Updated on 2026-08-14
This commit is contained in:
parent
efe271e1a0
commit
b87a0ae96b
18 changed files with 91 additions and 79 deletions
|
|
@ -4,35 +4,26 @@ import com.tangem.datasource.api.promotion.models.*
|
|||
import retrofit2.http.*
|
||||
|
||||
/**
|
||||
*
|
||||
* Promotion API
|
||||
* @see <a href = "https://www.notion.so/tangem/Promotion-Program-API-0907159c3fdb4975aac761be632f44da">Documentation<a/>
|
||||
[REDACTED_AUTHOR]
|
||||
* Api details
|
||||
* https://www.notion.so/tangem/Promotion-Program-API-0907159c3fdb4975aac761be632f44da
|
||||
*/
|
||||
interface PromotionApi {
|
||||
|
||||
|
||||
@Headers("Cache-Control: max-age=$CACHE_CONTROL_SECONDS")
|
||||
@Headers("Cache-Control: max-age=3600")
|
||||
@GET("promotion")
|
||||
suspend fun getPromotionInfo(@Query("programName") name: String): PromotionInfoResponse
|
||||
|
||||
|
||||
@POST("promotion/code/validate")
|
||||
suspend fun codeValidate(@Body request: CodeValidateRequestBody): CodeValidateResponse
|
||||
suspend fun validateCode(@Body request: CodeValidateRequestBody): CodeValidateResponse
|
||||
|
||||
|
||||
@POST("promotion/code/award")
|
||||
suspend fun codeAward(@Body request: CodeAwardRequestBody): CodeAwardResponse
|
||||
suspend fun requestAwardByCode(@Body request: CodeAwardRequestBody): CodeAwardResponse
|
||||
|
||||
|
||||
@POST("promotion/validate")
|
||||
suspend fun validate(@Body request: ValidateRequestBody): ValidateResponse
|
||||
|
||||
|
||||
@GET("promotion/award")
|
||||
suspend fun award(@Body request: AwardRequestBody): AwardResponse
|
||||
|
||||
companion object {
|
||||
const val ONE_INCH_TIMEOUT_MS = 5000L
|
||||
const val CACHE_CONTROL_SECONDS = 3600
|
||||
}
|
||||
suspend fun requestAward(@Body request: AwardRequestBody): AwardResponse
|
||||
}
|
||||
|
|
@ -14,7 +14,5 @@ abstract class AbstractPromotionResponse {
|
|||
data class Error(
|
||||
@Json(name = "code") val code: Int,
|
||||
@Json(name = "description") val description: String,
|
||||
) {
|
||||
companion object
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
@ -66,10 +66,10 @@ class NetworkModule {
|
|||
AuthenticationHeader(authProvider),
|
||||
)
|
||||
.allowLogging()
|
||||
.callTimeout(PromotionApi.ONE_INCH_TIMEOUT_MS, TimeUnit.MILLISECONDS)
|
||||
.connectTimeout(PromotionApi.ONE_INCH_TIMEOUT_MS, TimeUnit.MILLISECONDS)
|
||||
.readTimeout(PromotionApi.ONE_INCH_TIMEOUT_MS, TimeUnit.MILLISECONDS)
|
||||
.writeTimeout(PromotionApi.ONE_INCH_TIMEOUT_MS, TimeUnit.MILLISECONDS)
|
||||
.callTimeout(API_ONE_INCH_TIMEOUT_MS, TimeUnit.MILLISECONDS)
|
||||
.connectTimeout(API_ONE_INCH_TIMEOUT_MS, TimeUnit.MILLISECONDS)
|
||||
.readTimeout(API_ONE_INCH_TIMEOUT_MS, TimeUnit.MILLISECONDS)
|
||||
.writeTimeout(API_ONE_INCH_TIMEOUT_MS, TimeUnit.MILLISECONDS)
|
||||
.build()
|
||||
return createBasePromotionRetrofit(okClient, moshi)
|
||||
}
|
||||
|
|
@ -90,5 +90,6 @@ class NetworkModule {
|
|||
const val PROMOTION_BASE_URL = "https://tangem.com/v1/"
|
||||
|
||||
const val PAYMENTOLOGY_BASE_URL: String = "https://paymentologygate.oa.r.appspot.com/"
|
||||
const val API_ONE_INCH_TIMEOUT_MS = 5000L
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue