|
| 1 | +package com.lithic.api.models |
| 2 | + |
| 3 | +import com.fasterxml.jackson.annotation.JsonAnyGetter |
| 4 | +import com.fasterxml.jackson.annotation.JsonAnySetter |
| 5 | +import com.fasterxml.jackson.annotation.JsonProperty |
| 6 | +import com.fasterxml.jackson.databind.annotation.JsonDeserialize |
| 7 | +import com.lithic.api.core.ExcludeMissing |
| 8 | +import com.lithic.api.core.JsonField |
| 9 | +import com.lithic.api.core.JsonMissing |
| 10 | +import com.lithic.api.core.JsonValue |
| 11 | +import com.lithic.api.core.NoAutoDetect |
| 12 | +import com.lithic.api.core.toUnmodifiable |
| 13 | +import java.util.Objects |
| 14 | +import java.util.Optional |
| 15 | + |
| 16 | +/** |
| 17 | + * Address used during Address Verification Service (AVS) checks during transactions if enabled via |
| 18 | + * Auth Rules. |
| 19 | + */ |
| 20 | +@JsonDeserialize(builder = ExternalBankAccountAddress.Builder::class) |
| 21 | +@NoAutoDetect |
| 22 | +class ExternalBankAccountAddress |
| 23 | +private constructor( |
| 24 | + private val address1: JsonField<String>, |
| 25 | + private val address2: JsonField<String>, |
| 26 | + private val city: JsonField<String>, |
| 27 | + private val state: JsonField<String>, |
| 28 | + private val postalCode: JsonField<String>, |
| 29 | + private val country: JsonField<String>, |
| 30 | + private val additionalProperties: Map<String, JsonValue>, |
| 31 | +) { |
| 32 | + |
| 33 | + private var validated: Boolean = false |
| 34 | + |
| 35 | + private var hashCode: Int = 0 |
| 36 | + |
| 37 | + fun address1(): String = address1.getRequired("address1") |
| 38 | + |
| 39 | + fun address2(): Optional<String> = Optional.ofNullable(address2.getNullable("address2")) |
| 40 | + |
| 41 | + fun city(): String = city.getRequired("city") |
| 42 | + |
| 43 | + fun state(): String = state.getRequired("state") |
| 44 | + |
| 45 | + fun postalCode(): String = postalCode.getRequired("postal_code") |
| 46 | + |
| 47 | + fun country(): String = country.getRequired("country") |
| 48 | + |
| 49 | + @JsonProperty("address1") @ExcludeMissing fun _address1() = address1 |
| 50 | + |
| 51 | + @JsonProperty("address2") @ExcludeMissing fun _address2() = address2 |
| 52 | + |
| 53 | + @JsonProperty("city") @ExcludeMissing fun _city() = city |
| 54 | + |
| 55 | + @JsonProperty("state") @ExcludeMissing fun _state() = state |
| 56 | + |
| 57 | + @JsonProperty("postal_code") @ExcludeMissing fun _postalCode() = postalCode |
| 58 | + |
| 59 | + @JsonProperty("country") @ExcludeMissing fun _country() = country |
| 60 | + |
| 61 | + @JsonAnyGetter |
| 62 | + @ExcludeMissing |
| 63 | + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties |
| 64 | + |
| 65 | + fun validate(): ExternalBankAccountAddress = apply { |
| 66 | + if (!validated) { |
| 67 | + address1() |
| 68 | + address2() |
| 69 | + city() |
| 70 | + state() |
| 71 | + postalCode() |
| 72 | + country() |
| 73 | + validated = true |
| 74 | + } |
| 75 | + } |
| 76 | + |
| 77 | + fun toBuilder() = Builder().from(this) |
| 78 | + |
| 79 | + override fun equals(other: Any?): Boolean { |
| 80 | + if (this === other) { |
| 81 | + return true |
| 82 | + } |
| 83 | + |
| 84 | + return other is ExternalBankAccountAddress && |
| 85 | + this.address1 == other.address1 && |
| 86 | + this.address2 == other.address2 && |
| 87 | + this.city == other.city && |
| 88 | + this.state == other.state && |
| 89 | + this.postalCode == other.postalCode && |
| 90 | + this.country == other.country && |
| 91 | + this.additionalProperties == other.additionalProperties |
| 92 | + } |
| 93 | + |
| 94 | + override fun hashCode(): Int { |
| 95 | + if (hashCode == 0) { |
| 96 | + hashCode = |
| 97 | + Objects.hash( |
| 98 | + address1, |
| 99 | + address2, |
| 100 | + city, |
| 101 | + state, |
| 102 | + postalCode, |
| 103 | + country, |
| 104 | + additionalProperties, |
| 105 | + ) |
| 106 | + } |
| 107 | + return hashCode |
| 108 | + } |
| 109 | + |
| 110 | + override fun toString() = |
| 111 | + "ExternalBankAccountAddress{address1=$address1, address2=$address2, city=$city, state=$state, postalCode=$postalCode, country=$country, additionalProperties=$additionalProperties}" |
| 112 | + |
| 113 | + companion object { |
| 114 | + |
| 115 | + @JvmStatic fun builder() = Builder() |
| 116 | + } |
| 117 | + |
| 118 | + class Builder { |
| 119 | + |
| 120 | + private var address1: JsonField<String> = JsonMissing.of() |
| 121 | + private var address2: JsonField<String> = JsonMissing.of() |
| 122 | + private var city: JsonField<String> = JsonMissing.of() |
| 123 | + private var state: JsonField<String> = JsonMissing.of() |
| 124 | + private var postalCode: JsonField<String> = JsonMissing.of() |
| 125 | + private var country: JsonField<String> = JsonMissing.of() |
| 126 | + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() |
| 127 | + |
| 128 | + @JvmSynthetic |
| 129 | + internal fun from(externalBankAccountAddress: ExternalBankAccountAddress) = apply { |
| 130 | + this.address1 = externalBankAccountAddress.address1 |
| 131 | + this.address2 = externalBankAccountAddress.address2 |
| 132 | + this.city = externalBankAccountAddress.city |
| 133 | + this.state = externalBankAccountAddress.state |
| 134 | + this.postalCode = externalBankAccountAddress.postalCode |
| 135 | + this.country = externalBankAccountAddress.country |
| 136 | + additionalProperties(externalBankAccountAddress.additionalProperties) |
| 137 | + } |
| 138 | + |
| 139 | + fun address1(address1: String) = address1(JsonField.of(address1)) |
| 140 | + |
| 141 | + @JsonProperty("address1") |
| 142 | + @ExcludeMissing |
| 143 | + fun address1(address1: JsonField<String>) = apply { this.address1 = address1 } |
| 144 | + |
| 145 | + fun address2(address2: String) = address2(JsonField.of(address2)) |
| 146 | + |
| 147 | + @JsonProperty("address2") |
| 148 | + @ExcludeMissing |
| 149 | + fun address2(address2: JsonField<String>) = apply { this.address2 = address2 } |
| 150 | + |
| 151 | + fun city(city: String) = city(JsonField.of(city)) |
| 152 | + |
| 153 | + @JsonProperty("city") |
| 154 | + @ExcludeMissing |
| 155 | + fun city(city: JsonField<String>) = apply { this.city = city } |
| 156 | + |
| 157 | + fun state(state: String) = state(JsonField.of(state)) |
| 158 | + |
| 159 | + @JsonProperty("state") |
| 160 | + @ExcludeMissing |
| 161 | + fun state(state: JsonField<String>) = apply { this.state = state } |
| 162 | + |
| 163 | + fun postalCode(postalCode: String) = postalCode(JsonField.of(postalCode)) |
| 164 | + |
| 165 | + @JsonProperty("postal_code") |
| 166 | + @ExcludeMissing |
| 167 | + fun postalCode(postalCode: JsonField<String>) = apply { this.postalCode = postalCode } |
| 168 | + |
| 169 | + fun country(country: String) = country(JsonField.of(country)) |
| 170 | + |
| 171 | + @JsonProperty("country") |
| 172 | + @ExcludeMissing |
| 173 | + fun country(country: JsonField<String>) = apply { this.country = country } |
| 174 | + |
| 175 | + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { |
| 176 | + this.additionalProperties.clear() |
| 177 | + this.additionalProperties.putAll(additionalProperties) |
| 178 | + } |
| 179 | + |
| 180 | + @JsonAnySetter |
| 181 | + fun putAdditionalProperty(key: String, value: JsonValue) = apply { |
| 182 | + this.additionalProperties.put(key, value) |
| 183 | + } |
| 184 | + |
| 185 | + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { |
| 186 | + this.additionalProperties.putAll(additionalProperties) |
| 187 | + } |
| 188 | + |
| 189 | + fun build(): ExternalBankAccountAddress = |
| 190 | + ExternalBankAccountAddress( |
| 191 | + address1, |
| 192 | + address2, |
| 193 | + city, |
| 194 | + state, |
| 195 | + postalCode, |
| 196 | + country, |
| 197 | + additionalProperties.toUnmodifiable(), |
| 198 | + ) |
| 199 | + } |
| 200 | +} |
0 commit comments