Updated on 2026-08-14

This commit is contained in:
Tangem 2022-11-11 15:25:06 +03:00
parent df818fa72a
commit 241f8d217c
6 changed files with 74 additions and 1 deletions

View file

@ -43,4 +43,7 @@ dependencies {
implementation(Library.moshiKotlin)
implementation(Library.okHttp)
implementation(Library.okHttpLogging)
/** Time */
implementation(Library.jodatime)
}

View file

@ -1,7 +1,22 @@
package com.tangem.datasource.api.referral
import com.tangem.datasource.api.referral.models.ReferralResponse
import com.tangem.datasource.api.referral.models.StartReferralBody
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Query
/**
* Api for referral functionality
* Api for referral feature
*/
interface ReferralApi {
/** Returns referral status by [walletId] */
@GET("referral/{walletId}")
suspend fun getReferralStatus(@Query("name") walletId: String): ReferralResponse
/** Make user referral, requires [StartReferralBody] */
@POST("referral")
suspend fun startReferral(@Body startReferralBody: StartReferralBody): ReferralResponse
}

View file

@ -0,0 +1,42 @@
package com.tangem.datasource.api.referral.models
import com.squareup.moshi.Json
import org.joda.time.DateTime
/**
* Main response class for referral API
* contains all necessary info about users program status
*/
data class ReferralResponse(
@Json(name = "conditions") val conditions: Conditions,
)
data class Conditions(
@Json(name = "conditions") val award: Int,
@Json(name = "discount") val discount: Int,
@Json(name = "discountType") val discountType: DiscountType,
@Json(name = "tosLink") val tosLink: String,
@Json(name = "tokens") val tokens: List<Token>,
@Json(name = "referral") val referral: Referral,
)
data class Token(
@Json(name = "id") val id: String,
@Json(name = "name") val name: String,
@Json(name = "symbol") val symbol: String,
@Json(name = "networkId") val networkId: String?,
@Json(name = "contractAddress") val contractAddress: String?,
@Json(name = "decimalCount") val decimalCount: Int,
)
data class Referral(
@Json(name = "shareLink") val shareLink: String,
@Json(name = "address") val address: String,
@Json(name = "promocode") val promocode: String,
@Json(name = "walletsPurchased") val walletsPurchased: Int,
@Json(name = "termsAcceptedAt") val termsAcceptedAt: DateTime?,
)
enum class DiscountType {
PERCENTAGE, VALUE
}

View file

@ -0,0 +1,11 @@
package com.tangem.datasource.api.referral.models
import com.squareup.moshi.Json
/** Body for make user referral */
data class StartReferralBody(
@Json(name = "walletId") val walletId: String,
@Json(name = "networkId") val networkId: String,
@Json(name = "tokenId") val tokenId: String,
@Json(name = "address") val address: String,
)