From 47addc3b908318cbf04a9f5ee94f3b8b42a65b72 Mon Sep 17 00:00:00 2001 From: Kirill Kamakin Date: Sat, 29 Oct 2022 17:46:28 +0200 Subject: [PATCH] Fix opening recipes on v0.5.6 --- .../data/network/MealieDataSourceWrapper.kt | 14 ++- .../mealient/data/recipes/RecipeRepo.kt | 4 +- .../mealient/data/recipes/db/RecipeStorage.kt | 8 +- .../data/recipes/db/RecipeStorageImpl.kt | 6 +- .../data/recipes/impl/RecipeRepoImpl.kt | 4 +- .../data/recipes/network/FullRecipeInfo.kt | 34 +++++++ .../data/recipes/network/RecipeDataSource.kt | 4 +- .../extensions/RemoteToLocalMappings.kt | 98 +++++++++++++++---- .../ui/recipes/info/RecipeInfoUiState.kt | 4 +- .../mealient/test/RecipeImplTestData.kt | 4 +- .../mealient/database/recipe/RecipeDao.kt | 2 +- ...{FullRecipeInfo.kt => FullRecipeEntity.kt} | 2 +- .../datasource/models/GetRecipeResponse.kt | 2 +- .../mealient/datasource/v1/MealieServiceV1.kt | 3 +- .../models/GetRecipeIngredientResponseV1.kt | 14 +++ .../models/GetRecipeInstructionResponseV1.kt | 10 ++ .../v1/models/GetRecipeResponseV1.kt | 23 +++++ 17 files changed, 192 insertions(+), 44 deletions(-) create mode 100644 app/src/main/java/gq/kirmanak/mealient/data/recipes/network/FullRecipeInfo.kt rename database/src/main/kotlin/gq/kirmanak/mealient/database/recipe/entity/{FullRecipeInfo.kt => FullRecipeEntity.kt} (95%) create mode 100644 datasource/src/main/kotlin/gq/kirmanak/mealient/datasource/v1/models/GetRecipeIngredientResponseV1.kt create mode 100644 datasource/src/main/kotlin/gq/kirmanak/mealient/datasource/v1/models/GetRecipeInstructionResponseV1.kt create mode 100644 datasource/src/main/kotlin/gq/kirmanak/mealient/datasource/v1/models/GetRecipeResponseV1.kt diff --git a/app/src/main/java/gq/kirmanak/mealient/data/network/MealieDataSourceWrapper.kt b/app/src/main/java/gq/kirmanak/mealient/data/network/MealieDataSourceWrapper.kt index c9205cc..733dc58 100644 --- a/app/src/main/java/gq/kirmanak/mealient/data/network/MealieDataSourceWrapper.kt +++ b/app/src/main/java/gq/kirmanak/mealient/data/network/MealieDataSourceWrapper.kt @@ -5,14 +5,15 @@ import gq.kirmanak.mealient.data.auth.AuthRepo import gq.kirmanak.mealient.data.baseurl.BaseURLStorage import gq.kirmanak.mealient.data.baseurl.VersionDataSource import gq.kirmanak.mealient.data.baseurl.VersionInfo +import gq.kirmanak.mealient.data.recipes.network.FullRecipeInfo import gq.kirmanak.mealient.data.recipes.network.RecipeDataSource import gq.kirmanak.mealient.data.recipes.network.RecipeSummaryInfo import gq.kirmanak.mealient.datasource.MealieDataSource import gq.kirmanak.mealient.datasource.models.AddRecipeRequest -import gq.kirmanak.mealient.datasource.models.GetRecipeResponse import gq.kirmanak.mealient.datasource.models.NetworkError import gq.kirmanak.mealient.datasource.v1.MealieDataSourceV1 import gq.kirmanak.mealient.extensions.runCatchingExceptCancel +import gq.kirmanak.mealient.extensions.toFullRecipeInfo import gq.kirmanak.mealient.extensions.toRecipeSummaryInfo import gq.kirmanak.mealient.extensions.toVersionInfo import javax.inject.Inject @@ -50,8 +51,15 @@ class MealieDataSourceWrapper @Inject constructor( } } - override suspend fun requestRecipeInfo(slug: String): GetRecipeResponse = - withAuthHeader { token -> source.requestRecipeInfo(getUrl(), token, slug) } + override suspend fun requestRecipeInfo(slug: String): FullRecipeInfo = + withAuthHeader { token -> + val url = getUrl() + if (isV1()) { + v1Source.requestRecipeInfo(url, token, slug).toFullRecipeInfo() + } else { + source.requestRecipeInfo(url, token, slug).toFullRecipeInfo() + } + } private suspend fun getUrl() = baseURLStorage.requireBaseURL() diff --git a/app/src/main/java/gq/kirmanak/mealient/data/recipes/RecipeRepo.kt b/app/src/main/java/gq/kirmanak/mealient/data/recipes/RecipeRepo.kt index 9c42bf0..4cd3b1b 100644 --- a/app/src/main/java/gq/kirmanak/mealient/data/recipes/RecipeRepo.kt +++ b/app/src/main/java/gq/kirmanak/mealient/data/recipes/RecipeRepo.kt @@ -1,7 +1,7 @@ package gq.kirmanak.mealient.data.recipes import androidx.paging.Pager -import gq.kirmanak.mealient.database.recipe.entity.FullRecipeInfo +import gq.kirmanak.mealient.database.recipe.entity.FullRecipeEntity import gq.kirmanak.mealient.database.recipe.entity.RecipeSummaryEntity interface RecipeRepo { @@ -9,5 +9,5 @@ interface RecipeRepo { suspend fun clearLocalData() - suspend fun loadRecipeInfo(recipeId: String, recipeSlug: String): FullRecipeInfo + suspend fun loadRecipeInfo(recipeId: String, recipeSlug: String): FullRecipeEntity } \ No newline at end of file diff --git a/app/src/main/java/gq/kirmanak/mealient/data/recipes/db/RecipeStorage.kt b/app/src/main/java/gq/kirmanak/mealient/data/recipes/db/RecipeStorage.kt index 2d70c3c..431e74a 100644 --- a/app/src/main/java/gq/kirmanak/mealient/data/recipes/db/RecipeStorage.kt +++ b/app/src/main/java/gq/kirmanak/mealient/data/recipes/db/RecipeStorage.kt @@ -1,10 +1,10 @@ package gq.kirmanak.mealient.data.recipes.db import androidx.paging.PagingSource +import gq.kirmanak.mealient.data.recipes.network.FullRecipeInfo import gq.kirmanak.mealient.data.recipes.network.RecipeSummaryInfo -import gq.kirmanak.mealient.database.recipe.entity.FullRecipeInfo +import gq.kirmanak.mealient.database.recipe.entity.FullRecipeEntity import gq.kirmanak.mealient.database.recipe.entity.RecipeSummaryEntity -import gq.kirmanak.mealient.datasource.models.GetRecipeResponse interface RecipeStorage { suspend fun saveRecipes(recipes: List) @@ -15,7 +15,7 @@ interface RecipeStorage { suspend fun clearAllLocalData() - suspend fun saveRecipeInfo(recipe: GetRecipeResponse) + suspend fun saveRecipeInfo(recipe: FullRecipeInfo) - suspend fun queryRecipeInfo(recipeId: String): FullRecipeInfo + suspend fun queryRecipeInfo(recipeId: String): FullRecipeEntity } \ No newline at end of file diff --git a/app/src/main/java/gq/kirmanak/mealient/data/recipes/db/RecipeStorageImpl.kt b/app/src/main/java/gq/kirmanak/mealient/data/recipes/db/RecipeStorageImpl.kt index aa6cdcb..8f5224e 100644 --- a/app/src/main/java/gq/kirmanak/mealient/data/recipes/db/RecipeStorageImpl.kt +++ b/app/src/main/java/gq/kirmanak/mealient/data/recipes/db/RecipeStorageImpl.kt @@ -2,11 +2,11 @@ package gq.kirmanak.mealient.data.recipes.db import androidx.paging.PagingSource import androidx.room.withTransaction +import gq.kirmanak.mealient.data.recipes.network.FullRecipeInfo import gq.kirmanak.mealient.data.recipes.network.RecipeSummaryInfo import gq.kirmanak.mealient.database.AppDb import gq.kirmanak.mealient.database.recipe.RecipeDao import gq.kirmanak.mealient.database.recipe.entity.* -import gq.kirmanak.mealient.datasource.models.GetRecipeResponse import gq.kirmanak.mealient.extensions.recipeEntity import gq.kirmanak.mealient.extensions.toRecipeEntity import gq.kirmanak.mealient.extensions.toRecipeIngredientEntity @@ -113,7 +113,7 @@ class RecipeStorageImpl @Inject constructor( } } - override suspend fun saveRecipeInfo(recipe: GetRecipeResponse) { + override suspend fun saveRecipeInfo(recipe: FullRecipeInfo) { logger.v { "saveRecipeInfo() called with: recipe = $recipe" } db.withTransaction { recipeDao.insertRecipe(recipe.toRecipeEntity()) @@ -132,7 +132,7 @@ class RecipeStorageImpl @Inject constructor( } } - override suspend fun queryRecipeInfo(recipeId: String): FullRecipeInfo { + override suspend fun queryRecipeInfo(recipeId: String): FullRecipeEntity { logger.v { "queryRecipeInfo() called with: recipeId = $recipeId" } val fullRecipeInfo = checkNotNull(recipeDao.queryFullRecipeInfo(recipeId)) { "Can't find recipe by id $recipeId in DB" diff --git a/app/src/main/java/gq/kirmanak/mealient/data/recipes/impl/RecipeRepoImpl.kt b/app/src/main/java/gq/kirmanak/mealient/data/recipes/impl/RecipeRepoImpl.kt index 5398aae..0fee9f7 100644 --- a/app/src/main/java/gq/kirmanak/mealient/data/recipes/impl/RecipeRepoImpl.kt +++ b/app/src/main/java/gq/kirmanak/mealient/data/recipes/impl/RecipeRepoImpl.kt @@ -7,7 +7,7 @@ import androidx.paging.PagingConfig import gq.kirmanak.mealient.data.recipes.RecipeRepo import gq.kirmanak.mealient.data.recipes.db.RecipeStorage import gq.kirmanak.mealient.data.recipes.network.RecipeDataSource -import gq.kirmanak.mealient.database.recipe.entity.FullRecipeInfo +import gq.kirmanak.mealient.database.recipe.entity.FullRecipeEntity import gq.kirmanak.mealient.database.recipe.entity.RecipeSummaryEntity import gq.kirmanak.mealient.extensions.runCatchingExceptCancel import gq.kirmanak.mealient.logging.Logger @@ -38,7 +38,7 @@ class RecipeRepoImpl @Inject constructor( storage.clearAllLocalData() } - override suspend fun loadRecipeInfo(recipeId: String, recipeSlug: String): FullRecipeInfo { + override suspend fun loadRecipeInfo(recipeId: String, recipeSlug: String): FullRecipeEntity { logger.v { "loadRecipeInfo() called with: recipeId = $recipeId, recipeSlug = $recipeSlug" } runCatchingExceptCancel { diff --git a/app/src/main/java/gq/kirmanak/mealient/data/recipes/network/FullRecipeInfo.kt b/app/src/main/java/gq/kirmanak/mealient/data/recipes/network/FullRecipeInfo.kt new file mode 100644 index 0000000..395b194 --- /dev/null +++ b/app/src/main/java/gq/kirmanak/mealient/data/recipes/network/FullRecipeInfo.kt @@ -0,0 +1,34 @@ +package gq.kirmanak.mealient.data.recipes.network + +import kotlinx.datetime.LocalDate +import kotlinx.datetime.LocalDateTime + +data class FullRecipeInfo( + val remoteId: String, + val name: String, + val slug: String, + val image: String, + val description: String, + val recipeCategories: List, + val tags: List, + val rating: Int?, + val dateAdded: LocalDate, + val dateUpdated: LocalDateTime, + val recipeYield: String, + val recipeIngredients: List, + val recipeInstructions: List, +) + +data class RecipeIngredientInfo( + val title: String, + val note: String, + val unit: String, + val food: String, + val disableAmount: Boolean, + val quantity: Double, +) + +data class RecipeInstructionInfo( + val title: String, + val text: String, +) diff --git a/app/src/main/java/gq/kirmanak/mealient/data/recipes/network/RecipeDataSource.kt b/app/src/main/java/gq/kirmanak/mealient/data/recipes/network/RecipeDataSource.kt index 18fef8c..4305eb5 100644 --- a/app/src/main/java/gq/kirmanak/mealient/data/recipes/network/RecipeDataSource.kt +++ b/app/src/main/java/gq/kirmanak/mealient/data/recipes/network/RecipeDataSource.kt @@ -1,9 +1,7 @@ package gq.kirmanak.mealient.data.recipes.network -import gq.kirmanak.mealient.datasource.models.GetRecipeResponse - interface RecipeDataSource { suspend fun requestRecipes(start: Int, limit: Int): List - suspend fun requestRecipeInfo(slug: String): GetRecipeResponse + suspend fun requestRecipeInfo(slug: String): FullRecipeInfo } \ No newline at end of file diff --git a/app/src/main/java/gq/kirmanak/mealient/extensions/RemoteToLocalMappings.kt b/app/src/main/java/gq/kirmanak/mealient/extensions/RemoteToLocalMappings.kt index 223402d..a819df8 100644 --- a/app/src/main/java/gq/kirmanak/mealient/extensions/RemoteToLocalMappings.kt +++ b/app/src/main/java/gq/kirmanak/mealient/extensions/RemoteToLocalMappings.kt @@ -1,38 +1,38 @@ package gq.kirmanak.mealient.extensions import gq.kirmanak.mealient.data.baseurl.VersionInfo +import gq.kirmanak.mealient.data.recipes.network.FullRecipeInfo +import gq.kirmanak.mealient.data.recipes.network.RecipeIngredientInfo +import gq.kirmanak.mealient.data.recipes.network.RecipeInstructionInfo import gq.kirmanak.mealient.data.recipes.network.RecipeSummaryInfo import gq.kirmanak.mealient.database.recipe.entity.RecipeEntity import gq.kirmanak.mealient.database.recipe.entity.RecipeIngredientEntity import gq.kirmanak.mealient.database.recipe.entity.RecipeInstructionEntity import gq.kirmanak.mealient.database.recipe.entity.RecipeSummaryEntity import gq.kirmanak.mealient.datasource.models.* -import gq.kirmanak.mealient.datasource.v1.models.GetRecipeSummaryResponseV1 -import gq.kirmanak.mealient.datasource.v1.models.VersionResponseV1 +import gq.kirmanak.mealient.datasource.v1.models.* import gq.kirmanak.mealient.datastore.recipe.AddRecipeDraft -fun GetRecipeResponse.toRecipeEntity() = RecipeEntity( +fun FullRecipeInfo.toRecipeEntity() = RecipeEntity( remoteId = remoteId, recipeYield = recipeYield ) -fun GetRecipeIngredientResponse.toRecipeIngredientEntity(remoteId: String) = - RecipeIngredientEntity( - recipeId = remoteId, - title = title, - note = note, - unit = unit, - food = food, - disableAmount = disableAmount, - quantity = quantity - ) +fun RecipeIngredientInfo.toRecipeIngredientEntity(remoteId: String) = RecipeIngredientEntity( + recipeId = remoteId, + title = title, + note = note, + unit = unit, + food = food, + disableAmount = disableAmount, + quantity = quantity +) -fun GetRecipeInstructionResponse.toRecipeInstructionEntity(remoteId: String) = - RecipeInstructionEntity( - recipeId = remoteId, - title = title, - text = text - ) +fun RecipeInstructionInfo.toRecipeInstructionEntity(remoteId: String) = RecipeInstructionEntity( + recipeId = remoteId, + title = title, + text = text +) fun GetRecipeSummaryResponse.toRecipeSummaryInfo() = RecipeSummaryInfo( remoteId = remoteId.toString(), @@ -99,3 +99,63 @@ fun AddRecipeRequest.toDraft(): AddRecipeDraft = AddRecipeDraft( isRecipePublic = settings.public, areCommentsDisabled = settings.disableComments, ) + +fun GetRecipeResponse.toFullRecipeInfo() = FullRecipeInfo( + remoteId = remoteId.toString(), + name = name, + slug = slug, + image = image, + description = description, + recipeCategories = recipeCategories, + tags = tags, + rating = rating, + dateAdded = dateAdded, + dateUpdated = dateUpdated, + recipeYield = recipeYield, + recipeIngredients = recipeIngredients.map { it.toRecipeIngredientInfo() }, + recipeInstructions = recipeInstructions.map { it.toRecipeInstructionInfo() } +) + +fun GetRecipeIngredientResponse.toRecipeIngredientInfo() = RecipeIngredientInfo( + title = title, + note = note, + unit = unit, + food = food, + disableAmount = disableAmount, + quantity = quantity +) + +fun GetRecipeInstructionResponse.toRecipeInstructionInfo() = RecipeInstructionInfo( + title = title, + text = text +) + +fun GetRecipeResponseV1.toFullRecipeInfo() = FullRecipeInfo( + remoteId = remoteId, + name = name, + slug = slug, + image = image, + description = description, + recipeCategories = recipeCategories, + tags = tags, + rating = rating, + dateAdded = dateAdded, + dateUpdated = dateUpdated, + recipeYield = recipeYield, + recipeIngredients = recipeIngredients.map { it.toRecipeIngredientInfo() }, + recipeInstructions = recipeInstructions.map { it.toRecipeInstructionInfo() } +) + +fun GetRecipeIngredientResponseV1.toRecipeIngredientInfo() = RecipeIngredientInfo( + title = title, + note = note, + unit = unit, + food = food, + disableAmount = disableAmount, + quantity = quantity +) + +fun GetRecipeInstructionResponseV1.toRecipeInstructionInfo() = RecipeInstructionInfo( + title = title, + text = text +) diff --git a/app/src/main/java/gq/kirmanak/mealient/ui/recipes/info/RecipeInfoUiState.kt b/app/src/main/java/gq/kirmanak/mealient/ui/recipes/info/RecipeInfoUiState.kt index 4d1fff5..6083fae 100644 --- a/app/src/main/java/gq/kirmanak/mealient/ui/recipes/info/RecipeInfoUiState.kt +++ b/app/src/main/java/gq/kirmanak/mealient/ui/recipes/info/RecipeInfoUiState.kt @@ -1,9 +1,9 @@ package gq.kirmanak.mealient.ui.recipes.info -import gq.kirmanak.mealient.database.recipe.entity.FullRecipeInfo +import gq.kirmanak.mealient.database.recipe.entity.FullRecipeEntity data class RecipeInfoUiState( val areIngredientsVisible: Boolean = false, val areInstructionsVisible: Boolean = false, - val recipeInfo: FullRecipeInfo? = null, + val recipeInfo: FullRecipeEntity? = null, ) diff --git a/app/src/test/java/gq/kirmanak/mealient/test/RecipeImplTestData.kt b/app/src/test/java/gq/kirmanak/mealient/test/RecipeImplTestData.kt index d64ec91..d6bc2ee 100644 --- a/app/src/test/java/gq/kirmanak/mealient/test/RecipeImplTestData.kt +++ b/app/src/test/java/gq/kirmanak/mealient/test/RecipeImplTestData.kt @@ -174,7 +174,7 @@ object RecipeImplTestData { quantity = 2 ) - val FULL_CAKE_INFO_ENTITY = FullRecipeInfo( + val FULL_CAKE_INFO_ENTITY = FullRecipeEntity( recipeEntity = CAKE_RECIPE_ENTITY, recipeSummaryEntity = CAKE_RECIPE_SUMMARY_ENTITY, recipeIngredients = listOf( @@ -228,7 +228,7 @@ object RecipeImplTestData { text = "Boil the ingredients" ) - val FULL_PORRIDGE_INFO_ENTITY = FullRecipeInfo( + val FULL_PORRIDGE_INFO_ENTITY = FullRecipeEntity( recipeEntity = PORRIDGE_RECIPE_ENTITY_FULL, recipeSummaryEntity = PORRIDGE_RECIPE_SUMMARY_ENTITY, recipeIngredients = listOf( diff --git a/database/src/main/kotlin/gq/kirmanak/mealient/database/recipe/RecipeDao.kt b/database/src/main/kotlin/gq/kirmanak/mealient/database/recipe/RecipeDao.kt index 4113f37..091ec3f 100644 --- a/database/src/main/kotlin/gq/kirmanak/mealient/database/recipe/RecipeDao.kt +++ b/database/src/main/kotlin/gq/kirmanak/mealient/database/recipe/RecipeDao.kt @@ -66,7 +66,7 @@ interface RecipeDao { @Transaction @SuppressWarnings(RoomWarnings.CURSOR_MISMATCH) // The lint is wrong, the columns are actually used @Query("SELECT * FROM recipe JOIN recipe_summaries ON recipe.remote_id = recipe_summaries.remote_id JOIN recipe_ingredient ON recipe_ingredient.recipe_id = recipe.remote_id JOIN recipe_instruction ON recipe_instruction.recipe_id = recipe.remote_id WHERE recipe.remote_id = :recipeId") - suspend fun queryFullRecipeInfo(recipeId: String): FullRecipeInfo? + suspend fun queryFullRecipeInfo(recipeId: String): FullRecipeEntity? @Query("DELETE FROM recipe_ingredient WHERE recipe_id = :recipeId") suspend fun deleteRecipeIngredients(recipeId: String) diff --git a/database/src/main/kotlin/gq/kirmanak/mealient/database/recipe/entity/FullRecipeInfo.kt b/database/src/main/kotlin/gq/kirmanak/mealient/database/recipe/entity/FullRecipeEntity.kt similarity index 95% rename from database/src/main/kotlin/gq/kirmanak/mealient/database/recipe/entity/FullRecipeInfo.kt rename to database/src/main/kotlin/gq/kirmanak/mealient/database/recipe/entity/FullRecipeEntity.kt index 27b02cc..2c0cab0 100644 --- a/database/src/main/kotlin/gq/kirmanak/mealient/database/recipe/entity/FullRecipeInfo.kt +++ b/database/src/main/kotlin/gq/kirmanak/mealient/database/recipe/entity/FullRecipeEntity.kt @@ -3,7 +3,7 @@ package gq.kirmanak.mealient.database.recipe.entity import androidx.room.Embedded import androidx.room.Relation -data class FullRecipeInfo( +data class FullRecipeEntity( @Embedded val recipeEntity: RecipeEntity, @Relation( parentColumn = "remote_id", diff --git a/datasource/src/main/kotlin/gq/kirmanak/mealient/datasource/models/GetRecipeResponse.kt b/datasource/src/main/kotlin/gq/kirmanak/mealient/datasource/models/GetRecipeResponse.kt index 36f9ee4..1f7dd8d 100644 --- a/datasource/src/main/kotlin/gq/kirmanak/mealient/datasource/models/GetRecipeResponse.kt +++ b/datasource/src/main/kotlin/gq/kirmanak/mealient/datasource/models/GetRecipeResponse.kt @@ -7,7 +7,7 @@ import kotlinx.serialization.Serializable @Serializable data class GetRecipeResponse( - @SerialName("id") val remoteId: String, + @SerialName("id") val remoteId: Int, @SerialName("name") val name: String, @SerialName("slug") val slug: String, @SerialName("image") val image: String, diff --git a/datasource/src/main/kotlin/gq/kirmanak/mealient/datasource/v1/MealieServiceV1.kt b/datasource/src/main/kotlin/gq/kirmanak/mealient/datasource/v1/MealieServiceV1.kt index 5e6146c..b631c81 100644 --- a/datasource/src/main/kotlin/gq/kirmanak/mealient/datasource/v1/MealieServiceV1.kt +++ b/datasource/src/main/kotlin/gq/kirmanak/mealient/datasource/v1/MealieServiceV1.kt @@ -2,6 +2,7 @@ package gq.kirmanak.mealient.datasource.v1 import gq.kirmanak.mealient.datasource.DataSourceModule.Companion.AUTHORIZATION_HEADER_NAME import gq.kirmanak.mealient.datasource.models.* +import gq.kirmanak.mealient.datasource.v1.models.GetRecipeResponseV1 import gq.kirmanak.mealient.datasource.v1.models.GetRecipesResponseV1 import gq.kirmanak.mealient.datasource.v1.models.VersionResponseV1 import retrofit2.http.* @@ -40,5 +41,5 @@ interface MealieServiceV1 { suspend fun getRecipe( @Url url: String, @Header(AUTHORIZATION_HEADER_NAME) token: String?, - ): GetRecipeResponse + ): GetRecipeResponseV1 } \ No newline at end of file diff --git a/datasource/src/main/kotlin/gq/kirmanak/mealient/datasource/v1/models/GetRecipeIngredientResponseV1.kt b/datasource/src/main/kotlin/gq/kirmanak/mealient/datasource/v1/models/GetRecipeIngredientResponseV1.kt new file mode 100644 index 0000000..68bd444 --- /dev/null +++ b/datasource/src/main/kotlin/gq/kirmanak/mealient/datasource/v1/models/GetRecipeIngredientResponseV1.kt @@ -0,0 +1,14 @@ +package gq.kirmanak.mealient.datasource.v1.models + +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class GetRecipeIngredientResponseV1( + @SerialName("title") val title: String = "", + @SerialName("note") val note: String = "", + @SerialName("unit") val unit: String = "", + @SerialName("food") val food: String = "", + @SerialName("disableAmount") val disableAmount: Boolean, + @SerialName("quantity") val quantity: Double, +) diff --git a/datasource/src/main/kotlin/gq/kirmanak/mealient/datasource/v1/models/GetRecipeInstructionResponseV1.kt b/datasource/src/main/kotlin/gq/kirmanak/mealient/datasource/v1/models/GetRecipeInstructionResponseV1.kt new file mode 100644 index 0000000..12b5cc7 --- /dev/null +++ b/datasource/src/main/kotlin/gq/kirmanak/mealient/datasource/v1/models/GetRecipeInstructionResponseV1.kt @@ -0,0 +1,10 @@ +package gq.kirmanak.mealient.datasource.v1.models + +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class GetRecipeInstructionResponseV1( + @SerialName("title") val title: String = "", + @SerialName("text") val text: String, +) diff --git a/datasource/src/main/kotlin/gq/kirmanak/mealient/datasource/v1/models/GetRecipeResponseV1.kt b/datasource/src/main/kotlin/gq/kirmanak/mealient/datasource/v1/models/GetRecipeResponseV1.kt new file mode 100644 index 0000000..a9ca1f5 --- /dev/null +++ b/datasource/src/main/kotlin/gq/kirmanak/mealient/datasource/v1/models/GetRecipeResponseV1.kt @@ -0,0 +1,23 @@ +package gq.kirmanak.mealient.datasource.v1.models + +import kotlinx.datetime.LocalDate +import kotlinx.datetime.LocalDateTime +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class GetRecipeResponseV1( + @SerialName("id") val remoteId: String, + @SerialName("name") val name: String, + @SerialName("slug") val slug: String, + @SerialName("image") val image: String, + @SerialName("description") val description: String = "", + @SerialName("recipeCategory") val recipeCategories: List, + @SerialName("tags") val tags: List, + @SerialName("rating") val rating: Int?, + @SerialName("dateAdded") val dateAdded: LocalDate, + @SerialName("dateUpdated") val dateUpdated: LocalDateTime, + @SerialName("recipeYield") val recipeYield: String = "", + @SerialName("recipeIngredient") val recipeIngredients: List, + @SerialName("recipeInstructions") val recipeInstructions: List, +)