All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.io.revenuemonster.sdk.module.VoucherModule.kt Maven / Gradle / Ivy

There is a newer version: 2.2.0
Show newest version
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
        )
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy