From 3fbd53d6c677c22bdd6dbdb72f900b1b57604267 Mon Sep 17 00:00:00 2001 From: Kirill Zhukov Date: Mon, 24 Jun 2024 20:26:06 -0700 Subject: [PATCH] Fix serialization of `Nut` model A serialization unit test was failing with ``` Unexpected JSON token at offset 170: Expected start of the array '[', but had '[' instead at path: $.nuts['4'].methods[0] ``` because response structure is different from the one used by `Nut`. Fix by introducing a `Method` model type as part of a `Nul` type matching actual json response structure. --- .../main/kotlin/me/tb/cashuclient/types/InfoResponse.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/src/main/kotlin/me/tb/cashuclient/types/InfoResponse.kt b/lib/src/main/kotlin/me/tb/cashuclient/types/InfoResponse.kt index 84be529..37d1795 100644 --- a/lib/src/main/kotlin/me/tb/cashuclient/types/InfoResponse.kt +++ b/lib/src/main/kotlin/me/tb/cashuclient/types/InfoResponse.kt @@ -20,9 +20,15 @@ public data class InfoResponse( val nuts: Map, ) +@Serializable +public data class Method( + val method: String, + val unit: String +) + @Serializable public data class Nut( - val methods: List>? = null, + val methods: List? = null, val disabled: Boolean? = null, val supported: Boolean? = null )