RM Kotlin Multiplatform SDK

Revenue Monster Kotlin Multiplatform SDK, support every possible platform, such as desktop and mobile.
🔨 Installation with Gradle
Maven Central
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
🪣 Requirements
- Kotlin compiler at least 1.5.10
- JDK at least 1.8
✨ Features
- Minimal package dependency
- Support multiple platform
📦️ Dependencies
| Package name | Version |
|---|
| ktor | 2.1.2 |
|
🤖 Supported Platforms
The idea is to support every possible platforms without pain
🙈 Example
How to get your credential
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 =
)
GlobalScope.launch {
{
auth = RevenueMonsterAuth(config).getAccessToken()
sdk = RevenueMonsterSDK(auth)
result = sdk.payment.getTransactions()
println(result)
} (e: RMException){
println(e.message)
println(e.errorCode)
println(e.errorMessage)
} (e: Throwable){
e.printStackTrace()
}
}
Custom Request (Sample)
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.
Get
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())
Post
@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)
result = Json.decodeFromString<RMResponse>(response.bodyAsText())
} (e: RMException){
println(e.message)
println(e.errorCode)
println(e.errorMessage)
} (e: Throwable){
e.printStackTrace()
}
Version 2.1.1 onward
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
)
📄 License
MIT