Skip to content

Commit ef6e26f

Browse files
committed
fix: api incompatibility with older versions
1 parent d112460 commit ef6e26f

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

app/src/main/java/de/lukasneugebauer/nextcloudcookbook/recipe/data/dto/RecipePreviewDto.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@ package de.lukasneugebauer.nextcloudcookbook.recipe.data.dto
22

33
import com.google.gson.annotations.SerializedName
44
import de.lukasneugebauer.nextcloudcookbook.recipe.domain.model.RecipePreview
5+
import kotlin.jvm.Throws
56

67
data class RecipePreviewDto(
8+
@Deprecated(message = "As of Cookbook v0.10.3, this field is deprecated.", replaceWith = ReplaceWith(expression = "id"))
9+
@SerializedName("recipe_id")
10+
val recipeId: String?,
711
@SerializedName("id")
8-
val id: String,
12+
val id: String?,
913
@SerializedName("name")
1014
val name: String,
1115
@SerializedName("keywords")
@@ -21,9 +25,10 @@ data class RecipePreviewDto(
2125
@SerializedName("imagePlaceholderUrl")
2226
val imagePlaceholderUrl: String?,
2327
) {
28+
@Throws(IllegalStateException::class)
2429
fun toRecipePreview() =
2530
RecipePreview(
26-
id = id,
31+
id = if (!id.isNullOrBlank()) id else recipeId ?: throw IllegalStateException("Both 'id' and 'recipe_id' are null or blank"),
2732
name = name,
2833
keywords = keywords?.split(",")?.toSet() ?: emptySet(),
2934
category = category ?: "",

0 commit comments

Comments
 (0)