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

tech.carpentum.sdk.payment.internal.generated.api.PaymentsApi.kt Maven / Gradle / Ivy

The newest version!
/**
 *
 * Please note:
 * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * Do not edit this file manually.
 *
 */

@file:Suppress(
    "ArrayInDataClass",
    "EnumEntryName",
    "RemoveRedundantQualifierName",
    "UnusedImport"
)

package tech.carpentum.sdk.payment.internal.generated.api

import java.io.IOException
import okhttp3.OkHttpClient
import okhttp3.HttpUrl

import tech.carpentum.sdk.payment.model.BasicError
import tech.carpentum.sdk.payment.model.CurrencyList
import tech.carpentum.sdk.payment.model.GetPaymentOptionsError
import tech.carpentum.sdk.payment.model.PaymentMethodsList
import tech.carpentum.sdk.payment.model.PaymentOperatorList
import tech.carpentum.sdk.payment.model.PaymentOptionsList
import tech.carpentum.sdk.payment.model.SegmentList

import com.squareup.moshi.Json

import tech.carpentum.sdk.payment.internal.generated.infrastructure.ApiClient
import tech.carpentum.sdk.payment.internal.generated.infrastructure.ApiResponse
import tech.carpentum.sdk.payment.internal.generated.infrastructure.ClientException
import tech.carpentum.sdk.payment.internal.generated.infrastructure.ClientError
import tech.carpentum.sdk.payment.internal.generated.infrastructure.ServerException
import tech.carpentum.sdk.payment.internal.generated.infrastructure.ServerError
import tech.carpentum.sdk.payment.internal.generated.infrastructure.MultiValueMap
import tech.carpentum.sdk.payment.internal.generated.infrastructure.PartConfig
import tech.carpentum.sdk.payment.internal.generated.infrastructure.RequestConfig
import tech.carpentum.sdk.payment.internal.generated.infrastructure.RequestMethod
import tech.carpentum.sdk.payment.internal.generated.infrastructure.ResponseType
import tech.carpentum.sdk.payment.internal.generated.infrastructure.Success
import tech.carpentum.sdk.payment.internal.generated.infrastructure.toMultiValue

internal open class PaymentsApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClient = ApiClient.defaultClient) : ApiClient(basePath, client) {
    companion object {
        @JvmStatic
        val defaultBasePath: String by lazy {
            System.getProperties().getProperty(ApiClient.baseUrlKey, "https://api.sandbox.carpentum.tech")
        }
    }

    /**
     * Currencies.
     * Return list of currencies available for the current merchant (according to content of the [JWT token](general.html#security)).  New currency codes may be added without further notice and are considered as non breaking change and do not affect API version.  Fiat currency codes are based on 3-letter ISO 4217. Crypto currency codes are based on commonly used codes.  For available currencies please refer to section \"available currencies\" on merchant detail page in Merchant Back-office. To add new available currency please contact our support.
     * @param xAPIVersion Required API version. See [Versioning](general.html#versioning)
     * @return CurrencyList
     * @throws IllegalStateException If the request is not correctly configured
     * @throws IOException Rethrows the OkHttp execute method exception
     * @throws UnsupportedOperationException If the API returns an informational or redirection response
     * @throws ClientException If the API returns a client error response
     * @throws ServerException If the API returns a server error response
     */
    @Suppress("UNCHECKED_CAST")
    @Throws(IllegalStateException::class, IOException::class, UnsupportedOperationException::class, ClientException::class, ServerException::class)
    fun getCurrencies(xAPIVersion: kotlin.Int) : CurrencyList {
        val localVarResponse = getCurrenciesWithHttpInfo(xAPIVersion = xAPIVersion)

        return when (localVarResponse.responseType) {
            ResponseType.Success -> (localVarResponse as Success<*>).data as CurrencyList
            ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
            ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
            ResponseType.ClientError -> {
                val localVarError = localVarResponse as ClientError<*>
                throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
            }
            ResponseType.ServerError -> {
                val localVarError = localVarResponse as ServerError<*>
                throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()} ${localVarError.body}", localVarError.statusCode, localVarResponse)
            }
        }
    }

    /**
     * Currencies.
     * Return list of currencies available for the current merchant (according to content of the [JWT token](general.html#security)).  New currency codes may be added without further notice and are considered as non breaking change and do not affect API version.  Fiat currency codes are based on 3-letter ISO 4217. Crypto currency codes are based on commonly used codes.  For available currencies please refer to section \"available currencies\" on merchant detail page in Merchant Back-office. To add new available currency please contact our support.
     * @param xAPIVersion Required API version. See [Versioning](general.html#versioning)
     * @return ApiResponse
     * @throws IllegalStateException If the request is not correctly configured
     * @throws IOException Rethrows the OkHttp execute method exception
     */
    @Suppress("UNCHECKED_CAST")
    @Throws(IllegalStateException::class, IOException::class)
    fun getCurrenciesWithHttpInfo(xAPIVersion: kotlin.Int) : ApiResponse {
        val localVariableConfig = getCurrenciesRequestConfig(xAPIVersion = xAPIVersion)

        return request(
            localVariableConfig
        )
    }

    /**
     * To obtain the request config of the operation getCurrencies
     *
     * @param xAPIVersion Required API version. See [Versioning](general.html#versioning)
     * @return RequestConfig
     */
    fun getCurrenciesRequestConfig(xAPIVersion: kotlin.Int) : RequestConfig {
        val localVariableBody = null
        val localVariableQuery: MultiValueMap = mutableMapOf()
        val localVariableHeaders: MutableMap = mutableMapOf()
        xAPIVersion.apply { localVariableHeaders["X-API-Version"] = this.toString() }
        localVariableHeaders["Accept"] = "application/json"

        return RequestConfig(
            method = RequestMethod.GET,
            path = "/currencies",
            query = localVariableQuery,
            headers = localVariableHeaders,
            requiresAuthentication = true,
            body = localVariableBody
        )
    }

    /**
     * Payment methods.
     * Return list of [payment methods](terminology.html#term-Payment-method) available in the system.  New payment method codes may be added without further notice and are considered as non breaking change and do not affect API version.
     * @param xAPIVersion Required API version. See [Versioning](general.html#versioning)
     * @return PaymentMethodsList
     * @throws IllegalStateException If the request is not correctly configured
     * @throws IOException Rethrows the OkHttp execute method exception
     * @throws UnsupportedOperationException If the API returns an informational or redirection response
     * @throws ClientException If the API returns a client error response
     * @throws ServerException If the API returns a server error response
     */
    @Suppress("UNCHECKED_CAST")
    @Throws(IllegalStateException::class, IOException::class, UnsupportedOperationException::class, ClientException::class, ServerException::class)
    fun getPaymentMethods(xAPIVersion: kotlin.Int) : PaymentMethodsList {
        val localVarResponse = getPaymentMethodsWithHttpInfo(xAPIVersion = xAPIVersion)

        return when (localVarResponse.responseType) {
            ResponseType.Success -> (localVarResponse as Success<*>).data as PaymentMethodsList
            ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
            ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
            ResponseType.ClientError -> {
                val localVarError = localVarResponse as ClientError<*>
                throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
            }
            ResponseType.ServerError -> {
                val localVarError = localVarResponse as ServerError<*>
                throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()} ${localVarError.body}", localVarError.statusCode, localVarResponse)
            }
        }
    }

    /**
     * Payment methods.
     * Return list of [payment methods](terminology.html#term-Payment-method) available in the system.  New payment method codes may be added without further notice and are considered as non breaking change and do not affect API version.
     * @param xAPIVersion Required API version. See [Versioning](general.html#versioning)
     * @return ApiResponse
     * @throws IllegalStateException If the request is not correctly configured
     * @throws IOException Rethrows the OkHttp execute method exception
     */
    @Suppress("UNCHECKED_CAST")
    @Throws(IllegalStateException::class, IOException::class)
    fun getPaymentMethodsWithHttpInfo(xAPIVersion: kotlin.Int) : ApiResponse {
        val localVariableConfig = getPaymentMethodsRequestConfig(xAPIVersion = xAPIVersion)

        return request(
            localVariableConfig
        )
    }

    /**
     * To obtain the request config of the operation getPaymentMethods
     *
     * @param xAPIVersion Required API version. See [Versioning](general.html#versioning)
     * @return RequestConfig
     */
    fun getPaymentMethodsRequestConfig(xAPIVersion: kotlin.Int) : RequestConfig {
        val localVariableBody = null
        val localVariableQuery: MultiValueMap = mutableMapOf()
        val localVariableHeaders: MutableMap = mutableMapOf()
        xAPIVersion.apply { localVariableHeaders["X-API-Version"] = this.toString() }
        localVariableHeaders["Accept"] = "application/json"

        return RequestConfig(
            method = RequestMethod.GET,
            path = "/payment-methods",
            query = localVariableQuery,
            headers = localVariableHeaders,
            requiresAuthentication = true,
            body = localVariableBody
        )
    }

    /**
     * Payment operators.
     * Return list of [payment operators](terminology.html#term-Payment-operator) available in the system.  New payment operators codes may be added without further notice and are considered as non breaking change and do not affect API version.
     * @param xAPIVersion Required API version. See [Versioning](general.html#versioning)
     * @return PaymentOperatorList
     * @throws IllegalStateException If the request is not correctly configured
     * @throws IOException Rethrows the OkHttp execute method exception
     * @throws UnsupportedOperationException If the API returns an informational or redirection response
     * @throws ClientException If the API returns a client error response
     * @throws ServerException If the API returns a server error response
     */
    @Suppress("UNCHECKED_CAST")
    @Throws(IllegalStateException::class, IOException::class, UnsupportedOperationException::class, ClientException::class, ServerException::class)
    fun getPaymentOperators(xAPIVersion: kotlin.Int) : PaymentOperatorList {
        val localVarResponse = getPaymentOperatorsWithHttpInfo(xAPIVersion = xAPIVersion)

        return when (localVarResponse.responseType) {
            ResponseType.Success -> (localVarResponse as Success<*>).data as PaymentOperatorList
            ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
            ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
            ResponseType.ClientError -> {
                val localVarError = localVarResponse as ClientError<*>
                throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
            }
            ResponseType.ServerError -> {
                val localVarError = localVarResponse as ServerError<*>
                throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()} ${localVarError.body}", localVarError.statusCode, localVarResponse)
            }
        }
    }

    /**
     * Payment operators.
     * Return list of [payment operators](terminology.html#term-Payment-operator) available in the system.  New payment operators codes may be added without further notice and are considered as non breaking change and do not affect API version.
     * @param xAPIVersion Required API version. See [Versioning](general.html#versioning)
     * @return ApiResponse
     * @throws IllegalStateException If the request is not correctly configured
     * @throws IOException Rethrows the OkHttp execute method exception
     */
    @Suppress("UNCHECKED_CAST")
    @Throws(IllegalStateException::class, IOException::class)
    fun getPaymentOperatorsWithHttpInfo(xAPIVersion: kotlin.Int) : ApiResponse {
        val localVariableConfig = getPaymentOperatorsRequestConfig(xAPIVersion = xAPIVersion)

        return request(
            localVariableConfig
        )
    }

    /**
     * To obtain the request config of the operation getPaymentOperators
     *
     * @param xAPIVersion Required API version. See [Versioning](general.html#versioning)
     * @return RequestConfig
     */
    fun getPaymentOperatorsRequestConfig(xAPIVersion: kotlin.Int) : RequestConfig {
        val localVariableBody = null
        val localVariableQuery: MultiValueMap = mutableMapOf()
        val localVariableHeaders: MutableMap = mutableMapOf()
        xAPIVersion.apply { localVariableHeaders["X-API-Version"] = this.toString() }
        localVariableHeaders["Accept"] = "application/json"

        return RequestConfig(
            method = RequestMethod.GET,
            path = "/payment-operators",
            query = localVariableQuery,
            headers = localVariableHeaders,
            requiresAuthentication = true,
            body = localVariableBody
        )
    }

    /**
     * enum for parameter paymentTypeCode
     */
     enum class PaymentTypeCodeGetPaymentOptions(val value: kotlin.String) {
         @Json(name = "PAYIN") PAYIN("PAYIN"),
         @Json(name = "PAYOUT") PAYOUT("PAYOUT")
     }

    /**
     * Payment options.
     *  Return [payment options](terminology.html#term-Payment-option) (combination of payment methods and corresponding payment operators) (possibly) available for the merchant specified in the authorization token, optionally filtered by the query parameters.  The API documentation describes currently supported list of `paymentMethodCode`. Be aware that to return more items than described is classified as a backward-compatible change. The list of supported payment methods will grow in the future. New payment method is returned only when you have the method configured in your account.
     * @param xAPIVersion Required API version. See [Versioning](general.html#versioning)
     * @param paymentTypeCode  (optional)
     * @param paymentMethodCodes  (optional)
     * @param currencyCodes  (optional)
     * @param segmentCodes  (optional)
     * @param paymentOperatorCodes  (optional)
     * @return PaymentOptionsList
     * @throws IllegalStateException If the request is not correctly configured
     * @throws IOException Rethrows the OkHttp execute method exception
     * @throws UnsupportedOperationException If the API returns an informational or redirection response
     * @throws ClientException If the API returns a client error response
     * @throws ServerException If the API returns a server error response
     */
    @Suppress("UNCHECKED_CAST")
    @Throws(IllegalStateException::class, IOException::class, UnsupportedOperationException::class, ClientException::class, ServerException::class)
    fun getPaymentOptions(xAPIVersion: kotlin.Int, paymentTypeCode: PaymentTypeCodeGetPaymentOptions? = null, paymentMethodCodes: kotlin.String? = null, currencyCodes: kotlin.String? = null, segmentCodes: kotlin.String? = null, paymentOperatorCodes: kotlin.String? = null) : PaymentOptionsList {
        val localVarResponse = getPaymentOptionsWithHttpInfo(xAPIVersion = xAPIVersion, paymentTypeCode = paymentTypeCode, paymentMethodCodes = paymentMethodCodes, currencyCodes = currencyCodes, segmentCodes = segmentCodes, paymentOperatorCodes = paymentOperatorCodes)

        return when (localVarResponse.responseType) {
            ResponseType.Success -> (localVarResponse as Success<*>).data as PaymentOptionsList
            ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
            ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
            ResponseType.ClientError -> {
                val localVarError = localVarResponse as ClientError<*>
                throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
            }
            ResponseType.ServerError -> {
                val localVarError = localVarResponse as ServerError<*>
                throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()} ${localVarError.body}", localVarError.statusCode, localVarResponse)
            }
        }
    }

    /**
     * Payment options.
     *  Return [payment options](terminology.html#term-Payment-option) (combination of payment methods and corresponding payment operators) (possibly) available for the merchant specified in the authorization token, optionally filtered by the query parameters.  The API documentation describes currently supported list of `paymentMethodCode`. Be aware that to return more items than described is classified as a backward-compatible change. The list of supported payment methods will grow in the future. New payment method is returned only when you have the method configured in your account.
     * @param xAPIVersion Required API version. See [Versioning](general.html#versioning)
     * @param paymentTypeCode  (optional)
     * @param paymentMethodCodes  (optional)
     * @param currencyCodes  (optional)
     * @param segmentCodes  (optional)
     * @param paymentOperatorCodes  (optional)
     * @return ApiResponse
     * @throws IllegalStateException If the request is not correctly configured
     * @throws IOException Rethrows the OkHttp execute method exception
     */
    @Suppress("UNCHECKED_CAST")
    @Throws(IllegalStateException::class, IOException::class)
    fun getPaymentOptionsWithHttpInfo(xAPIVersion: kotlin.Int, paymentTypeCode: PaymentTypeCodeGetPaymentOptions?, paymentMethodCodes: kotlin.String?, currencyCodes: kotlin.String?, segmentCodes: kotlin.String?, paymentOperatorCodes: kotlin.String?) : ApiResponse {
        val localVariableConfig = getPaymentOptionsRequestConfig(xAPIVersion = xAPIVersion, paymentTypeCode = paymentTypeCode, paymentMethodCodes = paymentMethodCodes, currencyCodes = currencyCodes, segmentCodes = segmentCodes, paymentOperatorCodes = paymentOperatorCodes)

        return request(
            localVariableConfig
        )
    }

    /**
     * To obtain the request config of the operation getPaymentOptions
     *
     * @param xAPIVersion Required API version. See [Versioning](general.html#versioning)
     * @param paymentTypeCode  (optional)
     * @param paymentMethodCodes  (optional)
     * @param currencyCodes  (optional)
     * @param segmentCodes  (optional)
     * @param paymentOperatorCodes  (optional)
     * @return RequestConfig
     */
    fun getPaymentOptionsRequestConfig(xAPIVersion: kotlin.Int, paymentTypeCode: PaymentTypeCodeGetPaymentOptions?, paymentMethodCodes: kotlin.String?, currencyCodes: kotlin.String?, segmentCodes: kotlin.String?, paymentOperatorCodes: kotlin.String?) : RequestConfig {
        val localVariableBody = null
        val localVariableQuery: MultiValueMap = mutableMapOf>()
            .apply {
                if (paymentTypeCode != null) {
                    put("paymentTypeCode", listOf(paymentTypeCode.value))
                }
                if (paymentMethodCodes != null) {
                    put("paymentMethodCodes", listOf(paymentMethodCodes.toString()))
                }
                if (currencyCodes != null) {
                    put("currencyCodes", listOf(currencyCodes.toString()))
                }
                if (segmentCodes != null) {
                    put("segmentCodes", listOf(segmentCodes.toString()))
                }
                if (paymentOperatorCodes != null) {
                    put("paymentOperatorCodes", listOf(paymentOperatorCodes.toString()))
                }
            }
        val localVariableHeaders: MutableMap = mutableMapOf()
        xAPIVersion.apply { localVariableHeaders["X-API-Version"] = this.toString() }
        localVariableHeaders["Accept"] = "application/json"

        return RequestConfig(
            method = RequestMethod.GET,
            path = "/payment-options",
            query = localVariableQuery,
            headers = localVariableHeaders,
            requiresAuthentication = true,
            body = localVariableBody
        )
    }

    /**
     * Segments.
     * Return list of customer segments available in the system.
     * @param xAPIVersion Required API version. See [Versioning](general.html#versioning)
     * @return SegmentList
     * @throws IllegalStateException If the request is not correctly configured
     * @throws IOException Rethrows the OkHttp execute method exception
     * @throws UnsupportedOperationException If the API returns an informational or redirection response
     * @throws ClientException If the API returns a client error response
     * @throws ServerException If the API returns a server error response
     */
    @Suppress("UNCHECKED_CAST")
    @Throws(IllegalStateException::class, IOException::class, UnsupportedOperationException::class, ClientException::class, ServerException::class)
    fun getSegments(xAPIVersion: kotlin.Int) : SegmentList {
        val localVarResponse = getSegmentsWithHttpInfo(xAPIVersion = xAPIVersion)

        return when (localVarResponse.responseType) {
            ResponseType.Success -> (localVarResponse as Success<*>).data as SegmentList
            ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
            ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
            ResponseType.ClientError -> {
                val localVarError = localVarResponse as ClientError<*>
                throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
            }
            ResponseType.ServerError -> {
                val localVarError = localVarResponse as ServerError<*>
                throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()} ${localVarError.body}", localVarError.statusCode, localVarResponse)
            }
        }
    }

    /**
     * Segments.
     * Return list of customer segments available in the system.
     * @param xAPIVersion Required API version. See [Versioning](general.html#versioning)
     * @return ApiResponse
     * @throws IllegalStateException If the request is not correctly configured
     * @throws IOException Rethrows the OkHttp execute method exception
     */
    @Suppress("UNCHECKED_CAST")
    @Throws(IllegalStateException::class, IOException::class)
    fun getSegmentsWithHttpInfo(xAPIVersion: kotlin.Int) : ApiResponse {
        val localVariableConfig = getSegmentsRequestConfig(xAPIVersion = xAPIVersion)

        return request(
            localVariableConfig
        )
    }

    /**
     * To obtain the request config of the operation getSegments
     *
     * @param xAPIVersion Required API version. See [Versioning](general.html#versioning)
     * @return RequestConfig
     */
    fun getSegmentsRequestConfig(xAPIVersion: kotlin.Int) : RequestConfig {
        val localVariableBody = null
        val localVariableQuery: MultiValueMap = mutableMapOf()
        val localVariableHeaders: MutableMap = mutableMapOf()
        xAPIVersion.apply { localVariableHeaders["X-API-Version"] = this.toString() }
        localVariableHeaders["Accept"] = "application/json"

        return RequestConfig(
            method = RequestMethod.GET,
            path = "/segments",
            query = localVariableQuery,
            headers = localVariableHeaders,
            requiresAuthentication = true,
            body = localVariableBody
        )
    }

    /**
     * Topup options.
     *  Return [topup options](terminology.html#term-Payment-option) (combination of payment methods and corresponding payment operators) (possibly) available for topups for the tenant specified in the authorization token, optionally filtered by the query parameters.  The API documentation describes currently supported list of `paymentMethodCode`. Be aware that to return more items than described is classified as a backward-compatible change. The list of supported payment methods will grow in the future. New payment method is returned only when you have the method configured in your account.
     * @param xAPIVersion Required API version. See [Versioning](general.html#versioning)
     * @param paymentMethodCodes  (optional)
     * @param currencyCodes  (optional)
     * @param paymentOperatorCodes  (optional)
     * @return PaymentOptionsList
     * @throws IllegalStateException If the request is not correctly configured
     * @throws IOException Rethrows the OkHttp execute method exception
     * @throws UnsupportedOperationException If the API returns an informational or redirection response
     * @throws ClientException If the API returns a client error response
     * @throws ServerException If the API returns a server error response
     */
    @Suppress("UNCHECKED_CAST")
    @Throws(IllegalStateException::class, IOException::class, UnsupportedOperationException::class, ClientException::class, ServerException::class)
    fun getTopupOptions(xAPIVersion: kotlin.Int, paymentMethodCodes: kotlin.String? = null, currencyCodes: kotlin.String? = null, paymentOperatorCodes: kotlin.String? = null) : PaymentOptionsList {
        val localVarResponse = getTopupOptionsWithHttpInfo(xAPIVersion = xAPIVersion, paymentMethodCodes = paymentMethodCodes, currencyCodes = currencyCodes, paymentOperatorCodes = paymentOperatorCodes)

        return when (localVarResponse.responseType) {
            ResponseType.Success -> (localVarResponse as Success<*>).data as PaymentOptionsList
            ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
            ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
            ResponseType.ClientError -> {
                val localVarError = localVarResponse as ClientError<*>
                throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
            }
            ResponseType.ServerError -> {
                val localVarError = localVarResponse as ServerError<*>
                throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()} ${localVarError.body}", localVarError.statusCode, localVarResponse)
            }
        }
    }

    /**
     * Topup options.
     *  Return [topup options](terminology.html#term-Payment-option) (combination of payment methods and corresponding payment operators) (possibly) available for topups for the tenant specified in the authorization token, optionally filtered by the query parameters.  The API documentation describes currently supported list of `paymentMethodCode`. Be aware that to return more items than described is classified as a backward-compatible change. The list of supported payment methods will grow in the future. New payment method is returned only when you have the method configured in your account.
     * @param xAPIVersion Required API version. See [Versioning](general.html#versioning)
     * @param paymentMethodCodes  (optional)
     * @param currencyCodes  (optional)
     * @param paymentOperatorCodes  (optional)
     * @return ApiResponse
     * @throws IllegalStateException If the request is not correctly configured
     * @throws IOException Rethrows the OkHttp execute method exception
     */
    @Suppress("UNCHECKED_CAST")
    @Throws(IllegalStateException::class, IOException::class)
    fun getTopupOptionsWithHttpInfo(xAPIVersion: kotlin.Int, paymentMethodCodes: kotlin.String?, currencyCodes: kotlin.String?, paymentOperatorCodes: kotlin.String?) : ApiResponse {
        val localVariableConfig = getTopupOptionsRequestConfig(xAPIVersion = xAPIVersion, paymentMethodCodes = paymentMethodCodes, currencyCodes = currencyCodes, paymentOperatorCodes = paymentOperatorCodes)

        return request(
            localVariableConfig
        )
    }

    /**
     * To obtain the request config of the operation getTopupOptions
     *
     * @param xAPIVersion Required API version. See [Versioning](general.html#versioning)
     * @param paymentMethodCodes  (optional)
     * @param currencyCodes  (optional)
     * @param paymentOperatorCodes  (optional)
     * @return RequestConfig
     */
    fun getTopupOptionsRequestConfig(xAPIVersion: kotlin.Int, paymentMethodCodes: kotlin.String?, currencyCodes: kotlin.String?, paymentOperatorCodes: kotlin.String?) : RequestConfig {
        val localVariableBody = null
        val localVariableQuery: MultiValueMap = mutableMapOf>()
            .apply {
                if (paymentMethodCodes != null) {
                    put("paymentMethodCodes", listOf(paymentMethodCodes.toString()))
                }
                if (currencyCodes != null) {
                    put("currencyCodes", listOf(currencyCodes.toString()))
                }
                if (paymentOperatorCodes != null) {
                    put("paymentOperatorCodes", listOf(paymentOperatorCodes.toString()))
                }
            }
        val localVariableHeaders: MutableMap = mutableMapOf()
        xAPIVersion.apply { localVariableHeaders["X-API-Version"] = this.toString() }
        localVariableHeaders["Accept"] = "application/json"

        return RequestConfig(
            method = RequestMethod.GET,
            path = "/topup-options",
            query = localVariableQuery,
            headers = localVariableHeaders,
            requiresAuthentication = true,
            body = localVariableBody
        )
    }


    private fun encodeURIComponent(uriComponent: kotlin.String): kotlin.String =
        HttpUrl.Builder().scheme("http").host("localhost").addPathSegment(uriComponent).build().encodedPathSegments[0]
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy