Revenue Monster Kotlin Multiplatform SDK, support every possible platform, such as desktop and mobile.
repositories {
google()
mavenCentral()
}
dependencies {
implementation("io.revenuemonster.sdk:rm-kotlin-sdk:2.2.0")
}
⚠ Don't forget to implement ⚠
Kotlin Coroutines
Kotlinx Datetime
For more detail please visit our wiki
- Minimal package dependency
- Support multiple platform
Package name | Version |
---|---|
ktor | 2.1.2 |
kotlinx.serialization | 1.7.20 |
kotlinx-datetime | 0.4.0 |
The idea is to support every possible platforms without pain
Platform | Architecture | Technology | Package name | Support |
---|---|---|---|---|
macOS | JVM | rm-kotlin-sdk-jvm | ✅ | |
linux | JVM | rm-kotlin-sdk-jvm | ✅ | |
window | JVM | rm-kotlin-sdk-jvm | ✅ | |
android | Android | rm-kotlin-sdk-android | ✅ |
import io.revenuemonster.sdk.RevenueMonsterAuth
import io.revenuemonster.sdk.RevenueMonsterSDK
import io.revenuemonster.sdk.model.auth.Config
import io.revenuemonster.sdk.util.RMException
val config = Config(
clientID = "<<<Client ID>>>",
clientSecret = "<<<Client Secret>>>",
privateKey = "<<<YOUR PRIVATE KEY>>>",
sandbox = true
)
GlobalScope.launch {
try {
val auth = RevenueMonsterAuth(config).getAccessToken()
val sdk = RevenueMonsterSDK(auth)
val result = sdk.payment.getTransactions()
println(result)
}catch (e: RMException){
println(e.message)
println(e.errorCode)
println(e.errorMessage)
}catch (e: Throwable){
e.printStackTrace()
}
}
If there's some new Feature / Open API, is not updated only we suggest to use this method, we handled most of the data processing & security check part. What you need to do only pass the request parameters and url.
val sdk = RevenueMonsterSDK(auth)
val response = sdk.custom(url = "/v3/store/1692604052727021311", HttpMethod.Get)
val json = Json {
ignoreUnknownKeys = true
}
val store = json.decodeFromString<Item<Store>>(response.bodyAsText())
@Serializable
data class LoyaltyPointRequest(
val point: Int,
val type: String,
val countryCode: String,
val phoneNumber: String
)
@Serializable
data class RMResponse(
val code: String
)
val data = LoyaltyPointRequest(
point = 100,
type = "PHONENUMBER",
countryCode = "60",
phoneNumber = "123456789"
)
try{
val jsonElement = Json.encodeToJsonElement(data)
val sdk = RevenueMonsterSDK(auth)
val response = sdk.custom("/v3/loyalty/reward", HttpMethod.Post, jsonElement)
val result = Json.decodeFromString<RMResponse>(response.bodyAsText())
}catch (e: RMException){
println(e.message)
println(e.errorCode)
println(e.errorMessage)
}catch (e: Throwable){
e.printStackTrace()
}
Starting from version 2.1.1 onward, users will have the ability to manually set the timeout or socket timeout.
By default, the request timeout will be set to 95 seconds (95000L), and the socket timeout will be set to 60 seconds (60000L).
sdk.setTimeout(
timeout = 120000L,
socketTimeout = 120000L
)