diff --git a/tangem-sdk-core/src/main/java/com/tangem/common/SuccessResponse.kt b/tangem-sdk-core/src/main/java/com/tangem/common/SuccessResponse.kt index 001344fa..f7c142b9 100644 --- a/tangem-sdk-core/src/main/java/com/tangem/common/SuccessResponse.kt +++ b/tangem-sdk-core/src/main/java/com/tangem/common/SuccessResponse.kt @@ -1,7 +1,11 @@ package com.tangem.common +import com.squareup.moshi.Json import com.squareup.moshi.JsonClass import com.tangem.operations.CommandResponse @JsonClass(generateAdapter = true) -data class SuccessResponse(val cardId: String) : CommandResponse +data class SuccessResponse( + @Json(name = "cardId") + val cardId: String, +) : CommandResponse diff --git a/tangem-sdk-core/src/main/java/com/tangem/common/UserCode.kt b/tangem-sdk-core/src/main/java/com/tangem/common/UserCode.kt index a2844f33..c688428b 100644 --- a/tangem-sdk-core/src/main/java/com/tangem/common/UserCode.kt +++ b/tangem-sdk-core/src/main/java/com/tangem/common/UserCode.kt @@ -1,12 +1,15 @@ package com.tangem.common +import com.squareup.moshi.Json import com.squareup.moshi.JsonClass import com.tangem.common.core.SessionEnvironment import com.tangem.common.extensions.calculateSha256 @JsonClass(generateAdapter = true) class UserCode constructor( + @Json(name = "type") val type: UserCodeType, + @Json(name = "value") val value: ByteArray?, ) { constructor(type: UserCodeType) : this(type, type.defaultValue) @@ -19,8 +22,12 @@ class UserCode constructor( } } +@JsonClass(generateAdapter = false) enum class UserCodeType(val defaultValue: String) { + @Json(name = "AccessCode") AccessCode(UserCode.DefaultAccessCode), + + @Json(name = "Passcode") Passcode(UserCode.DefaultPasscode), ; diff --git a/tangem-sdk-core/src/main/java/com/tangem/common/json/JSONRPC.kt b/tangem-sdk-core/src/main/java/com/tangem/common/json/JSONRPC.kt index 52532bce..421f112b 100644 --- a/tangem-sdk-core/src/main/java/com/tangem/common/json/JSONRPC.kt +++ b/tangem-sdk-core/src/main/java/com/tangem/common/json/JSONRPC.kt @@ -1,5 +1,6 @@ package com.tangem.common.json +import com.squareup.moshi.Json import com.squareup.moshi.JsonClass import com.tangem.common.core.TangemError @@ -55,18 +56,31 @@ class JSONRPCRequest constructor( @JsonClass(generateAdapter = true) data class JSONRPCResponse( + @Json(name = "result") val result: Any?, + @Json(name = "error") val error: JSONRPCError?, + @Json(name = "id") val id: Int? = null, + @Json(name = "jsonrpc") val jsonrpc: String = "2.0", ) : JSONStringConvertible -data class ErrorData(val code: Int, val message: String) +@JsonClass(generateAdapter = true) +data class ErrorData( + @Json(name = "code") + val code: Int, + @Json(name = "message") + val message: String, +) @JsonClass(generateAdapter = true) class JSONRPCError constructor( + @Json(name = "code") val code: Int, + @Json(name = "message") val message: String, + @Json(name = "data") val data: ErrorData? = null, ) : JSONStringConvertible {