com.lithic.api.models.AccountHolderCreateParams.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.
The newest version!
// File generated from our OpenAPI spec by Stainless.
package com.lithic.api.models
import com.fasterxml.jackson.core.JsonGenerator
import com.fasterxml.jackson.core.ObjectCodec
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.SerializerProvider
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import com.fasterxml.jackson.databind.annotation.JsonSerialize
import com.fasterxml.jackson.module.kotlin.jacksonTypeRef
import com.lithic.api.core.BaseDeserializer
import com.lithic.api.core.BaseSerializer
import com.lithic.api.core.JsonValue
import com.lithic.api.core.NoAutoDetect
import com.lithic.api.core.getOrThrow
import com.lithic.api.core.http.Headers
import com.lithic.api.core.http.QueryParams
import com.lithic.api.errors.LithicInvalidDataException
import com.lithic.api.models.*
import java.util.Objects
class AccountHolderCreateParams
constructor(
private val kyb: Kyb?,
private val kyc: Kyc?,
private val kycExempt: KycExempt?,
private val additionalHeaders: Headers,
private val additionalQueryParams: QueryParams,
) {
fun kyb(): Kyb? = kyb
fun kyc(): Kyc? = kyc
fun kycExempt(): KycExempt? = kycExempt
internal fun getBody(): AccountHolderCreateBody {
return AccountHolderCreateBody(
kyb,
kyc,
kycExempt,
)
}
internal fun getHeaders(): Headers = additionalHeaders
internal fun getQueryParams(): QueryParams = additionalQueryParams
@JsonDeserialize(using = AccountHolderCreateBody.Deserializer::class)
@JsonSerialize(using = AccountHolderCreateBody.Serializer::class)
class AccountHolderCreateBody
internal constructor(
private val kyb: Kyb? = null,
private val kyc: Kyc? = null,
private val kycExempt: KycExempt? = null,
private val _json: JsonValue? = null,
) {
fun kyb(): Kyb? = kyb
fun kyc(): Kyc? = kyc
fun kycExempt(): KycExempt? = kycExempt
fun isKyb(): Boolean = kyb != null
fun isKyc(): Boolean = kyc != null
fun isKycExempt(): Boolean = kycExempt != null
fun asKyb(): Kyb = kyb.getOrThrow("kyb")
fun asKyc(): Kyc = kyc.getOrThrow("kyc")
fun asKycExempt(): KycExempt = kycExempt.getOrThrow("kycExempt")
fun _json(): JsonValue? = _json
fun accept(visitor: Visitor): T {
return when {
kyb != null -> visitor.visitKyb(kyb)
kyc != null -> visitor.visitKyc(kyc)
kycExempt != null -> visitor.visitKycExempt(kycExempt)
else -> visitor.unknown(_json)
}
}
override fun equals(other: Any?): Boolean {
if (this === other) {
return true
}
return /* spotless:off */ other is AccountHolderCreateBody && this.kyb == other.kyb && this.kyc == other.kyc && this.kycExempt == other.kycExempt /* spotless:on */
}
override fun hashCode(): Int {
return /* spotless:off */ Objects.hash(kyb, kyc, kycExempt) /* spotless:on */
}
override fun toString(): String {
return when {
kyb != null -> "AccountHolderCreateBody{kyb=$kyb}"
kyc != null -> "AccountHolderCreateBody{kyc=$kyc}"
kycExempt != null -> "AccountHolderCreateBody{kycExempt=$kycExempt}"
_json != null -> "AccountHolderCreateBody{_unknown=$_json}"
else -> throw IllegalStateException("Invalid AccountHolderCreateBody")
}
}
companion object {
fun ofKyb(kyb: Kyb) = AccountHolderCreateBody(kyb = kyb)
fun ofKyc(kyc: Kyc) = AccountHolderCreateBody(kyc = kyc)
fun ofKycExempt(kycExempt: KycExempt) = AccountHolderCreateBody(kycExempt = kycExempt)
}
interface Visitor {
fun visitKyb(kyb: Kyb): T
fun visitKyc(kyc: Kyc): T
fun visitKycExempt(kycExempt: KycExempt): T
fun unknown(json: JsonValue?): T {
throw LithicInvalidDataException("Unknown AccountHolderCreateBody: $json")
}
}
class Deserializer :
BaseDeserializer(AccountHolderCreateBody::class) {
override fun ObjectCodec.deserialize(node: JsonNode): AccountHolderCreateBody {
val json = JsonValue.fromJsonNode(node)
tryDeserialize(node, jacksonTypeRef())?.let {
return AccountHolderCreateBody(kyb = it, _json = json)
}
tryDeserialize(node, jacksonTypeRef())?.let {
return AccountHolderCreateBody(kyc = it, _json = json)
}
tryDeserialize(node, jacksonTypeRef())?.let {
return AccountHolderCreateBody(kycExempt = it, _json = json)
}
return AccountHolderCreateBody(_json = json)
}
}
class Serializer : BaseSerializer(AccountHolderCreateBody::class) {
override fun serialize(
value: AccountHolderCreateBody,
generator: JsonGenerator,
provider: SerializerProvider
) {
when {
value.kyb != null -> generator.writeObject(value.kyb)
value.kyc != null -> generator.writeObject(value.kyc)
value.kycExempt != null -> generator.writeObject(value.kycExempt)
value._json != null -> generator.writeObject(value._json)
else -> throw IllegalStateException("Invalid AccountHolderCreateBody")
}
}
}
}
fun _additionalHeaders(): Headers = additionalHeaders
fun _additionalQueryParams(): QueryParams = additionalQueryParams
override fun equals(other: Any?): Boolean {
if (this === other) {
return true
}
return /* spotless:off */ other is AccountHolderCreateParams && this.kyb == other.kyb && this.kyc == other.kyc && this.kycExempt == other.kycExempt && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams /* spotless:on */
}
override fun hashCode(): Int {
return /* spotless:off */ Objects.hash(kyb, kyc, kycExempt, additionalHeaders, additionalQueryParams) /* spotless:on */
}
override fun toString() =
"AccountHolderCreateParams{kyb=$kyb, kyc=$kyc, kycExempt=$kycExempt, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}"
fun toBuilder() = Builder().from(this)
companion object {
fun builder() = Builder()
}
@NoAutoDetect
class Builder {
private var kyb: Kyb? = null
private var kyc: Kyc? = null
private var kycExempt: KycExempt? = null
private var additionalHeaders: Headers.Builder = Headers.builder()
private var additionalQueryParams: QueryParams.Builder = QueryParams.builder()
internal fun from(accountHolderCreateParams: AccountHolderCreateParams) = apply {
this.kyb = accountHolderCreateParams.kyb
this.kyc = accountHolderCreateParams.kyc
this.kycExempt = accountHolderCreateParams.kycExempt
additionalHeaders(accountHolderCreateParams.additionalHeaders)
additionalQueryParams(accountHolderCreateParams.additionalQueryParams)
}
fun forKyb(kyb: Kyb) = apply {
this.kyb = kyb
this.kyc = null
this.kycExempt = null
}
fun forKyc(kyc: Kyc) = apply {
this.kyb = null
this.kyc = kyc
this.kycExempt = null
}
fun forKycExempt(kycExempt: KycExempt) = apply {
this.kyb = null
this.kyc = null
this.kycExempt = kycExempt
}
fun additionalHeaders(additionalHeaders: Headers) = apply {
this.additionalHeaders.clear()
putAllAdditionalHeaders(additionalHeaders)
}
fun additionalHeaders(additionalHeaders: Map>) = apply {
this.additionalHeaders.clear()
putAllAdditionalHeaders(additionalHeaders)
}
fun putAdditionalHeader(name: String, value: String) = apply {
additionalHeaders.put(name, value)
}
fun putAdditionalHeaders(name: String, values: Iterable) = apply {
additionalHeaders.put(name, values)
}
fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply {
this.additionalHeaders.putAll(additionalHeaders)
}
fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply {
this.additionalHeaders.putAll(additionalHeaders)
}
fun replaceAdditionalHeaders(name: String, value: String) = apply {
additionalHeaders.replace(name, value)
}
fun replaceAdditionalHeaders(name: String, values: Iterable) = apply {
additionalHeaders.replace(name, values)
}
fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply {
this.additionalHeaders.replaceAll(additionalHeaders)
}
fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply {
this.additionalHeaders.replaceAll(additionalHeaders)
}
fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) }
fun removeAllAdditionalHeaders(names: Set) = apply {
additionalHeaders.removeAll(names)
}
fun additionalQueryParams(additionalQueryParams: QueryParams) = apply {
this.additionalQueryParams.clear()
putAllAdditionalQueryParams(additionalQueryParams)
}
fun additionalQueryParams(additionalQueryParams: Map>) = apply {
this.additionalQueryParams.clear()
putAllAdditionalQueryParams(additionalQueryParams)
}
fun putAdditionalQueryParam(key: String, value: String) = apply {
additionalQueryParams.put(key, value)
}
fun putAdditionalQueryParams(key: String, values: Iterable) = apply {
additionalQueryParams.put(key, values)
}
fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply {
this.additionalQueryParams.putAll(additionalQueryParams)
}
fun putAllAdditionalQueryParams(additionalQueryParams: Map>) =
apply {
this.additionalQueryParams.putAll(additionalQueryParams)
}
fun replaceAdditionalQueryParams(key: String, value: String) = apply {
additionalQueryParams.replace(key, value)
}
fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply {
additionalQueryParams.replace(key, values)
}
fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply {
this.additionalQueryParams.replaceAll(additionalQueryParams)
}
fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) =
apply {
this.additionalQueryParams.replaceAll(additionalQueryParams)
}
fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) }
fun removeAllAdditionalQueryParams(keys: Set) = apply {
additionalQueryParams.removeAll(keys)
}
fun build(): AccountHolderCreateParams =
AccountHolderCreateParams(
kyb,
kyc,
kycExempt,
additionalHeaders.build(),
additionalQueryParams.build(),
)
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy