commonMain.io.revenuemonster.sdk.module.VoucherModule.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rm-kotlin-sdk-jvm Show documentation
Show all versions of rm-kotlin-sdk-jvm Show documentation
Revenue Monster Kotlin Multiplatform SDK
package io.revenuemonster.sdk.module
import io.ktor.http.*
import io.revenuemonster.sdk.RevenueMonsterSDK
import io.revenuemonster.sdk.model.Item
import io.revenuemonster.sdk.model.Items
import io.revenuemonster.sdk.model.response.IssueVoucherResponse
import io.revenuemonster.sdk.model.response.Voucher
import io.revenuemonster.sdk.model.response.Vouchers
import kotlinx.serialization.json.JsonNull
class VoucherModule(private val sdk: RevenueMonsterSDK) {
suspend fun getVoucherBatches(): Items {
return sdk.call>(
url = "/v3/voucher-batches"
)
}
suspend fun getVoucherByCode(code: String): Item {
return sdk.call>(
url = "/v3/voucher/$code"
)
}
suspend fun getVoucherBatchByKey(key: String): Items {
return sdk.call>(
url = "/v3/voucher-batch/$key/vouchers"
)
}
suspend fun issueVoucher(key: String): Item {
return sdk.call>(
url = "/v3/voucher-batch/$key/issue",
method = HttpMethod.Post,
)
}
suspend fun voidVoucher(code: String): Item {
return sdk.call>(
url = "/v3/voucher/$code/void",
method = HttpMethod.Post
)
}
}