Skip to content

Commit

Permalink
refactor: move to a fqdn package
Browse files Browse the repository at this point in the history
  • Loading branch information
Vexcited committed Sep 26, 2024
1 parent e68267e commit f464ba1
Show file tree
Hide file tree
Showing 27 changed files with 91 additions and 80 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package api
package ink.literate.crowous.api

import core.Request
import decoders.decodeFeed
import ink.literate.crowous.core.Request
import ink.literate.crowous.decoders.decodeFeed
import kotlinx.serialization.json.*
import models.Feed
import ink.literate.crowous.models.Feed

suspend fun feeds (): List<Feed> {
val request = Request("feeds.json")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package api
package ink.literate.crowous.api

import core.Request
import decoders.decodeRestaurant
import ink.literate.crowous.core.Request
import ink.literate.crowous.decoders.decodeRestaurant
import kotlinx.datetime.LocalDate
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.jsonArray
import kotlinx.serialization.json.jsonObject
import models.Meal
import models.Moment
import models.Restaurant
import ink.literate.crowous.models.Meal
import ink.literate.crowous.models.Moment
import ink.literate.crowous.models.Restaurant

suspend fun restaurants (identifier: String): List<Restaurant> {
val request = Request("$identifier/externe/crous-$identifier.min.json")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package core
package ink.literate.crowous.core

import io.ktor.client.*
import io.ktor.client.request.*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package decoders
package ink.literate.crowous.decoders

import kotlinx.serialization.json.*
import models.Contact
import ink.literate.crowous.models.Contact

fun decodeContact (contact: JsonObject): Contact {
return Contact(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package decoders
package ink.literate.crowous.decoders

import kotlinx.serialization.json.*
import models.Feed
import ink.literate.crowous.models.Feed

fun decodeFeed (feed: JsonObject): Feed {
var name = feed["name"]!!.jsonPrimitive.content
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package decoders
package ink.literate.crowous.decoders

import kotlinx.serialization.json.*
import models.Image
import ink.literate.crowous.models.Image

fun decodeImage (contact: JsonObject): Image {
return Image(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package decoders
package ink.literate.crowous.decoders

import kotlinx.serialization.json.*
import models.MealCategory
import ink.literate.crowous.models.MealCategory

fun decodeMealCategory (category: JsonObject): MealCategory {
return MealCategory(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package decoders
package ink.literate.crowous.decoders

import kotlinx.serialization.json.*
import models.Meal
import ink.literate.crowous.models.Meal

fun decodeMeal (meal: JsonObject): Meal {
var information: String? = null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package decoders
package ink.literate.crowous.decoders

import kotlinx.datetime.LocalDate
import kotlinx.serialization.json.*
import models.Menu
import ink.literate.crowous.models.Menu

fun decodeMenu (menu: JsonObject): Menu {
return Menu(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package decoders
package ink.literate.crowous.decoders

import models.Moment
import ink.literate.crowous.models.Moment

fun decodeMoment (value: String): Moment {
return when (value) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package decoders
package ink.literate.crowous.decoders

import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.jsonPrimitive
import models.PaymentMethod
import ink.literate.crowous.models.PaymentMethod

fun decodePaymentMethod (method: JsonObject): PaymentMethod {
return when (val value = method["name"]!!.jsonPrimitive.content) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package decoders
package ink.literate.crowous.decoders

import models.RestaurantKind
import ink.literate.crowous.models.RestaurantKind

fun decodeRestaurantKind (kind: String): RestaurantKind {
return when (kind) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package decoders
package ink.literate.crowous.decoders

import kotlinx.serialization.json.*
import models.Restaurant
import ink.literate.crowous.models.Restaurant

fun decodeRestaurant (restaurant: JsonObject): Restaurant {
return Restaurant(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package models
package ink.literate.crowous.models

import kotlinx.serialization.Serializable

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package models
package ink.literate.crowous.models

import kotlinx.serialization.Serializable

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package models
package ink.literate.crowous.models

import kotlinx.serialization.Serializable

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package models
package ink.literate.crowous.models

import kotlinx.serialization.Serializable

Expand Down
10 changes: 10 additions & 0 deletions library/src/commonMain/kotlin/ink/literate/crowous/models/meal.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package ink.literate.crowous.models

import kotlinx.serialization.Serializable

@Serializable
data class Meal(
val moment: Moment,
val information: String?,
val categories: List<MealCategory>
)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package models
package ink.literate.crowous.models

import kotlinx.datetime.LocalDate
import kotlinx.serialization.Serializable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package models
package ink.literate.crowous.models

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package models
package ink.literate.crowous.models

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package models
package ink.literate.crowous.models

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package ink.literate.crowous.models

import kotlinx.serialization.Serializable

@Serializable
data class Restaurant(
val id: Int,
val title: String,
val latitude: Double,
val longitude: Double,
val area: String,
val address: String,
val opening: String,
val closing: String,
val kind: RestaurantKind,
val accessibility: Boolean,
val wifi: Boolean,
val shortDescription: String,
val description: String,
val access: String,
val operationalHours: String,
val contact: Contact,
val crousAndGo: String,
val album: Image?,
val photo: Image,
val paymentMethods: List<PaymentMethod>,
val menus: List<Menu>
)
10 changes: 0 additions & 10 deletions library/src/commonMain/kotlin/models/meal.kt

This file was deleted.

28 changes: 0 additions & 28 deletions library/src/commonMain/kotlin/models/restaurant.kt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package api
package ink.literate.crowous.api

import kotlinx.coroutines.runBlocking
import kotlin.test.Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package api
package ink.literate.crowous.api

import ink.literate.crowous.models.*
import kotlinx.coroutines.runBlocking
import kotlinx.datetime.LocalDate
import models.*
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertTrue
Expand All @@ -20,6 +20,17 @@ class RestaurantsTest {
paymentMethods = listOf(),
id = 1,
area = "Dummy",
/**
* Opening moments for the week.
*
* 0.Monday = morning, lunch, evening
* 1.Tuesday = lunch, evening
* 2.Wednesday = (none)
* 3.Thursday = lunch
* 4.Friday = morning
* 5.Saturday = evening
* 6.Sunday = (none)
*/
/**
* Opening moments for the week.
*
Expand Down

0 comments on commit f464ba1

Please sign in to comment.