Initialize recipe removal feature

This commit is contained in:
Kirill Kamakin
2022-12-14 22:49:52 +01:00
parent 8e45a30480
commit 9ab86e7be3
16 changed files with 99 additions and 3 deletions

View File

@@ -46,4 +46,6 @@ interface MealieDataSourceV0 {
suspend fun removeFavoriteRecipe(userId: Int, recipeSlug: String)
suspend fun addFavoriteRecipe(userId: Int, recipeSlug: String)
suspend fun deleteRecipe(slug: String)
}

View File

@@ -115,4 +115,12 @@ class MealieDataSourceV0Impl @Inject constructor(
logMethod = { "addFavoriteRecipe" },
logParameters = { "userId = $userId, recipeSlug = $recipeSlug" }
)
override suspend fun deleteRecipe(
slug: String
): Unit = networkRequestWrapper.makeCallAndHandleUnauthorized(
block = { service.deleteRecipe(slug) },
logMethod = { "deleteRecipe" },
logParameters = { "slug = $slug" }
)
}

View File

@@ -55,4 +55,9 @@ interface MealieServiceV0 {
@Path("userId") userId: Int,
@Path("recipeSlug") recipeSlug: String
)
@DELETE("/api/recipes/{slug}")
suspend fun deleteRecipe(
@Path("slug") slug: String
)
}

View File

@@ -54,4 +54,5 @@ interface MealieDataSourceV1 {
suspend fun removeFavoriteRecipe(userId: String, recipeSlug: String)
suspend fun addFavoriteRecipe(userId: String, recipeSlug: String)
suspend fun deleteRecipe(slug: String)
}

View File

@@ -126,5 +126,13 @@ class MealieDataSourceV1Impl @Inject constructor(
logMethod = { "addFavoriteRecipe" },
logParameters = { "userId = $userId, recipeSlug = $recipeSlug" }
)
override suspend fun deleteRecipe(
slug: String
): Unit = networkRequestWrapper.makeCallAndHandleUnauthorized(
block = { service.deleteRecipe(slug) },
logMethod = { "deleteRecipe" },
logParameters = { "slug = $slug" }
)
}

View File

@@ -61,4 +61,9 @@ interface MealieServiceV1 {
@Path("userId") userId: String,
@Path("recipeSlug") recipeSlug: String
)
@DELETE("/api/recipes/{slug}")
suspend fun deleteRecipe(
@Path("slug") slug: String
)
}