com.lithic.api.client.LithicClientAsyncImpl.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lithic-kotlin-core Show documentation
Show all versions of lithic-kotlin-core Show documentation
The Lithic Developer API is designed to provide a predictable programmatic
interface for accessing your Lithic account through an API and transaction
webhooks. Note that your API key is a secret and should be treated as such.
Don't share it with anyone, including us. We will never ask you for it.
// File generated from our OpenAPI spec by Stainless.
package com.lithic.api.client
import com.lithic.api.core.ClientOptions
import com.lithic.api.core.RequestOptions
import com.lithic.api.core.http.HttpMethod
import com.lithic.api.core.http.HttpRequest
import com.lithic.api.core.http.HttpResponse.Handler
import com.lithic.api.errors.LithicError
import com.lithic.api.models.*
import com.lithic.api.services.async.*
import com.lithic.api.services.errorHandler
import com.lithic.api.services.jsonHandler
import com.lithic.api.services.withErrorHandler
class LithicClientAsyncImpl
constructor(
private val clientOptions: ClientOptions,
) : LithicClientAsync {
private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper)
private val sync: LithicClient by lazy { LithicClientImpl(clientOptions) }
private val accounts: AccountServiceAsync by lazy { AccountServiceAsyncImpl(clientOptions) }
private val accountHolders: AccountHolderServiceAsync by lazy {
AccountHolderServiceAsyncImpl(clientOptions)
}
private val authRules: AuthRuleServiceAsync by lazy { AuthRuleServiceAsyncImpl(clientOptions) }
private val authStreamEnrollment: AuthStreamEnrollmentServiceAsync by lazy {
AuthStreamEnrollmentServiceAsyncImpl(clientOptions)
}
private val tokenizationDecisioning: TokenizationDecisioningServiceAsync by lazy {
TokenizationDecisioningServiceAsyncImpl(clientOptions)
}
private val tokenizations: TokenizationServiceAsync by lazy {
TokenizationServiceAsyncImpl(clientOptions)
}
private val cards: CardServiceAsync by lazy { CardServiceAsyncImpl(clientOptions) }
private val balances: BalanceServiceAsync by lazy { BalanceServiceAsyncImpl(clientOptions) }
private val aggregateBalances: AggregateBalanceServiceAsync by lazy {
AggregateBalanceServiceAsyncImpl(clientOptions)
}
private val disputes: DisputeServiceAsync by lazy { DisputeServiceAsyncImpl(clientOptions) }
private val events: EventServiceAsync by lazy { EventServiceAsyncImpl(clientOptions) }
private val transfers: TransferServiceAsync by lazy { TransferServiceAsyncImpl(clientOptions) }
private val financialAccounts: FinancialAccountServiceAsync by lazy {
FinancialAccountServiceAsyncImpl(clientOptions)
}
private val transactions: TransactionServiceAsync by lazy {
TransactionServiceAsyncImpl(clientOptions)
}
private val responderEndpoints: ResponderEndpointServiceAsync by lazy {
ResponderEndpointServiceAsyncImpl(clientOptions)
}
private val webhooks: WebhookServiceAsync by lazy { WebhookServiceAsyncImpl(clientOptions) }
private val externalBankAccounts: ExternalBankAccountServiceAsync by lazy {
ExternalBankAccountServiceAsyncImpl(clientOptions)
}
private val payments: PaymentServiceAsync by lazy { PaymentServiceAsyncImpl(clientOptions) }
private val threeDS: ThreeDSServiceAsync by lazy { ThreeDSServiceAsyncImpl(clientOptions) }
private val reports: ReportServiceAsync by lazy { ReportServiceAsyncImpl(clientOptions) }
private val cardPrograms: CardProgramServiceAsync by lazy {
CardProgramServiceAsyncImpl(clientOptions)
}
private val digitalCardArt: DigitalCardArtServiceAsync by lazy {
DigitalCardArtServiceAsyncImpl(clientOptions)
}
private val bookTransfers: BookTransferServiceAsync by lazy {
BookTransferServiceAsyncImpl(clientOptions)
}
private val creditProducts: CreditProductServiceAsync by lazy {
CreditProductServiceAsyncImpl(clientOptions)
}
override fun sync(): LithicClient = sync
override fun accounts(): AccountServiceAsync = accounts
override fun accountHolders(): AccountHolderServiceAsync = accountHolders
override fun authRules(): AuthRuleServiceAsync = authRules
override fun authStreamEnrollment(): AuthStreamEnrollmentServiceAsync = authStreamEnrollment
override fun tokenizationDecisioning(): TokenizationDecisioningServiceAsync =
tokenizationDecisioning
override fun tokenizations(): TokenizationServiceAsync = tokenizations
override fun cards(): CardServiceAsync = cards
override fun balances(): BalanceServiceAsync = balances
override fun aggregateBalances(): AggregateBalanceServiceAsync = aggregateBalances
override fun disputes(): DisputeServiceAsync = disputes
override fun events(): EventServiceAsync = events
override fun transfers(): TransferServiceAsync = transfers
override fun financialAccounts(): FinancialAccountServiceAsync = financialAccounts
override fun transactions(): TransactionServiceAsync = transactions
override fun responderEndpoints(): ResponderEndpointServiceAsync = responderEndpoints
override fun webhooks(): WebhookServiceAsync = webhooks
override fun externalBankAccounts(): ExternalBankAccountServiceAsync = externalBankAccounts
override fun payments(): PaymentServiceAsync = payments
override fun threeDS(): ThreeDSServiceAsync = threeDS
override fun reports(): ReportServiceAsync = reports
override fun cardPrograms(): CardProgramServiceAsync = cardPrograms
override fun digitalCardArt(): DigitalCardArtServiceAsync = digitalCardArt
override fun bookTransfers(): BookTransferServiceAsync = bookTransfers
override fun creditProducts(): CreditProductServiceAsync = creditProducts
private val apiStatusHandler: Handler =
jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler)
/** Status of api */
override suspend fun apiStatus(
params: ClientApiStatusParams,
requestOptions: RequestOptions
): ApiStatus {
val request =
HttpRequest.builder()
.method(HttpMethod.GET)
.addPathSegments("status")
.putAllQueryParams(clientOptions.queryParams)
.putAllQueryParams(params.getQueryParams())
.putAllHeaders(clientOptions.headers)
.putAllHeaders(params.getHeaders())
.build()
return clientOptions.httpClient.executeAsync(request, requestOptions).let { response ->
response
.use { apiStatusHandler.handle(it) }
.apply {
if (requestOptions.responseValidation ?: clientOptions.responseValidation) {
validate()
}
}
}
}
}