Updated on 2026-08-14

This commit is contained in:
Tangem 2025-05-15 11:39:28 +03:00
parent a72837204d
commit 96b4a46462
8 changed files with 30 additions and 24 deletions

View file

@ -10,4 +10,13 @@ fun <T : Any, R : Any> ApiResponse<T>.fold(onSuccess: (T) -> R, onError: (ApiRes
is ApiResponse.Error -> onError(cause)
is ApiResponse.Success -> onSuccess(data)
}
}
inline fun <T> catchApiResponseError(onError: (ApiResponseError) -> Unit, block: () -> T): T {
return try {
block()
} catch (e: ApiResponseError) {
onError(e)
throw e
}
}

View file

@ -55,11 +55,11 @@ interface TangemTechApi {
/** Returns referral status by [walletId] */
@GET("referral/{walletId}")
suspend fun getReferralStatus(@Path("walletId") walletId: String): ReferralResponse
suspend fun getReferralStatus(@Path("walletId") walletId: String): ApiResponse<ReferralResponse>
/** Make user referral, requires [StartReferralBody] */
@POST("referral")
suspend fun startReferral(@Body startReferralBody: StartReferralBody): ReferralResponse
suspend fun startReferral(@Body startReferralBody: StartReferralBody): ApiResponse<ReferralResponse>
@GET("quotes")
suspend fun getQuotes(