Fix parsing update recipe response

This commit is contained in:
Kirill Kamakin
2022-10-30 11:53:48 +01:00
parent 90380dcbf1
commit 9ed229f20f
6 changed files with 9 additions and 10 deletions

View File

@@ -15,7 +15,7 @@ interface MealieDataSourceV1 {
token: String?,
slug: String,
recipe: UpdateRecipeRequestV1,
): String
): GetRecipeResponseV1
/**
* Tries to acquire authentication token using the provided credentials

View File

@@ -34,7 +34,7 @@ class MealieDataSourceV1Impl @Inject constructor(
token: String?,
slug: String,
recipe: UpdateRecipeRequestV1
): String = networkRequestWrapper.makeCallAndHandleUnauthorized(
): GetRecipeResponseV1 = networkRequestWrapper.makeCallAndHandleUnauthorized(
block = { service.updateRecipe("$baseUrl/api/recipes/$slug", token, recipe) },
logMethod = { "updateRecipe" },
logParameters = { "baseUrl = $baseUrl, token = $token, slug = $slug, recipe = $recipe" }

View File

@@ -21,12 +21,12 @@ interface MealieServiceV1 {
@Body addRecipeRequest: CreateRecipeRequestV1,
): String
@PUT
@PATCH
suspend fun updateRecipe(
@Url url: String,
@Header(AUTHORIZATION_HEADER_NAME) token: String?,
@Body addRecipeRequest: UpdateRecipeRequestV1,
): String
): GetRecipeResponseV1
@GET
suspend fun getVersion(

View File

@@ -5,13 +5,11 @@ import kotlinx.serialization.Serializable
@Serializable
data class UpdateRecipeRequestV1(
@SerialName("name") val name: String = "",
@SerialName("description") val description: String = "",
@SerialName("image") val image: String = "",
@SerialName("recipeYield") val recipeYield: String = "",
@SerialName("recipeIngredient") val recipeIngredient: List<AddRecipeIngredientV1> = emptyList(),
@SerialName("recipeInstructions") val recipeInstructions: List<AddRecipeInstructionV1> = emptyList(),
@SerialName("slug") val slug: String = "",
@SerialName("filePath") val filePath: String = "",
@SerialName("tags") val tags: List<String> = emptyList(),
@SerialName("categories") val categories: List<String> = emptyList(),
@@ -35,6 +33,7 @@ data class AddRecipeIngredientV1(
data class AddRecipeInstructionV1(
@SerialName("title") val title: String = "",
@SerialName("text") val text: String = "",
@SerialName("ingredientReferences") val ingredientReferences: List<String> = emptyList(),
)
@Serializable