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

com.lithic.api.models.ShippingAddress.kt Maven / Gradle / Ivy

Go to download

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.annotation.JsonAnyGetter
import com.fasterxml.jackson.annotation.JsonAnySetter
import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import com.lithic.api.core.ExcludeMissing
import com.lithic.api.core.JsonField
import com.lithic.api.core.JsonMissing
import com.lithic.api.core.JsonValue
import com.lithic.api.core.NoAutoDetect
import com.lithic.api.core.toImmutable
import java.util.Objects

@JsonDeserialize(builder = ShippingAddress.Builder::class)
@NoAutoDetect
class ShippingAddress
private constructor(
    private val address1: JsonField,
    private val address2: JsonField,
    private val city: JsonField,
    private val country: JsonField,
    private val email: JsonField,
    private val firstName: JsonField,
    private val lastName: JsonField,
    private val line2Text: JsonField,
    private val phoneNumber: JsonField,
    private val postalCode: JsonField,
    private val state: JsonField,
    private val additionalProperties: Map,
) {

    private var validated: Boolean = false

    /** Valid USPS routable address. */
    fun address1(): String = address1.getRequired("address1")

    /** Unit number (if applicable). */
    fun address2(): String? = address2.getNullable("address2")

    /** City */
    fun city(): String = city.getRequired("city")

    /** Uppercase ISO 3166-1 alpha-3 three character abbreviation. */
    fun country(): String = country.getRequired("country")

    /**
     * Email address to be contacted for expedited shipping process purposes. Required if
     * `shipping_method` is `EXPEDITED`.
     */
    fun email(): String? = email.getNullable("email")

    /**
     * Customer's first name. This will be the first name printed on the physical card. The combined
     * length of `first_name` and `last_name` may not exceed 25 characters.
     */
    fun firstName(): String = firstName.getRequired("first_name")

    /**
     * Customer's surname (family name). This will be the last name printed on the physical card.
     * The combined length of `first_name` and `last_name` may not exceed 25 characters.
     */
    fun lastName(): String = lastName.getRequired("last_name")

    /**
     * Text to be printed on line two of the physical card. Use of this field requires additional
     * permissions.
     */
    fun line2Text(): String? = line2Text.getNullable("line2_text")

    /**
     * Cardholder's phone number in E.164 format to be contacted for expedited shipping process
     * purposes. Required if `shipping_method` is `EXPEDITED`.
     */
    fun phoneNumber(): String? = phoneNumber.getNullable("phone_number")

    /**
     * Postal code (formerly zipcode). For US addresses, either five-digit postal code or nine-digit
     * postal code (ZIP+4) using the format 12345-1234.
     */
    fun postalCode(): String = postalCode.getRequired("postal_code")

    /**
     * Uppercase ISO 3166-2 two character abbreviation for US and CA. Optional with a limit of 24
     * characters for other countries.
     */
    fun state(): String = state.getRequired("state")

    /** Valid USPS routable address. */
    @JsonProperty("address1") @ExcludeMissing fun _address1() = address1

    /** Unit number (if applicable). */
    @JsonProperty("address2") @ExcludeMissing fun _address2() = address2

    /** City */
    @JsonProperty("city") @ExcludeMissing fun _city() = city

    /** Uppercase ISO 3166-1 alpha-3 three character abbreviation. */
    @JsonProperty("country") @ExcludeMissing fun _country() = country

    /**
     * Email address to be contacted for expedited shipping process purposes. Required if
     * `shipping_method` is `EXPEDITED`.
     */
    @JsonProperty("email") @ExcludeMissing fun _email() = email

    /**
     * Customer's first name. This will be the first name printed on the physical card. The combined
     * length of `first_name` and `last_name` may not exceed 25 characters.
     */
    @JsonProperty("first_name") @ExcludeMissing fun _firstName() = firstName

    /**
     * Customer's surname (family name). This will be the last name printed on the physical card.
     * The combined length of `first_name` and `last_name` may not exceed 25 characters.
     */
    @JsonProperty("last_name") @ExcludeMissing fun _lastName() = lastName

    /**
     * Text to be printed on line two of the physical card. Use of this field requires additional
     * permissions.
     */
    @JsonProperty("line2_text") @ExcludeMissing fun _line2Text() = line2Text

    /**
     * Cardholder's phone number in E.164 format to be contacted for expedited shipping process
     * purposes. Required if `shipping_method` is `EXPEDITED`.
     */
    @JsonProperty("phone_number") @ExcludeMissing fun _phoneNumber() = phoneNumber

    /**
     * Postal code (formerly zipcode). For US addresses, either five-digit postal code or nine-digit
     * postal code (ZIP+4) using the format 12345-1234.
     */
    @JsonProperty("postal_code") @ExcludeMissing fun _postalCode() = postalCode

    /**
     * Uppercase ISO 3166-2 two character abbreviation for US and CA. Optional with a limit of 24
     * characters for other countries.
     */
    @JsonProperty("state") @ExcludeMissing fun _state() = state

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

    fun validate(): ShippingAddress = apply {
        if (!validated) {
            address1()
            address2()
            city()
            country()
            email()
            firstName()
            lastName()
            line2Text()
            phoneNumber()
            postalCode()
            state()
            validated = true
        }
    }

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

    companion object {

        fun builder() = Builder()
    }

    class Builder {

        private var address1: JsonField = JsonMissing.of()
        private var address2: JsonField = JsonMissing.of()
        private var city: JsonField = JsonMissing.of()
        private var country: JsonField = JsonMissing.of()
        private var email: JsonField = JsonMissing.of()
        private var firstName: JsonField = JsonMissing.of()
        private var lastName: JsonField = JsonMissing.of()
        private var line2Text: JsonField = JsonMissing.of()
        private var phoneNumber: JsonField = JsonMissing.of()
        private var postalCode: JsonField = JsonMissing.of()
        private var state: JsonField = JsonMissing.of()
        private var additionalProperties: MutableMap = mutableMapOf()

        internal fun from(shippingAddress: ShippingAddress) = apply {
            this.address1 = shippingAddress.address1
            this.address2 = shippingAddress.address2
            this.city = shippingAddress.city
            this.country = shippingAddress.country
            this.email = shippingAddress.email
            this.firstName = shippingAddress.firstName
            this.lastName = shippingAddress.lastName
            this.line2Text = shippingAddress.line2Text
            this.phoneNumber = shippingAddress.phoneNumber
            this.postalCode = shippingAddress.postalCode
            this.state = shippingAddress.state
            additionalProperties(shippingAddress.additionalProperties)
        }

        /** Valid USPS routable address. */
        fun address1(address1: String) = address1(JsonField.of(address1))

        /** Valid USPS routable address. */
        @JsonProperty("address1")
        @ExcludeMissing
        fun address1(address1: JsonField) = apply { this.address1 = address1 }

        /** Unit number (if applicable). */
        fun address2(address2: String) = address2(JsonField.of(address2))

        /** Unit number (if applicable). */
        @JsonProperty("address2")
        @ExcludeMissing
        fun address2(address2: JsonField) = apply { this.address2 = address2 }

        /** City */
        fun city(city: String) = city(JsonField.of(city))

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

        /** Uppercase ISO 3166-1 alpha-3 three character abbreviation. */
        fun country(country: String) = country(JsonField.of(country))

        /** Uppercase ISO 3166-1 alpha-3 three character abbreviation. */
        @JsonProperty("country")
        @ExcludeMissing
        fun country(country: JsonField) = apply { this.country = country }

        /**
         * Email address to be contacted for expedited shipping process purposes. Required if
         * `shipping_method` is `EXPEDITED`.
         */
        fun email(email: String) = email(JsonField.of(email))

        /**
         * Email address to be contacted for expedited shipping process purposes. Required if
         * `shipping_method` is `EXPEDITED`.
         */
        @JsonProperty("email")
        @ExcludeMissing
        fun email(email: JsonField) = apply { this.email = email }

        /**
         * Customer's first name. This will be the first name printed on the physical card. The
         * combined length of `first_name` and `last_name` may not exceed 25 characters.
         */
        fun firstName(firstName: String) = firstName(JsonField.of(firstName))

        /**
         * Customer's first name. This will be the first name printed on the physical card. The
         * combined length of `first_name` and `last_name` may not exceed 25 characters.
         */
        @JsonProperty("first_name")
        @ExcludeMissing
        fun firstName(firstName: JsonField) = apply { this.firstName = firstName }

        /**
         * Customer's surname (family name). This will be the last name printed on the physical
         * card. The combined length of `first_name` and `last_name` may not exceed 25 characters.
         */
        fun lastName(lastName: String) = lastName(JsonField.of(lastName))

        /**
         * Customer's surname (family name). This will be the last name printed on the physical
         * card. The combined length of `first_name` and `last_name` may not exceed 25 characters.
         */
        @JsonProperty("last_name")
        @ExcludeMissing
        fun lastName(lastName: JsonField) = apply { this.lastName = lastName }

        /**
         * Text to be printed on line two of the physical card. Use of this field requires
         * additional permissions.
         */
        fun line2Text(line2Text: String) = line2Text(JsonField.of(line2Text))

        /**
         * Text to be printed on line two of the physical card. Use of this field requires
         * additional permissions.
         */
        @JsonProperty("line2_text")
        @ExcludeMissing
        fun line2Text(line2Text: JsonField) = apply { this.line2Text = line2Text }

        /**
         * Cardholder's phone number in E.164 format to be contacted for expedited shipping process
         * purposes. Required if `shipping_method` is `EXPEDITED`.
         */
        fun phoneNumber(phoneNumber: String) = phoneNumber(JsonField.of(phoneNumber))

        /**
         * Cardholder's phone number in E.164 format to be contacted for expedited shipping process
         * purposes. Required if `shipping_method` is `EXPEDITED`.
         */
        @JsonProperty("phone_number")
        @ExcludeMissing
        fun phoneNumber(phoneNumber: JsonField) = apply { this.phoneNumber = phoneNumber }

        /**
         * Postal code (formerly zipcode). For US addresses, either five-digit postal code or
         * nine-digit postal code (ZIP+4) using the format 12345-1234.
         */
        fun postalCode(postalCode: String) = postalCode(JsonField.of(postalCode))

        /**
         * Postal code (formerly zipcode). For US addresses, either five-digit postal code or
         * nine-digit postal code (ZIP+4) using the format 12345-1234.
         */
        @JsonProperty("postal_code")
        @ExcludeMissing
        fun postalCode(postalCode: JsonField) = apply { this.postalCode = postalCode }

        /**
         * Uppercase ISO 3166-2 two character abbreviation for US and CA. Optional with a limit of
         * 24 characters for other countries.
         */
        fun state(state: String) = state(JsonField.of(state))

        /**
         * Uppercase ISO 3166-2 two character abbreviation for US and CA. Optional with a limit of
         * 24 characters for other countries.
         */
        @JsonProperty("state")
        @ExcludeMissing
        fun state(state: JsonField) = apply { this.state = state }

        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(): ShippingAddress =
            ShippingAddress(
                address1,
                address2,
                city,
                country,
                email,
                firstName,
                lastName,
                line2Text,
                phoneNumber,
                postalCode,
                state,
                additionalProperties.toImmutable(),
            )
    }

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

        return /* spotless:off */ other is ShippingAddress && this.address1 == other.address1 && this.address2 == other.address2 && this.city == other.city && this.country == other.country && this.email == other.email && this.firstName == other.firstName && this.lastName == other.lastName && this.line2Text == other.line2Text && this.phoneNumber == other.phoneNumber && this.postalCode == other.postalCode && this.state == other.state && this.additionalProperties == other.additionalProperties /* spotless:on */
    }

    private var hashCode: Int = 0

    override fun hashCode(): Int {
        if (hashCode == 0) {
            hashCode = /* spotless:off */ Objects.hash(address1, address2, city, country, email, firstName, lastName, line2Text, phoneNumber, postalCode, state, additionalProperties) /* spotless:on */
        }
        return hashCode
    }

    override fun toString() =
        "ShippingAddress{address1=$address1, address2=$address2, city=$city, country=$country, email=$email, firstName=$firstName, lastName=$lastName, line2Text=$line2Text, phoneNumber=$phoneNumber, postalCode=$postalCode, state=$state, additionalProperties=$additionalProperties}"
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy