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

com.moderntreasury.api.models.LegalEntityAssociation.kt Maven / Gradle / Ivy

// File generated from our OpenAPI spec by Stainless.

package com.moderntreasury.api.models

import com.fasterxml.jackson.annotation.JsonAnyGetter
import com.fasterxml.jackson.annotation.JsonAnySetter
import com.fasterxml.jackson.annotation.JsonCreator
import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import com.moderntreasury.api.core.Enum
import com.moderntreasury.api.core.ExcludeMissing
import com.moderntreasury.api.core.JsonField
import com.moderntreasury.api.core.JsonMissing
import com.moderntreasury.api.core.JsonValue
import com.moderntreasury.api.core.NoAutoDetect
import com.moderntreasury.api.core.toImmutable
import com.moderntreasury.api.errors.ModernTreasuryInvalidDataException
import java.time.LocalDate
import java.time.OffsetDateTime
import java.util.Objects

@JsonDeserialize(builder = LegalEntityAssociation.Builder::class)
@NoAutoDetect
class LegalEntityAssociation
private constructor(
    private val id: JsonField,
    private val object_: JsonField,
    private val liveMode: JsonField,
    private val createdAt: JsonField,
    private val updatedAt: JsonField,
    private val discardedAt: JsonField,
    private val parentLegalEntityId: JsonField,
    private val relationshipTypes: JsonField>,
    private val title: JsonField,
    private val ownershipPercentage: JsonField,
    private val childLegalEntity: JsonField,
    private val additionalProperties: Map,
) {

    private var validated: Boolean = false

    fun id(): String = id.getRequired("id")

    fun object_(): String = object_.getRequired("object")

    /**
     * This field will be true if this object exists in the live environment or false if it exists
     * in the test environment.
     */
    fun liveMode(): Boolean = liveMode.getRequired("live_mode")

    fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at")

    fun updatedAt(): OffsetDateTime = updatedAt.getRequired("updated_at")

    fun discardedAt(): OffsetDateTime? = discardedAt.getNullable("discarded_at")

    /** The ID of the parent legal entity. This must be a business or joint legal entity. */
    fun parentLegalEntityId(): String = parentLegalEntityId.getRequired("parent_legal_entity_id")

    fun relationshipTypes(): List =
        relationshipTypes.getRequired("relationship_types")

    /** The job title of the child entity at the parent entity. */
    fun title(): String? = title.getNullable("title")

    /** The child entity's ownership percentage iff they are a beneficial owner. */
    fun ownershipPercentage(): Long? = ownershipPercentage.getNullable("ownership_percentage")

    /** The child legal entity. */
    fun childLegalEntity(): ChildLegalEntity = childLegalEntity.getRequired("child_legal_entity")

    @JsonProperty("id") @ExcludeMissing fun _id() = id

    @JsonProperty("object") @ExcludeMissing fun _object_() = object_

    /**
     * This field will be true if this object exists in the live environment or false if it exists
     * in the test environment.
     */
    @JsonProperty("live_mode") @ExcludeMissing fun _liveMode() = liveMode

    @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt

    @JsonProperty("updated_at") @ExcludeMissing fun _updatedAt() = updatedAt

    @JsonProperty("discarded_at") @ExcludeMissing fun _discardedAt() = discardedAt

    /** The ID of the parent legal entity. This must be a business or joint legal entity. */
    @JsonProperty("parent_legal_entity_id")
    @ExcludeMissing
    fun _parentLegalEntityId() = parentLegalEntityId

    @JsonProperty("relationship_types") @ExcludeMissing fun _relationshipTypes() = relationshipTypes

    /** The job title of the child entity at the parent entity. */
    @JsonProperty("title") @ExcludeMissing fun _title() = title

    /** The child entity's ownership percentage iff they are a beneficial owner. */
    @JsonProperty("ownership_percentage")
    @ExcludeMissing
    fun _ownershipPercentage() = ownershipPercentage

    /** The child legal entity. */
    @JsonProperty("child_legal_entity") @ExcludeMissing fun _childLegalEntity() = childLegalEntity

    @JsonAnyGetter
    @ExcludeMissing
    fun _additionalProperties(): Map = additionalProperties

    fun validate(): LegalEntityAssociation = apply {
        if (!validated) {
            id()
            object_()
            liveMode()
            createdAt()
            updatedAt()
            discardedAt()
            parentLegalEntityId()
            relationshipTypes()
            title()
            ownershipPercentage()
            childLegalEntity().validate()
            validated = true
        }
    }

    fun toBuilder() = Builder().from(this)

    companion object {

        fun builder() = Builder()
    }

    class Builder {

        private var id: JsonField = JsonMissing.of()
        private var object_: JsonField = JsonMissing.of()
        private var liveMode: JsonField = JsonMissing.of()
        private var createdAt: JsonField = JsonMissing.of()
        private var updatedAt: JsonField = JsonMissing.of()
        private var discardedAt: JsonField = JsonMissing.of()
        private var parentLegalEntityId: JsonField = JsonMissing.of()
        private var relationshipTypes: JsonField> = JsonMissing.of()
        private var title: JsonField = JsonMissing.of()
        private var ownershipPercentage: JsonField = JsonMissing.of()
        private var childLegalEntity: JsonField = JsonMissing.of()
        private var additionalProperties: MutableMap = mutableMapOf()

        internal fun from(legalEntityAssociation: LegalEntityAssociation) = apply {
            this.id = legalEntityAssociation.id
            this.object_ = legalEntityAssociation.object_
            this.liveMode = legalEntityAssociation.liveMode
            this.createdAt = legalEntityAssociation.createdAt
            this.updatedAt = legalEntityAssociation.updatedAt
            this.discardedAt = legalEntityAssociation.discardedAt
            this.parentLegalEntityId = legalEntityAssociation.parentLegalEntityId
            this.relationshipTypes = legalEntityAssociation.relationshipTypes
            this.title = legalEntityAssociation.title
            this.ownershipPercentage = legalEntityAssociation.ownershipPercentage
            this.childLegalEntity = legalEntityAssociation.childLegalEntity
            additionalProperties(legalEntityAssociation.additionalProperties)
        }

        fun id(id: String) = id(JsonField.of(id))

        @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id }

        fun object_(object_: String) = object_(JsonField.of(object_))

        @JsonProperty("object")
        @ExcludeMissing
        fun object_(object_: JsonField) = apply { this.object_ = object_ }

        /**
         * This field will be true if this object exists in the live environment or false if it
         * exists in the test environment.
         */
        fun liveMode(liveMode: Boolean) = liveMode(JsonField.of(liveMode))

        /**
         * This field will be true if this object exists in the live environment or false if it
         * exists in the test environment.
         */
        @JsonProperty("live_mode")
        @ExcludeMissing
        fun liveMode(liveMode: JsonField) = apply { this.liveMode = liveMode }

        fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt))

        @JsonProperty("created_at")
        @ExcludeMissing
        fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt }

        fun updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt))

        @JsonProperty("updated_at")
        @ExcludeMissing
        fun updatedAt(updatedAt: JsonField) = apply { this.updatedAt = updatedAt }

        fun discardedAt(discardedAt: OffsetDateTime) = discardedAt(JsonField.of(discardedAt))

        @JsonProperty("discarded_at")
        @ExcludeMissing
        fun discardedAt(discardedAt: JsonField) = apply {
            this.discardedAt = discardedAt
        }

        /** The ID of the parent legal entity. This must be a business or joint legal entity. */
        fun parentLegalEntityId(parentLegalEntityId: String) =
            parentLegalEntityId(JsonField.of(parentLegalEntityId))

        /** The ID of the parent legal entity. This must be a business or joint legal entity. */
        @JsonProperty("parent_legal_entity_id")
        @ExcludeMissing
        fun parentLegalEntityId(parentLegalEntityId: JsonField) = apply {
            this.parentLegalEntityId = parentLegalEntityId
        }

        fun relationshipTypes(relationshipTypes: List) =
            relationshipTypes(JsonField.of(relationshipTypes))

        @JsonProperty("relationship_types")
        @ExcludeMissing
        fun relationshipTypes(relationshipTypes: JsonField>) = apply {
            this.relationshipTypes = relationshipTypes
        }

        /** The job title of the child entity at the parent entity. */
        fun title(title: String) = title(JsonField.of(title))

        /** The job title of the child entity at the parent entity. */
        @JsonProperty("title")
        @ExcludeMissing
        fun title(title: JsonField) = apply { this.title = title }

        /** The child entity's ownership percentage iff they are a beneficial owner. */
        fun ownershipPercentage(ownershipPercentage: Long) =
            ownershipPercentage(JsonField.of(ownershipPercentage))

        /** The child entity's ownership percentage iff they are a beneficial owner. */
        @JsonProperty("ownership_percentage")
        @ExcludeMissing
        fun ownershipPercentage(ownershipPercentage: JsonField) = apply {
            this.ownershipPercentage = ownershipPercentage
        }

        /** The child legal entity. */
        fun childLegalEntity(childLegalEntity: ChildLegalEntity) =
            childLegalEntity(JsonField.of(childLegalEntity))

        /** The child legal entity. */
        @JsonProperty("child_legal_entity")
        @ExcludeMissing
        fun childLegalEntity(childLegalEntity: JsonField) = apply {
            this.childLegalEntity = childLegalEntity
        }

        fun additionalProperties(additionalProperties: Map) = apply {
            this.additionalProperties.clear()
            this.additionalProperties.putAll(additionalProperties)
        }

        @JsonAnySetter
        fun putAdditionalProperty(key: String, value: JsonValue) = apply {
            this.additionalProperties.put(key, value)
        }

        fun putAllAdditionalProperties(additionalProperties: Map) = apply {
            this.additionalProperties.putAll(additionalProperties)
        }

        fun build(): LegalEntityAssociation =
            LegalEntityAssociation(
                id,
                object_,
                liveMode,
                createdAt,
                updatedAt,
                discardedAt,
                parentLegalEntityId,
                relationshipTypes.map { it.toImmutable() },
                title,
                ownershipPercentage,
                childLegalEntity,
                additionalProperties.toImmutable(),
            )
    }

    /** The child legal entity. */
    @JsonDeserialize(builder = ChildLegalEntity.Builder::class)
    @NoAutoDetect
    class ChildLegalEntity
    private constructor(
        private val id: JsonField,
        private val object_: JsonField,
        private val liveMode: JsonField,
        private val createdAt: JsonField,
        private val updatedAt: JsonField,
        private val discardedAt: JsonField,
        private val legalEntityType: JsonField,
        private val riskRating: JsonField,
        private val prefix: JsonField,
        private val firstName: JsonField,
        private val middleName: JsonField,
        private val lastName: JsonField,
        private val suffix: JsonField,
        private val preferredName: JsonField,
        private val citizenshipCountry: JsonField,
        private val politicallyExposedPerson: JsonField,
        private val dateOfBirth: JsonField,
        private val dateFormed: JsonField,
        private val businessName: JsonField,
        private val doingBusinessAsNames: JsonField>,
        private val legalStructure: JsonField,
        private val phoneNumbers: JsonField>,
        private val email: JsonField,
        private val website: JsonField,
        private val metadata: JsonField,
        private val bankSettings: JsonField,
        private val wealthAndEmploymentDetails: JsonField,
        private val addresses: JsonField>,
        private val identifications: JsonField>,
        private val additionalProperties: Map,
    ) {

        private var validated: Boolean = false

        fun id(): String = id.getRequired("id")

        fun object_(): String = object_.getRequired("object")

        /**
         * This field will be true if this object exists in the live environment or false if it
         * exists in the test environment.
         */
        fun liveMode(): Boolean = liveMode.getRequired("live_mode")

        fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at")

        fun updatedAt(): OffsetDateTime = updatedAt.getRequired("updated_at")

        fun discardedAt(): OffsetDateTime? = discardedAt.getNullable("discarded_at")

        /** The type of legal entity. */
        fun legalEntityType(): LegalEntityType = legalEntityType.getRequired("legal_entity_type")

        /** The risk rating of the legal entity. One of low, medium, high. */
        fun riskRating(): RiskRating? = riskRating.getNullable("risk_rating")

        /** An individual's prefix. */
        fun prefix(): String? = prefix.getNullable("prefix")

        /** An individual's first name. */
        fun firstName(): String? = firstName.getNullable("first_name")

        /** An individual's middle name. */
        fun middleName(): String? = middleName.getNullable("middle_name")

        /** An individual's last name. */
        fun lastName(): String? = lastName.getNullable("last_name")

        /** An individual's suffix. */
        fun suffix(): String? = suffix.getNullable("suffix")

        /** An individual's preferred name. */
        fun preferredName(): String? = preferredName.getNullable("preferred_name")

        /** The country of citizenship for an individual. */
        fun citizenshipCountry(): String? = citizenshipCountry.getNullable("citizenship_country")

        /** Whether the individual is a politically exposed person. */
        fun politicallyExposedPerson(): Boolean? =
            politicallyExposedPerson.getNullable("politically_exposed_person")

        /** An individual's date of birth (YYYY-MM-DD). */
        fun dateOfBirth(): LocalDate? = dateOfBirth.getNullable("date_of_birth")

        /** A business's formation date (YYYY-MM-DD). */
        fun dateFormed(): LocalDate? = dateFormed.getNullable("date_formed")

        /** The business's legal business name. */
        fun businessName(): String? = businessName.getNullable("business_name")

        fun doingBusinessAsNames(): List =
            doingBusinessAsNames.getRequired("doing_business_as_names")

        /** The business's legal structure. */
        fun legalStructure(): LegalStructure? = legalStructure.getNullable("legal_structure")

        fun phoneNumbers(): List = phoneNumbers.getRequired("phone_numbers")

        /** The entity's primary email. */
        fun email(): String? = email.getNullable("email")

        /** The entity's primary website URL. */
        fun website(): String? = website.getNullable("website")

        /**
         * Additional data represented as key-value pairs. Both the key and value must be strings.
         */
        fun metadata(): Metadata = metadata.getRequired("metadata")

        fun bankSettings(): BankSettings? = bankSettings.getNullable("bank_settings")

        fun wealthAndEmploymentDetails(): WealthAndEmploymentDetails? =
            wealthAndEmploymentDetails.getNullable("wealth_and_employment_details")

        /** A list of addresses for the entity. */
        fun addresses(): List = addresses.getRequired("addresses")

        /** A list of identifications for the legal entity. */
        fun identifications(): List = identifications.getRequired("identifications")

        @JsonProperty("id") @ExcludeMissing fun _id() = id

        @JsonProperty("object") @ExcludeMissing fun _object_() = object_

        /**
         * This field will be true if this object exists in the live environment or false if it
         * exists in the test environment.
         */
        @JsonProperty("live_mode") @ExcludeMissing fun _liveMode() = liveMode

        @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt

        @JsonProperty("updated_at") @ExcludeMissing fun _updatedAt() = updatedAt

        @JsonProperty("discarded_at") @ExcludeMissing fun _discardedAt() = discardedAt

        /** The type of legal entity. */
        @JsonProperty("legal_entity_type") @ExcludeMissing fun _legalEntityType() = legalEntityType

        /** The risk rating of the legal entity. One of low, medium, high. */
        @JsonProperty("risk_rating") @ExcludeMissing fun _riskRating() = riskRating

        /** An individual's prefix. */
        @JsonProperty("prefix") @ExcludeMissing fun _prefix() = prefix

        /** An individual's first name. */
        @JsonProperty("first_name") @ExcludeMissing fun _firstName() = firstName

        /** An individual's middle name. */
        @JsonProperty("middle_name") @ExcludeMissing fun _middleName() = middleName

        /** An individual's last name. */
        @JsonProperty("last_name") @ExcludeMissing fun _lastName() = lastName

        /** An individual's suffix. */
        @JsonProperty("suffix") @ExcludeMissing fun _suffix() = suffix

        /** An individual's preferred name. */
        @JsonProperty("preferred_name") @ExcludeMissing fun _preferredName() = preferredName

        /** The country of citizenship for an individual. */
        @JsonProperty("citizenship_country")
        @ExcludeMissing
        fun _citizenshipCountry() = citizenshipCountry

        /** Whether the individual is a politically exposed person. */
        @JsonProperty("politically_exposed_person")
        @ExcludeMissing
        fun _politicallyExposedPerson() = politicallyExposedPerson

        /** An individual's date of birth (YYYY-MM-DD). */
        @JsonProperty("date_of_birth") @ExcludeMissing fun _dateOfBirth() = dateOfBirth

        /** A business's formation date (YYYY-MM-DD). */
        @JsonProperty("date_formed") @ExcludeMissing fun _dateFormed() = dateFormed

        /** The business's legal business name. */
        @JsonProperty("business_name") @ExcludeMissing fun _businessName() = businessName

        @JsonProperty("doing_business_as_names")
        @ExcludeMissing
        fun _doingBusinessAsNames() = doingBusinessAsNames

        /** The business's legal structure. */
        @JsonProperty("legal_structure") @ExcludeMissing fun _legalStructure() = legalStructure

        @JsonProperty("phone_numbers") @ExcludeMissing fun _phoneNumbers() = phoneNumbers

        /** The entity's primary email. */
        @JsonProperty("email") @ExcludeMissing fun _email() = email

        /** The entity's primary website URL. */
        @JsonProperty("website") @ExcludeMissing fun _website() = website

        /**
         * Additional data represented as key-value pairs. Both the key and value must be strings.
         */
        @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata

        @JsonProperty("bank_settings") @ExcludeMissing fun _bankSettings() = bankSettings

        @JsonProperty("wealth_and_employment_details")
        @ExcludeMissing
        fun _wealthAndEmploymentDetails() = wealthAndEmploymentDetails

        /** A list of addresses for the entity. */
        @JsonProperty("addresses") @ExcludeMissing fun _addresses() = addresses

        /** A list of identifications for the legal entity. */
        @JsonProperty("identifications") @ExcludeMissing fun _identifications() = identifications

        @JsonAnyGetter
        @ExcludeMissing
        fun _additionalProperties(): Map = additionalProperties

        fun validate(): ChildLegalEntity = apply {
            if (!validated) {
                id()
                object_()
                liveMode()
                createdAt()
                updatedAt()
                discardedAt()
                legalEntityType()
                riskRating()
                prefix()
                firstName()
                middleName()
                lastName()
                suffix()
                preferredName()
                citizenshipCountry()
                politicallyExposedPerson()
                dateOfBirth()
                dateFormed()
                businessName()
                doingBusinessAsNames()
                legalStructure()
                phoneNumbers().forEach { it.validate() }
                email()
                website()
                metadata().validate()
                bankSettings()?.validate()
                wealthAndEmploymentDetails()?.validate()
                addresses().forEach { it.validate() }
                identifications().forEach { it.validate() }
                validated = true
            }
        }

        fun toBuilder() = Builder().from(this)

        companion object {

            fun builder() = Builder()
        }

        class Builder {

            private var id: JsonField = JsonMissing.of()
            private var object_: JsonField = JsonMissing.of()
            private var liveMode: JsonField = JsonMissing.of()
            private var createdAt: JsonField = JsonMissing.of()
            private var updatedAt: JsonField = JsonMissing.of()
            private var discardedAt: JsonField = JsonMissing.of()
            private var legalEntityType: JsonField = JsonMissing.of()
            private var riskRating: JsonField = JsonMissing.of()
            private var prefix: JsonField = JsonMissing.of()
            private var firstName: JsonField = JsonMissing.of()
            private var middleName: JsonField = JsonMissing.of()
            private var lastName: JsonField = JsonMissing.of()
            private var suffix: JsonField = JsonMissing.of()
            private var preferredName: JsonField = JsonMissing.of()
            private var citizenshipCountry: JsonField = JsonMissing.of()
            private var politicallyExposedPerson: JsonField = JsonMissing.of()
            private var dateOfBirth: JsonField = JsonMissing.of()
            private var dateFormed: JsonField = JsonMissing.of()
            private var businessName: JsonField = JsonMissing.of()
            private var doingBusinessAsNames: JsonField> = JsonMissing.of()
            private var legalStructure: JsonField = JsonMissing.of()
            private var phoneNumbers: JsonField> = JsonMissing.of()
            private var email: JsonField = JsonMissing.of()
            private var website: JsonField = JsonMissing.of()
            private var metadata: JsonField = JsonMissing.of()
            private var bankSettings: JsonField = JsonMissing.of()
            private var wealthAndEmploymentDetails: JsonField =
                JsonMissing.of()
            private var addresses: JsonField> = JsonMissing.of()
            private var identifications: JsonField> = JsonMissing.of()
            private var additionalProperties: MutableMap = mutableMapOf()

            internal fun from(childLegalEntity: ChildLegalEntity) = apply {
                this.id = childLegalEntity.id
                this.object_ = childLegalEntity.object_
                this.liveMode = childLegalEntity.liveMode
                this.createdAt = childLegalEntity.createdAt
                this.updatedAt = childLegalEntity.updatedAt
                this.discardedAt = childLegalEntity.discardedAt
                this.legalEntityType = childLegalEntity.legalEntityType
                this.riskRating = childLegalEntity.riskRating
                this.prefix = childLegalEntity.prefix
                this.firstName = childLegalEntity.firstName
                this.middleName = childLegalEntity.middleName
                this.lastName = childLegalEntity.lastName
                this.suffix = childLegalEntity.suffix
                this.preferredName = childLegalEntity.preferredName
                this.citizenshipCountry = childLegalEntity.citizenshipCountry
                this.politicallyExposedPerson = childLegalEntity.politicallyExposedPerson
                this.dateOfBirth = childLegalEntity.dateOfBirth
                this.dateFormed = childLegalEntity.dateFormed
                this.businessName = childLegalEntity.businessName
                this.doingBusinessAsNames = childLegalEntity.doingBusinessAsNames
                this.legalStructure = childLegalEntity.legalStructure
                this.phoneNumbers = childLegalEntity.phoneNumbers
                this.email = childLegalEntity.email
                this.website = childLegalEntity.website
                this.metadata = childLegalEntity.metadata
                this.bankSettings = childLegalEntity.bankSettings
                this.wealthAndEmploymentDetails = childLegalEntity.wealthAndEmploymentDetails
                this.addresses = childLegalEntity.addresses
                this.identifications = childLegalEntity.identifications
                additionalProperties(childLegalEntity.additionalProperties)
            }

            fun id(id: String) = id(JsonField.of(id))

            @JsonProperty("id")
            @ExcludeMissing
            fun id(id: JsonField) = apply { this.id = id }

            fun object_(object_: String) = object_(JsonField.of(object_))

            @JsonProperty("object")
            @ExcludeMissing
            fun object_(object_: JsonField) = apply { this.object_ = object_ }

            /**
             * This field will be true if this object exists in the live environment or false if it
             * exists in the test environment.
             */
            fun liveMode(liveMode: Boolean) = liveMode(JsonField.of(liveMode))

            /**
             * This field will be true if this object exists in the live environment or false if it
             * exists in the test environment.
             */
            @JsonProperty("live_mode")
            @ExcludeMissing
            fun liveMode(liveMode: JsonField) = apply { this.liveMode = liveMode }

            fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt))

            @JsonProperty("created_at")
            @ExcludeMissing
            fun createdAt(createdAt: JsonField) = apply {
                this.createdAt = createdAt
            }

            fun updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt))

            @JsonProperty("updated_at")
            @ExcludeMissing
            fun updatedAt(updatedAt: JsonField) = apply {
                this.updatedAt = updatedAt
            }

            fun discardedAt(discardedAt: OffsetDateTime) = discardedAt(JsonField.of(discardedAt))

            @JsonProperty("discarded_at")
            @ExcludeMissing
            fun discardedAt(discardedAt: JsonField) = apply {
                this.discardedAt = discardedAt
            }

            /** The type of legal entity. */
            fun legalEntityType(legalEntityType: LegalEntityType) =
                legalEntityType(JsonField.of(legalEntityType))

            /** The type of legal entity. */
            @JsonProperty("legal_entity_type")
            @ExcludeMissing
            fun legalEntityType(legalEntityType: JsonField) = apply {
                this.legalEntityType = legalEntityType
            }

            /** The risk rating of the legal entity. One of low, medium, high. */
            fun riskRating(riskRating: RiskRating) = riskRating(JsonField.of(riskRating))

            /** The risk rating of the legal entity. One of low, medium, high. */
            @JsonProperty("risk_rating")
            @ExcludeMissing
            fun riskRating(riskRating: JsonField) = apply {
                this.riskRating = riskRating
            }

            /** An individual's prefix. */
            fun prefix(prefix: String) = prefix(JsonField.of(prefix))

            /** An individual's prefix. */
            @JsonProperty("prefix")
            @ExcludeMissing
            fun prefix(prefix: JsonField) = apply { this.prefix = prefix }

            /** An individual's first name. */
            fun firstName(firstName: String) = firstName(JsonField.of(firstName))

            /** An individual's first name. */
            @JsonProperty("first_name")
            @ExcludeMissing
            fun firstName(firstName: JsonField) = apply { this.firstName = firstName }

            /** An individual's middle name. */
            fun middleName(middleName: String) = middleName(JsonField.of(middleName))

            /** An individual's middle name. */
            @JsonProperty("middle_name")
            @ExcludeMissing
            fun middleName(middleName: JsonField) = apply { this.middleName = middleName }

            /** An individual's last name. */
            fun lastName(lastName: String) = lastName(JsonField.of(lastName))

            /** An individual's last name. */
            @JsonProperty("last_name")
            @ExcludeMissing
            fun lastName(lastName: JsonField) = apply { this.lastName = lastName }

            /** An individual's suffix. */
            fun suffix(suffix: String) = suffix(JsonField.of(suffix))

            /** An individual's suffix. */
            @JsonProperty("suffix")
            @ExcludeMissing
            fun suffix(suffix: JsonField) = apply { this.suffix = suffix }

            /** An individual's preferred name. */
            fun preferredName(preferredName: String) = preferredName(JsonField.of(preferredName))

            /** An individual's preferred name. */
            @JsonProperty("preferred_name")
            @ExcludeMissing
            fun preferredName(preferredName: JsonField) = apply {
                this.preferredName = preferredName
            }

            /** The country of citizenship for an individual. */
            fun citizenshipCountry(citizenshipCountry: String) =
                citizenshipCountry(JsonField.of(citizenshipCountry))

            /** The country of citizenship for an individual. */
            @JsonProperty("citizenship_country")
            @ExcludeMissing
            fun citizenshipCountry(citizenshipCountry: JsonField) = apply {
                this.citizenshipCountry = citizenshipCountry
            }

            /** Whether the individual is a politically exposed person. */
            fun politicallyExposedPerson(politicallyExposedPerson: Boolean) =
                politicallyExposedPerson(JsonField.of(politicallyExposedPerson))

            /** Whether the individual is a politically exposed person. */
            @JsonProperty("politically_exposed_person")
            @ExcludeMissing
            fun politicallyExposedPerson(politicallyExposedPerson: JsonField) = apply {
                this.politicallyExposedPerson = politicallyExposedPerson
            }

            /** An individual's date of birth (YYYY-MM-DD). */
            fun dateOfBirth(dateOfBirth: LocalDate) = dateOfBirth(JsonField.of(dateOfBirth))

            /** An individual's date of birth (YYYY-MM-DD). */
            @JsonProperty("date_of_birth")
            @ExcludeMissing
            fun dateOfBirth(dateOfBirth: JsonField) = apply {
                this.dateOfBirth = dateOfBirth
            }

            /** A business's formation date (YYYY-MM-DD). */
            fun dateFormed(dateFormed: LocalDate) = dateFormed(JsonField.of(dateFormed))

            /** A business's formation date (YYYY-MM-DD). */
            @JsonProperty("date_formed")
            @ExcludeMissing
            fun dateFormed(dateFormed: JsonField) = apply {
                this.dateFormed = dateFormed
            }

            /** The business's legal business name. */
            fun businessName(businessName: String) = businessName(JsonField.of(businessName))

            /** The business's legal business name. */
            @JsonProperty("business_name")
            @ExcludeMissing
            fun businessName(businessName: JsonField) = apply {
                this.businessName = businessName
            }

            fun doingBusinessAsNames(doingBusinessAsNames: List) =
                doingBusinessAsNames(JsonField.of(doingBusinessAsNames))

            @JsonProperty("doing_business_as_names")
            @ExcludeMissing
            fun doingBusinessAsNames(doingBusinessAsNames: JsonField>) = apply {
                this.doingBusinessAsNames = doingBusinessAsNames
            }

            /** The business's legal structure. */
            fun legalStructure(legalStructure: LegalStructure) =
                legalStructure(JsonField.of(legalStructure))

            /** The business's legal structure. */
            @JsonProperty("legal_structure")
            @ExcludeMissing
            fun legalStructure(legalStructure: JsonField) = apply {
                this.legalStructure = legalStructure
            }

            fun phoneNumbers(phoneNumbers: List) =
                phoneNumbers(JsonField.of(phoneNumbers))

            @JsonProperty("phone_numbers")
            @ExcludeMissing
            fun phoneNumbers(phoneNumbers: JsonField>) = apply {
                this.phoneNumbers = phoneNumbers
            }

            /** The entity's primary email. */
            fun email(email: String) = email(JsonField.of(email))

            /** The entity's primary email. */
            @JsonProperty("email")
            @ExcludeMissing
            fun email(email: JsonField) = apply { this.email = email }

            /** The entity's primary website URL. */
            fun website(website: String) = website(JsonField.of(website))

            /** The entity's primary website URL. */
            @JsonProperty("website")
            @ExcludeMissing
            fun website(website: JsonField) = apply { this.website = website }

            /**
             * Additional data represented as key-value pairs. Both the key and value must be
             * strings.
             */
            fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata))

            /**
             * Additional data represented as key-value pairs. Both the key and value must be
             * strings.
             */
            @JsonProperty("metadata")
            @ExcludeMissing
            fun metadata(metadata: JsonField) = apply { this.metadata = metadata }

            fun bankSettings(bankSettings: BankSettings) = bankSettings(JsonField.of(bankSettings))

            @JsonProperty("bank_settings")
            @ExcludeMissing
            fun bankSettings(bankSettings: JsonField) = apply {
                this.bankSettings = bankSettings
            }

            fun wealthAndEmploymentDetails(wealthAndEmploymentDetails: WealthAndEmploymentDetails) =
                wealthAndEmploymentDetails(JsonField.of(wealthAndEmploymentDetails))

            @JsonProperty("wealth_and_employment_details")
            @ExcludeMissing
            fun wealthAndEmploymentDetails(
                wealthAndEmploymentDetails: JsonField
            ) = apply { this.wealthAndEmploymentDetails = wealthAndEmploymentDetails }

            /** A list of addresses for the entity. */
            fun addresses(addresses: List) = addresses(JsonField.of(addresses))

            /** A list of addresses for the entity. */
            @JsonProperty("addresses")
            @ExcludeMissing
            fun addresses(addresses: JsonField>) = apply {
                this.addresses = addresses
            }

            /** A list of identifications for the legal entity. */
            fun identifications(identifications: List) =
                identifications(JsonField.of(identifications))

            /** A list of identifications for the legal entity. */
            @JsonProperty("identifications")
            @ExcludeMissing
            fun identifications(identifications: JsonField>) = apply {
                this.identifications = identifications
            }

            fun additionalProperties(additionalProperties: Map) = apply {
                this.additionalProperties.clear()
                this.additionalProperties.putAll(additionalProperties)
            }

            @JsonAnySetter
            fun putAdditionalProperty(key: String, value: JsonValue) = apply {
                this.additionalProperties.put(key, value)
            }

            fun putAllAdditionalProperties(additionalProperties: Map) = apply {
                this.additionalProperties.putAll(additionalProperties)
            }

            fun build(): ChildLegalEntity =
                ChildLegalEntity(
                    id,
                    object_,
                    liveMode,
                    createdAt,
                    updatedAt,
                    discardedAt,
                    legalEntityType,
                    riskRating,
                    prefix,
                    firstName,
                    middleName,
                    lastName,
                    suffix,
                    preferredName,
                    citizenshipCountry,
                    politicallyExposedPerson,
                    dateOfBirth,
                    dateFormed,
                    businessName,
                    doingBusinessAsNames.map { it.toImmutable() },
                    legalStructure,
                    phoneNumbers.map { it.toImmutable() },
                    email,
                    website,
                    metadata,
                    bankSettings,
                    wealthAndEmploymentDetails,
                    addresses.map { it.toImmutable() },
                    identifications.map { it.toImmutable() },
                    additionalProperties.toImmutable(),
                )
        }

        @JsonDeserialize(builder = LegalEntityAddress.Builder::class)
        @NoAutoDetect
        class LegalEntityAddress
        private constructor(
            private val id: JsonField,
            private val object_: JsonField,
            private val liveMode: JsonField,
            private val createdAt: JsonField,
            private val updatedAt: JsonField,
            private val discardedAt: JsonField,
            private val addressTypes: JsonField>,
            private val line1: JsonField,
            private val line2: JsonField,
            private val locality: JsonField,
            private val region: JsonField,
            private val postalCode: JsonField,
            private val country: JsonField,
            private val additionalProperties: Map,
        ) {

            private var validated: Boolean = false

            fun id(): String = id.getRequired("id")

            fun object_(): String = object_.getRequired("object")

            /**
             * This field will be true if this object exists in the live environment or false if it
             * exists in the test environment.
             */
            fun liveMode(): Boolean = liveMode.getRequired("live_mode")

            fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at")

            fun updatedAt(): OffsetDateTime = updatedAt.getRequired("updated_at")

            fun discardedAt(): OffsetDateTime? = discardedAt.getNullable("discarded_at")

            /** The types of this address. */
            fun addressTypes(): List = addressTypes.getRequired("address_types")

            fun line1(): String? = line1.getNullable("line1")

            fun line2(): String? = line2.getNullable("line2")

            /** Locality or City. */
            fun locality(): String? = locality.getNullable("locality")

            /** Region or State. */
            fun region(): String? = region.getNullable("region")

            /** The postal code of the address. */
            fun postalCode(): String? = postalCode.getNullable("postal_code")

            /** Country code conforms to [ISO 3166-1 alpha-2] */
            fun country(): String? = country.getNullable("country")

            @JsonProperty("id") @ExcludeMissing fun _id() = id

            @JsonProperty("object") @ExcludeMissing fun _object_() = object_

            /**
             * This field will be true if this object exists in the live environment or false if it
             * exists in the test environment.
             */
            @JsonProperty("live_mode") @ExcludeMissing fun _liveMode() = liveMode

            @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt

            @JsonProperty("updated_at") @ExcludeMissing fun _updatedAt() = updatedAt

            @JsonProperty("discarded_at") @ExcludeMissing fun _discardedAt() = discardedAt

            /** The types of this address. */
            @JsonProperty("address_types") @ExcludeMissing fun _addressTypes() = addressTypes

            @JsonProperty("line1") @ExcludeMissing fun _line1() = line1

            @JsonProperty("line2") @ExcludeMissing fun _line2() = line2

            /** Locality or City. */
            @JsonProperty("locality") @ExcludeMissing fun _locality() = locality

            /** Region or State. */
            @JsonProperty("region") @ExcludeMissing fun _region() = region

            /** The postal code of the address. */
            @JsonProperty("postal_code") @ExcludeMissing fun _postalCode() = postalCode

            /** Country code conforms to [ISO 3166-1 alpha-2] */
            @JsonProperty("country") @ExcludeMissing fun _country() = country

            @JsonAnyGetter
            @ExcludeMissing
            fun _additionalProperties(): Map = additionalProperties

            fun validate(): LegalEntityAddress = apply {
                if (!validated) {
                    id()
                    object_()
                    liveMode()
                    createdAt()
                    updatedAt()
                    discardedAt()
                    addressTypes()
                    line1()
                    line2()
                    locality()
                    region()
                    postalCode()
                    country()
                    validated = true
                }
            }

            fun toBuilder() = Builder().from(this)

            companion object {

                fun builder() = Builder()
            }

            class Builder {

                private var id: JsonField = JsonMissing.of()
                private var object_: JsonField = JsonMissing.of()
                private var liveMode: JsonField = JsonMissing.of()
                private var createdAt: JsonField = JsonMissing.of()
                private var updatedAt: JsonField = JsonMissing.of()
                private var discardedAt: JsonField = JsonMissing.of()
                private var addressTypes: JsonField> = JsonMissing.of()
                private var line1: JsonField = JsonMissing.of()
                private var line2: JsonField = JsonMissing.of()
                private var locality: JsonField = JsonMissing.of()
                private var region: JsonField = JsonMissing.of()
                private var postalCode: JsonField = JsonMissing.of()
                private var country: JsonField = JsonMissing.of()
                private var additionalProperties: MutableMap = mutableMapOf()

                internal fun from(legalEntityAddress: LegalEntityAddress) = apply {
                    this.id = legalEntityAddress.id
                    this.object_ = legalEntityAddress.object_
                    this.liveMode = legalEntityAddress.liveMode
                    this.createdAt = legalEntityAddress.createdAt
                    this.updatedAt = legalEntityAddress.updatedAt
                    this.discardedAt = legalEntityAddress.discardedAt
                    this.addressTypes = legalEntityAddress.addressTypes
                    this.line1 = legalEntityAddress.line1
                    this.line2 = legalEntityAddress.line2
                    this.locality = legalEntityAddress.locality
                    this.region = legalEntityAddress.region
                    this.postalCode = legalEntityAddress.postalCode
                    this.country = legalEntityAddress.country
                    additionalProperties(legalEntityAddress.additionalProperties)
                }

                fun id(id: String) = id(JsonField.of(id))

                @JsonProperty("id")
                @ExcludeMissing
                fun id(id: JsonField) = apply { this.id = id }

                fun object_(object_: String) = object_(JsonField.of(object_))

                @JsonProperty("object")
                @ExcludeMissing
                fun object_(object_: JsonField) = apply { this.object_ = object_ }

                /**
                 * This field will be true if this object exists in the live environment or false if
                 * it exists in the test environment.
                 */
                fun liveMode(liveMode: Boolean) = liveMode(JsonField.of(liveMode))

                /**
                 * This field will be true if this object exists in the live environment or false if
                 * it exists in the test environment.
                 */
                @JsonProperty("live_mode")
                @ExcludeMissing
                fun liveMode(liveMode: JsonField) = apply { this.liveMode = liveMode }

                fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt))

                @JsonProperty("created_at")
                @ExcludeMissing
                fun createdAt(createdAt: JsonField) = apply {
                    this.createdAt = createdAt
                }

                fun updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt))

                @JsonProperty("updated_at")
                @ExcludeMissing
                fun updatedAt(updatedAt: JsonField) = apply {
                    this.updatedAt = updatedAt
                }

                fun discardedAt(discardedAt: OffsetDateTime) =
                    discardedAt(JsonField.of(discardedAt))

                @JsonProperty("discarded_at")
                @ExcludeMissing
                fun discardedAt(discardedAt: JsonField) = apply {
                    this.discardedAt = discardedAt
                }

                /** The types of this address. */
                fun addressTypes(addressTypes: List) =
                    addressTypes(JsonField.of(addressTypes))

                /** The types of this address. */
                @JsonProperty("address_types")
                @ExcludeMissing
                fun addressTypes(addressTypes: JsonField>) = apply {
                    this.addressTypes = addressTypes
                }

                fun line1(line1: String) = line1(JsonField.of(line1))

                @JsonProperty("line1")
                @ExcludeMissing
                fun line1(line1: JsonField) = apply { this.line1 = line1 }

                fun line2(line2: String) = line2(JsonField.of(line2))

                @JsonProperty("line2")
                @ExcludeMissing
                fun line2(line2: JsonField) = apply { this.line2 = line2 }

                /** Locality or City. */
                fun locality(locality: String) = locality(JsonField.of(locality))

                /** Locality or City. */
                @JsonProperty("locality")
                @ExcludeMissing
                fun locality(locality: JsonField) = apply { this.locality = locality }

                /** Region or State. */
                fun region(region: String) = region(JsonField.of(region))

                /** Region or State. */
                @JsonProperty("region")
                @ExcludeMissing
                fun region(region: JsonField) = apply { this.region = region }

                /** The postal code of the address. */
                fun postalCode(postalCode: String) = postalCode(JsonField.of(postalCode))

                /** The postal code of the address. */
                @JsonProperty("postal_code")
                @ExcludeMissing
                fun postalCode(postalCode: JsonField) = apply {
                    this.postalCode = postalCode
                }

                /** Country code conforms to [ISO 3166-1 alpha-2] */
                fun country(country: String) = country(JsonField.of(country))

                /** Country code conforms to [ISO 3166-1 alpha-2] */
                @JsonProperty("country")
                @ExcludeMissing
                fun country(country: JsonField) = apply { this.country = country }

                fun additionalProperties(additionalProperties: Map) = apply {
                    this.additionalProperties.clear()
                    this.additionalProperties.putAll(additionalProperties)
                }

                @JsonAnySetter
                fun putAdditionalProperty(key: String, value: JsonValue) = apply {
                    this.additionalProperties.put(key, value)
                }

                fun putAllAdditionalProperties(additionalProperties: Map) =
                    apply {
                        this.additionalProperties.putAll(additionalProperties)
                    }

                fun build(): LegalEntityAddress =
                    LegalEntityAddress(
                        id,
                        object_,
                        liveMode,
                        createdAt,
                        updatedAt,
                        discardedAt,
                        addressTypes.map { it.toImmutable() },
                        line1,
                        line2,
                        locality,
                        region,
                        postalCode,
                        country,
                        additionalProperties.toImmutable(),
                    )
            }

            class AddressType
            @JsonCreator
            private constructor(
                private val value: JsonField,
            ) : Enum {

                @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value

                companion object {

                    val BUSINESS = of("business")

                    val MAILING = of("mailing")

                    val OTHER = of("other")

                    val PO_BOX = of("po_box")

                    val RESIDENTIAL = of("residential")

                    fun of(value: String) = AddressType(JsonField.of(value))
                }

                enum class Known {
                    BUSINESS,
                    MAILING,
                    OTHER,
                    PO_BOX,
                    RESIDENTIAL,
                }

                enum class Value {
                    BUSINESS,
                    MAILING,
                    OTHER,
                    PO_BOX,
                    RESIDENTIAL,
                    _UNKNOWN,
                }

                fun value(): Value =
                    when (this) {
                        BUSINESS -> Value.BUSINESS
                        MAILING -> Value.MAILING
                        OTHER -> Value.OTHER
                        PO_BOX -> Value.PO_BOX
                        RESIDENTIAL -> Value.RESIDENTIAL
                        else -> Value._UNKNOWN
                    }

                fun known(): Known =
                    when (this) {
                        BUSINESS -> Known.BUSINESS
                        MAILING -> Known.MAILING
                        OTHER -> Known.OTHER
                        PO_BOX -> Known.PO_BOX
                        RESIDENTIAL -> Known.RESIDENTIAL
                        else ->
                            throw ModernTreasuryInvalidDataException("Unknown AddressType: $value")
                    }

                fun asString(): String = _value().asStringOrThrow()

                override fun equals(other: Any?): Boolean {
                    if (this === other) {
                        return true
                    }

                    return /* spotless:off */ other is AddressType && value == other.value /* spotless:on */
                }

                override fun hashCode() = value.hashCode()

                override fun toString() = value.toString()
            }

            override fun equals(other: Any?): Boolean {
                if (this === other) {
                    return true
                }

                return /* spotless:off */ other is LegalEntityAddress && id == other.id && object_ == other.object_ && liveMode == other.liveMode && createdAt == other.createdAt && updatedAt == other.updatedAt && discardedAt == other.discardedAt && addressTypes == other.addressTypes && line1 == other.line1 && line2 == other.line2 && locality == other.locality && region == other.region && postalCode == other.postalCode && country == other.country && additionalProperties == other.additionalProperties /* spotless:on */
            }

            /* spotless:off */
            private val hashCode: Int by lazy { Objects.hash(id, object_, liveMode, createdAt, updatedAt, discardedAt, addressTypes, line1, line2, locality, region, postalCode, country, additionalProperties) }
            /* spotless:on */

            override fun hashCode(): Int = hashCode

            override fun toString() =
                "LegalEntityAddress{id=$id, object_=$object_, liveMode=$liveMode, createdAt=$createdAt, updatedAt=$updatedAt, discardedAt=$discardedAt, addressTypes=$addressTypes, line1=$line1, line2=$line2, locality=$locality, region=$region, postalCode=$postalCode, country=$country, additionalProperties=$additionalProperties}"
        }

        @JsonDeserialize(builder = Identification.Builder::class)
        @NoAutoDetect
        class Identification
        private constructor(
            private val id: JsonField,
            private val object_: JsonField,
            private val liveMode: JsonField,
            private val createdAt: JsonField,
            private val updatedAt: JsonField,
            private val discardedAt: JsonField,
            private val idType: JsonField,
            private val issuingCountry: JsonField,
            private val additionalProperties: Map,
        ) {

            private var validated: Boolean = false

            fun id(): String = id.getRequired("id")

            fun object_(): String = object_.getRequired("object")

            /**
             * This field will be true if this object exists in the live environment or false if it
             * exists in the test environment.
             */
            fun liveMode(): Boolean = liveMode.getRequired("live_mode")

            fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at")

            fun updatedAt(): OffsetDateTime = updatedAt.getRequired("updated_at")

            fun discardedAt(): OffsetDateTime? = discardedAt.getNullable("discarded_at")

            /** The type of ID number. */
            fun idType(): IdType = idType.getRequired("id_type")

            /** The ISO 3166-1 alpha-2 country code of the country that issued the identification */
            fun issuingCountry(): String? = issuingCountry.getNullable("issuing_country")

            @JsonProperty("id") @ExcludeMissing fun _id() = id

            @JsonProperty("object") @ExcludeMissing fun _object_() = object_

            /**
             * This field will be true if this object exists in the live environment or false if it
             * exists in the test environment.
             */
            @JsonProperty("live_mode") @ExcludeMissing fun _liveMode() = liveMode

            @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt

            @JsonProperty("updated_at") @ExcludeMissing fun _updatedAt() = updatedAt

            @JsonProperty("discarded_at") @ExcludeMissing fun _discardedAt() = discardedAt

            /** The type of ID number. */
            @JsonProperty("id_type") @ExcludeMissing fun _idType() = idType

            /** The ISO 3166-1 alpha-2 country code of the country that issued the identification */
            @JsonProperty("issuing_country") @ExcludeMissing fun _issuingCountry() = issuingCountry

            @JsonAnyGetter
            @ExcludeMissing
            fun _additionalProperties(): Map = additionalProperties

            fun validate(): Identification = apply {
                if (!validated) {
                    id()
                    object_()
                    liveMode()
                    createdAt()
                    updatedAt()
                    discardedAt()
                    idType()
                    issuingCountry()
                    validated = true
                }
            }

            fun toBuilder() = Builder().from(this)

            companion object {

                fun builder() = Builder()
            }

            class Builder {

                private var id: JsonField = JsonMissing.of()
                private var object_: JsonField = JsonMissing.of()
                private var liveMode: JsonField = JsonMissing.of()
                private var createdAt: JsonField = JsonMissing.of()
                private var updatedAt: JsonField = JsonMissing.of()
                private var discardedAt: JsonField = JsonMissing.of()
                private var idType: JsonField = JsonMissing.of()
                private var issuingCountry: JsonField = JsonMissing.of()
                private var additionalProperties: MutableMap = mutableMapOf()

                internal fun from(identification: Identification) = apply {
                    this.id = identification.id
                    this.object_ = identification.object_
                    this.liveMode = identification.liveMode
                    this.createdAt = identification.createdAt
                    this.updatedAt = identification.updatedAt
                    this.discardedAt = identification.discardedAt
                    this.idType = identification.idType
                    this.issuingCountry = identification.issuingCountry
                    additionalProperties(identification.additionalProperties)
                }

                fun id(id: String) = id(JsonField.of(id))

                @JsonProperty("id")
                @ExcludeMissing
                fun id(id: JsonField) = apply { this.id = id }

                fun object_(object_: String) = object_(JsonField.of(object_))

                @JsonProperty("object")
                @ExcludeMissing
                fun object_(object_: JsonField) = apply { this.object_ = object_ }

                /**
                 * This field will be true if this object exists in the live environment or false if
                 * it exists in the test environment.
                 */
                fun liveMode(liveMode: Boolean) = liveMode(JsonField.of(liveMode))

                /**
                 * This field will be true if this object exists in the live environment or false if
                 * it exists in the test environment.
                 */
                @JsonProperty("live_mode")
                @ExcludeMissing
                fun liveMode(liveMode: JsonField) = apply { this.liveMode = liveMode }

                fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt))

                @JsonProperty("created_at")
                @ExcludeMissing
                fun createdAt(createdAt: JsonField) = apply {
                    this.createdAt = createdAt
                }

                fun updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt))

                @JsonProperty("updated_at")
                @ExcludeMissing
                fun updatedAt(updatedAt: JsonField) = apply {
                    this.updatedAt = updatedAt
                }

                fun discardedAt(discardedAt: OffsetDateTime) =
                    discardedAt(JsonField.of(discardedAt))

                @JsonProperty("discarded_at")
                @ExcludeMissing
                fun discardedAt(discardedAt: JsonField) = apply {
                    this.discardedAt = discardedAt
                }

                /** The type of ID number. */
                fun idType(idType: IdType) = idType(JsonField.of(idType))

                /** The type of ID number. */
                @JsonProperty("id_type")
                @ExcludeMissing
                fun idType(idType: JsonField) = apply { this.idType = idType }

                /**
                 * The ISO 3166-1 alpha-2 country code of the country that issued the identification
                 */
                fun issuingCountry(issuingCountry: String) =
                    issuingCountry(JsonField.of(issuingCountry))

                /**
                 * The ISO 3166-1 alpha-2 country code of the country that issued the identification
                 */
                @JsonProperty("issuing_country")
                @ExcludeMissing
                fun issuingCountry(issuingCountry: JsonField) = apply {
                    this.issuingCountry = issuingCountry
                }

                fun additionalProperties(additionalProperties: Map) = apply {
                    this.additionalProperties.clear()
                    this.additionalProperties.putAll(additionalProperties)
                }

                @JsonAnySetter
                fun putAdditionalProperty(key: String, value: JsonValue) = apply {
                    this.additionalProperties.put(key, value)
                }

                fun putAllAdditionalProperties(additionalProperties: Map) =
                    apply {
                        this.additionalProperties.putAll(additionalProperties)
                    }

                fun build(): Identification =
                    Identification(
                        id,
                        object_,
                        liveMode,
                        createdAt,
                        updatedAt,
                        discardedAt,
                        idType,
                        issuingCountry,
                        additionalProperties.toImmutable(),
                    )
            }

            class IdType
            @JsonCreator
            private constructor(
                private val value: JsonField,
            ) : Enum {

                @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value

                companion object {

                    val AR_CUIL = of("ar_cuil")

                    val AR_CUIT = of("ar_cuit")

                    val BR_CNPJ = of("br_cnpj")

                    val BR_CPF = of("br_cpf")

                    val CL_RUN = of("cl_run")

                    val CL_RUT = of("cl_rut")

                    val CO_CEDULAS = of("co_cedulas")

                    val CO_NIT = of("co_nit")

                    val HN_ID = of("hn_id")

                    val HN_RTN = of("hn_rtn")

                    val IN_LEI = of("in_lei")

                    val KR_BRN = of("kr_brn")

                    val KR_CRN = of("kr_crn")

                    val KR_RRN = of("kr_rrn")

                    val PASSPORT = of("passport")

                    val SA_TIN = of("sa_tin")

                    val SA_VAT = of("sa_vat")

                    val US_EIN = of("us_ein")

                    val US_ITIN = of("us_itin")

                    val US_SSN = of("us_ssn")

                    val VN_TIN = of("vn_tin")

                    fun of(value: String) = IdType(JsonField.of(value))
                }

                enum class Known {
                    AR_CUIL,
                    AR_CUIT,
                    BR_CNPJ,
                    BR_CPF,
                    CL_RUN,
                    CL_RUT,
                    CO_CEDULAS,
                    CO_NIT,
                    HN_ID,
                    HN_RTN,
                    IN_LEI,
                    KR_BRN,
                    KR_CRN,
                    KR_RRN,
                    PASSPORT,
                    SA_TIN,
                    SA_VAT,
                    US_EIN,
                    US_ITIN,
                    US_SSN,
                    VN_TIN,
                }

                enum class Value {
                    AR_CUIL,
                    AR_CUIT,
                    BR_CNPJ,
                    BR_CPF,
                    CL_RUN,
                    CL_RUT,
                    CO_CEDULAS,
                    CO_NIT,
                    HN_ID,
                    HN_RTN,
                    IN_LEI,
                    KR_BRN,
                    KR_CRN,
                    KR_RRN,
                    PASSPORT,
                    SA_TIN,
                    SA_VAT,
                    US_EIN,
                    US_ITIN,
                    US_SSN,
                    VN_TIN,
                    _UNKNOWN,
                }

                fun value(): Value =
                    when (this) {
                        AR_CUIL -> Value.AR_CUIL
                        AR_CUIT -> Value.AR_CUIT
                        BR_CNPJ -> Value.BR_CNPJ
                        BR_CPF -> Value.BR_CPF
                        CL_RUN -> Value.CL_RUN
                        CL_RUT -> Value.CL_RUT
                        CO_CEDULAS -> Value.CO_CEDULAS
                        CO_NIT -> Value.CO_NIT
                        HN_ID -> Value.HN_ID
                        HN_RTN -> Value.HN_RTN
                        IN_LEI -> Value.IN_LEI
                        KR_BRN -> Value.KR_BRN
                        KR_CRN -> Value.KR_CRN
                        KR_RRN -> Value.KR_RRN
                        PASSPORT -> Value.PASSPORT
                        SA_TIN -> Value.SA_TIN
                        SA_VAT -> Value.SA_VAT
                        US_EIN -> Value.US_EIN
                        US_ITIN -> Value.US_ITIN
                        US_SSN -> Value.US_SSN
                        VN_TIN -> Value.VN_TIN
                        else -> Value._UNKNOWN
                    }

                fun known(): Known =
                    when (this) {
                        AR_CUIL -> Known.AR_CUIL
                        AR_CUIT -> Known.AR_CUIT
                        BR_CNPJ -> Known.BR_CNPJ
                        BR_CPF -> Known.BR_CPF
                        CL_RUN -> Known.CL_RUN
                        CL_RUT -> Known.CL_RUT
                        CO_CEDULAS -> Known.CO_CEDULAS
                        CO_NIT -> Known.CO_NIT
                        HN_ID -> Known.HN_ID
                        HN_RTN -> Known.HN_RTN
                        IN_LEI -> Known.IN_LEI
                        KR_BRN -> Known.KR_BRN
                        KR_CRN -> Known.KR_CRN
                        KR_RRN -> Known.KR_RRN
                        PASSPORT -> Known.PASSPORT
                        SA_TIN -> Known.SA_TIN
                        SA_VAT -> Known.SA_VAT
                        US_EIN -> Known.US_EIN
                        US_ITIN -> Known.US_ITIN
                        US_SSN -> Known.US_SSN
                        VN_TIN -> Known.VN_TIN
                        else -> throw ModernTreasuryInvalidDataException("Unknown IdType: $value")
                    }

                fun asString(): String = _value().asStringOrThrow()

                override fun equals(other: Any?): Boolean {
                    if (this === other) {
                        return true
                    }

                    return /* spotless:off */ other is IdType && value == other.value /* spotless:on */
                }

                override fun hashCode() = value.hashCode()

                override fun toString() = value.toString()
            }

            override fun equals(other: Any?): Boolean {
                if (this === other) {
                    return true
                }

                return /* spotless:off */ other is Identification && id == other.id && object_ == other.object_ && liveMode == other.liveMode && createdAt == other.createdAt && updatedAt == other.updatedAt && discardedAt == other.discardedAt && idType == other.idType && issuingCountry == other.issuingCountry && additionalProperties == other.additionalProperties /* spotless:on */
            }

            /* spotless:off */
            private val hashCode: Int by lazy { Objects.hash(id, object_, liveMode, createdAt, updatedAt, discardedAt, idType, issuingCountry, additionalProperties) }
            /* spotless:on */

            override fun hashCode(): Int = hashCode

            override fun toString() =
                "Identification{id=$id, object_=$object_, liveMode=$liveMode, createdAt=$createdAt, updatedAt=$updatedAt, discardedAt=$discardedAt, idType=$idType, issuingCountry=$issuingCountry, additionalProperties=$additionalProperties}"
        }

        class LegalEntityType
        @JsonCreator
        private constructor(
            private val value: JsonField,
        ) : Enum {

            @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value

            companion object {

                val BUSINESS = of("business")

                val INDIVIDUAL = of("individual")

                val JOINT = of("joint")

                fun of(value: String) = LegalEntityType(JsonField.of(value))
            }

            enum class Known {
                BUSINESS,
                INDIVIDUAL,
                JOINT,
            }

            enum class Value {
                BUSINESS,
                INDIVIDUAL,
                JOINT,
                _UNKNOWN,
            }

            fun value(): Value =
                when (this) {
                    BUSINESS -> Value.BUSINESS
                    INDIVIDUAL -> Value.INDIVIDUAL
                    JOINT -> Value.JOINT
                    else -> Value._UNKNOWN
                }

            fun known(): Known =
                when (this) {
                    BUSINESS -> Known.BUSINESS
                    INDIVIDUAL -> Known.INDIVIDUAL
                    JOINT -> Known.JOINT
                    else ->
                        throw ModernTreasuryInvalidDataException("Unknown LegalEntityType: $value")
                }

            fun asString(): String = _value().asStringOrThrow()

            override fun equals(other: Any?): Boolean {
                if (this === other) {
                    return true
                }

                return /* spotless:off */ other is LegalEntityType && value == other.value /* spotless:on */
            }

            override fun hashCode() = value.hashCode()

            override fun toString() = value.toString()
        }

        class LegalStructure
        @JsonCreator
        private constructor(
            private val value: JsonField,
        ) : Enum {

            @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value

            companion object {

                val CORPORATION = of("corporation")

                val LLC = of("llc")

                val NON_PROFIT = of("non_profit")

                val PARTNERSHIP = of("partnership")

                val SOLE_PROPRIETORSHIP = of("sole_proprietorship")

                val TRUST = of("trust")

                fun of(value: String) = LegalStructure(JsonField.of(value))
            }

            enum class Known {
                CORPORATION,
                LLC,
                NON_PROFIT,
                PARTNERSHIP,
                SOLE_PROPRIETORSHIP,
                TRUST,
            }

            enum class Value {
                CORPORATION,
                LLC,
                NON_PROFIT,
                PARTNERSHIP,
                SOLE_PROPRIETORSHIP,
                TRUST,
                _UNKNOWN,
            }

            fun value(): Value =
                when (this) {
                    CORPORATION -> Value.CORPORATION
                    LLC -> Value.LLC
                    NON_PROFIT -> Value.NON_PROFIT
                    PARTNERSHIP -> Value.PARTNERSHIP
                    SOLE_PROPRIETORSHIP -> Value.SOLE_PROPRIETORSHIP
                    TRUST -> Value.TRUST
                    else -> Value._UNKNOWN
                }

            fun known(): Known =
                when (this) {
                    CORPORATION -> Known.CORPORATION
                    LLC -> Known.LLC
                    NON_PROFIT -> Known.NON_PROFIT
                    PARTNERSHIP -> Known.PARTNERSHIP
                    SOLE_PROPRIETORSHIP -> Known.SOLE_PROPRIETORSHIP
                    TRUST -> Known.TRUST
                    else ->
                        throw ModernTreasuryInvalidDataException("Unknown LegalStructure: $value")
                }

            fun asString(): String = _value().asStringOrThrow()

            override fun equals(other: Any?): Boolean {
                if (this === other) {
                    return true
                }

                return /* spotless:off */ other is LegalStructure && value == other.value /* spotless:on */
            }

            override fun hashCode() = value.hashCode()

            override fun toString() = value.toString()
        }

        /**
         * Additional data represented as key-value pairs. Both the key and value must be strings.
         */
        @JsonDeserialize(builder = Metadata.Builder::class)
        @NoAutoDetect
        class Metadata
        private constructor(
            private val additionalProperties: Map,
        ) {

            private var validated: Boolean = false

            @JsonAnyGetter
            @ExcludeMissing
            fun _additionalProperties(): Map = additionalProperties

            fun validate(): Metadata = apply {
                if (!validated) {
                    validated = true
                }
            }

            fun toBuilder() = Builder().from(this)

            companion object {

                fun builder() = Builder()
            }

            class Builder {

                private var additionalProperties: MutableMap = mutableMapOf()

                internal fun from(metadata: Metadata) = apply {
                    additionalProperties(metadata.additionalProperties)
                }

                fun additionalProperties(additionalProperties: Map) = apply {
                    this.additionalProperties.clear()
                    this.additionalProperties.putAll(additionalProperties)
                }

                @JsonAnySetter
                fun putAdditionalProperty(key: String, value: JsonValue) = apply {
                    this.additionalProperties.put(key, value)
                }

                fun putAllAdditionalProperties(additionalProperties: Map) =
                    apply {
                        this.additionalProperties.putAll(additionalProperties)
                    }

                fun build(): Metadata = Metadata(additionalProperties.toImmutable())
            }

            override fun equals(other: Any?): Boolean {
                if (this === other) {
                    return true
                }

                return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */
            }

            /* spotless:off */
            private val hashCode: Int by lazy { Objects.hash(additionalProperties) }
            /* spotless:on */

            override fun hashCode(): Int = hashCode

            override fun toString() = "Metadata{additionalProperties=$additionalProperties}"
        }

        /** A list of phone numbers in E.164 format. */
        @JsonDeserialize(builder = PhoneNumber.Builder::class)
        @NoAutoDetect
        class PhoneNumber
        private constructor(
            private val phoneNumber: JsonField,
            private val additionalProperties: Map,
        ) {

            private var validated: Boolean = false

            fun phoneNumber(): String? = phoneNumber.getNullable("phone_number")

            @JsonProperty("phone_number") @ExcludeMissing fun _phoneNumber() = phoneNumber

            @JsonAnyGetter
            @ExcludeMissing
            fun _additionalProperties(): Map = additionalProperties

            fun validate(): PhoneNumber = apply {
                if (!validated) {
                    phoneNumber()
                    validated = true
                }
            }

            fun toBuilder() = Builder().from(this)

            companion object {

                fun builder() = Builder()
            }

            class Builder {

                private var phoneNumber: JsonField = JsonMissing.of()
                private var additionalProperties: MutableMap = mutableMapOf()

                internal fun from(phoneNumber: PhoneNumber) = apply {
                    this.phoneNumber = phoneNumber.phoneNumber
                    additionalProperties(phoneNumber.additionalProperties)
                }

                fun phoneNumber(phoneNumber: String) = phoneNumber(JsonField.of(phoneNumber))

                @JsonProperty("phone_number")
                @ExcludeMissing
                fun phoneNumber(phoneNumber: JsonField) = apply {
                    this.phoneNumber = phoneNumber
                }

                fun additionalProperties(additionalProperties: Map) = apply {
                    this.additionalProperties.clear()
                    this.additionalProperties.putAll(additionalProperties)
                }

                @JsonAnySetter
                fun putAdditionalProperty(key: String, value: JsonValue) = apply {
                    this.additionalProperties.put(key, value)
                }

                fun putAllAdditionalProperties(additionalProperties: Map) =
                    apply {
                        this.additionalProperties.putAll(additionalProperties)
                    }

                fun build(): PhoneNumber =
                    PhoneNumber(phoneNumber, additionalProperties.toImmutable())
            }

            override fun equals(other: Any?): Boolean {
                if (this === other) {
                    return true
                }

                return /* spotless:off */ other is PhoneNumber && phoneNumber == other.phoneNumber && additionalProperties == other.additionalProperties /* spotless:on */
            }

            /* spotless:off */
            private val hashCode: Int by lazy { Objects.hash(phoneNumber, additionalProperties) }
            /* spotless:on */

            override fun hashCode(): Int = hashCode

            override fun toString() =
                "PhoneNumber{phoneNumber=$phoneNumber, additionalProperties=$additionalProperties}"
        }

        class RiskRating
        @JsonCreator
        private constructor(
            private val value: JsonField,
        ) : Enum {

            @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value

            companion object {

                val LOW = of("low")

                val MEDIUM = of("medium")

                val HIGH = of("high")

                fun of(value: String) = RiskRating(JsonField.of(value))
            }

            enum class Known {
                LOW,
                MEDIUM,
                HIGH,
            }

            enum class Value {
                LOW,
                MEDIUM,
                HIGH,
                _UNKNOWN,
            }

            fun value(): Value =
                when (this) {
                    LOW -> Value.LOW
                    MEDIUM -> Value.MEDIUM
                    HIGH -> Value.HIGH
                    else -> Value._UNKNOWN
                }

            fun known(): Known =
                when (this) {
                    LOW -> Known.LOW
                    MEDIUM -> Known.MEDIUM
                    HIGH -> Known.HIGH
                    else -> throw ModernTreasuryInvalidDataException("Unknown RiskRating: $value")
                }

            fun asString(): String = _value().asStringOrThrow()

            override fun equals(other: Any?): Boolean {
                if (this === other) {
                    return true
                }

                return /* spotless:off */ other is RiskRating && value == other.value /* spotless:on */
            }

            override fun hashCode() = value.hashCode()

            override fun toString() = value.toString()
        }

        override fun equals(other: Any?): Boolean {
            if (this === other) {
                return true
            }

            return /* spotless:off */ other is ChildLegalEntity && id == other.id && object_ == other.object_ && liveMode == other.liveMode && createdAt == other.createdAt && updatedAt == other.updatedAt && discardedAt == other.discardedAt && legalEntityType == other.legalEntityType && riskRating == other.riskRating && prefix == other.prefix && firstName == other.firstName && middleName == other.middleName && lastName == other.lastName && suffix == other.suffix && preferredName == other.preferredName && citizenshipCountry == other.citizenshipCountry && politicallyExposedPerson == other.politicallyExposedPerson && dateOfBirth == other.dateOfBirth && dateFormed == other.dateFormed && businessName == other.businessName && doingBusinessAsNames == other.doingBusinessAsNames && legalStructure == other.legalStructure && phoneNumbers == other.phoneNumbers && email == other.email && website == other.website && metadata == other.metadata && bankSettings == other.bankSettings && wealthAndEmploymentDetails == other.wealthAndEmploymentDetails && addresses == other.addresses && identifications == other.identifications && additionalProperties == other.additionalProperties /* spotless:on */
        }

        /* spotless:off */
        private val hashCode: Int by lazy { Objects.hash(id, object_, liveMode, createdAt, updatedAt, discardedAt, legalEntityType, riskRating, prefix, firstName, middleName, lastName, suffix, preferredName, citizenshipCountry, politicallyExposedPerson, dateOfBirth, dateFormed, businessName, doingBusinessAsNames, legalStructure, phoneNumbers, email, website, metadata, bankSettings, wealthAndEmploymentDetails, addresses, identifications, additionalProperties) }
        /* spotless:on */

        override fun hashCode(): Int = hashCode

        override fun toString() =
            "ChildLegalEntity{id=$id, object_=$object_, liveMode=$liveMode, createdAt=$createdAt, updatedAt=$updatedAt, discardedAt=$discardedAt, legalEntityType=$legalEntityType, riskRating=$riskRating, prefix=$prefix, firstName=$firstName, middleName=$middleName, lastName=$lastName, suffix=$suffix, preferredName=$preferredName, citizenshipCountry=$citizenshipCountry, politicallyExposedPerson=$politicallyExposedPerson, dateOfBirth=$dateOfBirth, dateFormed=$dateFormed, businessName=$businessName, doingBusinessAsNames=$doingBusinessAsNames, legalStructure=$legalStructure, phoneNumbers=$phoneNumbers, email=$email, website=$website, metadata=$metadata, bankSettings=$bankSettings, wealthAndEmploymentDetails=$wealthAndEmploymentDetails, addresses=$addresses, identifications=$identifications, additionalProperties=$additionalProperties}"
    }

    class RelationshipType
    @JsonCreator
    private constructor(
        private val value: JsonField,
    ) : Enum {

        @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value

        companion object {

            val BENEFICIAL_OWNER = of("beneficial_owner")

            val CONTROL_PERSON = of("control_person")

            fun of(value: String) = RelationshipType(JsonField.of(value))
        }

        enum class Known {
            BENEFICIAL_OWNER,
            CONTROL_PERSON,
        }

        enum class Value {
            BENEFICIAL_OWNER,
            CONTROL_PERSON,
            _UNKNOWN,
        }

        fun value(): Value =
            when (this) {
                BENEFICIAL_OWNER -> Value.BENEFICIAL_OWNER
                CONTROL_PERSON -> Value.CONTROL_PERSON
                else -> Value._UNKNOWN
            }

        fun known(): Known =
            when (this) {
                BENEFICIAL_OWNER -> Known.BENEFICIAL_OWNER
                CONTROL_PERSON -> Known.CONTROL_PERSON
                else -> throw ModernTreasuryInvalidDataException("Unknown RelationshipType: $value")
            }

        fun asString(): String = _value().asStringOrThrow()

        override fun equals(other: Any?): Boolean {
            if (this === other) {
                return true
            }

            return /* spotless:off */ other is RelationshipType && value == other.value /* spotless:on */
        }

        override fun hashCode() = value.hashCode()

        override fun toString() = value.toString()
    }

    override fun equals(other: Any?): Boolean {
        if (this === other) {
            return true
        }

        return /* spotless:off */ other is LegalEntityAssociation && id == other.id && object_ == other.object_ && liveMode == other.liveMode && createdAt == other.createdAt && updatedAt == other.updatedAt && discardedAt == other.discardedAt && parentLegalEntityId == other.parentLegalEntityId && relationshipTypes == other.relationshipTypes && title == other.title && ownershipPercentage == other.ownershipPercentage && childLegalEntity == other.childLegalEntity && additionalProperties == other.additionalProperties /* spotless:on */
    }

    /* spotless:off */
    private val hashCode: Int by lazy { Objects.hash(id, object_, liveMode, createdAt, updatedAt, discardedAt, parentLegalEntityId, relationshipTypes, title, ownershipPercentage, childLegalEntity, additionalProperties) }
    /* spotless:on */

    override fun hashCode(): Int = hashCode

    override fun toString() =
        "LegalEntityAssociation{id=$id, object_=$object_, liveMode=$liveMode, createdAt=$createdAt, updatedAt=$updatedAt, discardedAt=$discardedAt, parentLegalEntityId=$parentLegalEntityId, relationshipTypes=$relationshipTypes, title=$title, ownershipPercentage=$ownershipPercentage, childLegalEntity=$childLegalEntity, additionalProperties=$additionalProperties}"
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy