|
| 1 | +// File generated from our OpenAPI spec by Stainless. |
| 2 | + |
| 3 | +package com.tryfinch.api.models |
| 4 | + |
| 5 | +import com.fasterxml.jackson.annotation.JsonAnyGetter |
| 6 | +import com.fasterxml.jackson.annotation.JsonAnySetter |
| 7 | +import com.fasterxml.jackson.annotation.JsonCreator |
| 8 | +import com.fasterxml.jackson.annotation.JsonProperty |
| 9 | +import com.fasterxml.jackson.databind.annotation.JsonDeserialize |
| 10 | +import com.tryfinch.api.core.ExcludeMissing |
| 11 | +import com.tryfinch.api.core.JsonField |
| 12 | +import com.tryfinch.api.core.JsonMissing |
| 13 | +import com.tryfinch.api.core.JsonValue |
| 14 | +import com.tryfinch.api.core.NoAutoDetect |
| 15 | +import com.tryfinch.api.core.toUnmodifiable |
| 16 | +import com.tryfinch.api.errors.FinchInvalidDataException |
| 17 | +import java.util.Objects |
| 18 | + |
| 19 | +@JsonDeserialize(builder = AccountCreateResponse.Builder::class) |
| 20 | +@NoAutoDetect |
| 21 | +class AccountCreateResponse |
| 22 | +private constructor( |
| 23 | + private val companyId: JsonField<String>, |
| 24 | + private val providerId: JsonField<String>, |
| 25 | + private val accountId: JsonField<String>, |
| 26 | + private val authenticationType: JsonField<AuthenticationType>, |
| 27 | + private val products: JsonField<List<String>>, |
| 28 | + private val accessToken: JsonField<String>, |
| 29 | + private val additionalProperties: Map<String, JsonValue>, |
| 30 | +) { |
| 31 | + |
| 32 | + private var validated: Boolean = false |
| 33 | + |
| 34 | + private var hashCode: Int = 0 |
| 35 | + |
| 36 | + fun companyId(): String = companyId.getRequired("company_id") |
| 37 | + |
| 38 | + fun providerId(): String = providerId.getRequired("provider_id") |
| 39 | + |
| 40 | + fun accountId(): String = accountId.getRequired("account_id") |
| 41 | + |
| 42 | + fun authenticationType(): AuthenticationType = |
| 43 | + authenticationType.getRequired("authentication_type") |
| 44 | + |
| 45 | + fun products(): List<String> = products.getRequired("products") |
| 46 | + |
| 47 | + fun accessToken(): String = accessToken.getRequired("access_token") |
| 48 | + |
| 49 | + @JsonProperty("company_id") @ExcludeMissing fun _companyId() = companyId |
| 50 | + |
| 51 | + @JsonProperty("provider_id") @ExcludeMissing fun _providerId() = providerId |
| 52 | + |
| 53 | + @JsonProperty("account_id") @ExcludeMissing fun _accountId() = accountId |
| 54 | + |
| 55 | + @JsonProperty("authentication_type") |
| 56 | + @ExcludeMissing |
| 57 | + fun _authenticationType() = authenticationType |
| 58 | + |
| 59 | + @JsonProperty("products") @ExcludeMissing fun _products() = products |
| 60 | + |
| 61 | + @JsonProperty("access_token") @ExcludeMissing fun _accessToken() = accessToken |
| 62 | + |
| 63 | + @JsonAnyGetter |
| 64 | + @ExcludeMissing |
| 65 | + fun _additionalProperties(): Map<String, JsonValue> = additionalProperties |
| 66 | + |
| 67 | + fun validate(): AccountCreateResponse = apply { |
| 68 | + if (!validated) { |
| 69 | + companyId() |
| 70 | + providerId() |
| 71 | + accountId() |
| 72 | + authenticationType() |
| 73 | + products() |
| 74 | + accessToken() |
| 75 | + validated = true |
| 76 | + } |
| 77 | + } |
| 78 | + |
| 79 | + fun toBuilder() = Builder().from(this) |
| 80 | + |
| 81 | + override fun equals(other: Any?): Boolean { |
| 82 | + if (this === other) { |
| 83 | + return true |
| 84 | + } |
| 85 | + |
| 86 | + return other is AccountCreateResponse && |
| 87 | + this.companyId == other.companyId && |
| 88 | + this.providerId == other.providerId && |
| 89 | + this.accountId == other.accountId && |
| 90 | + this.authenticationType == other.authenticationType && |
| 91 | + this.products == other.products && |
| 92 | + this.accessToken == other.accessToken && |
| 93 | + this.additionalProperties == other.additionalProperties |
| 94 | + } |
| 95 | + |
| 96 | + override fun hashCode(): Int { |
| 97 | + if (hashCode == 0) { |
| 98 | + hashCode = |
| 99 | + Objects.hash( |
| 100 | + companyId, |
| 101 | + providerId, |
| 102 | + accountId, |
| 103 | + authenticationType, |
| 104 | + products, |
| 105 | + accessToken, |
| 106 | + additionalProperties, |
| 107 | + ) |
| 108 | + } |
| 109 | + return hashCode |
| 110 | + } |
| 111 | + |
| 112 | + override fun toString() = |
| 113 | + "AccountCreateResponse{companyId=$companyId, providerId=$providerId, accountId=$accountId, authenticationType=$authenticationType, products=$products, accessToken=$accessToken, additionalProperties=$additionalProperties}" |
| 114 | + |
| 115 | + companion object { |
| 116 | + |
| 117 | + @JvmStatic fun builder() = Builder() |
| 118 | + } |
| 119 | + |
| 120 | + class Builder { |
| 121 | + |
| 122 | + private var companyId: JsonField<String> = JsonMissing.of() |
| 123 | + private var providerId: JsonField<String> = JsonMissing.of() |
| 124 | + private var accountId: JsonField<String> = JsonMissing.of() |
| 125 | + private var authenticationType: JsonField<AuthenticationType> = JsonMissing.of() |
| 126 | + private var products: JsonField<List<String>> = JsonMissing.of() |
| 127 | + private var accessToken: JsonField<String> = JsonMissing.of() |
| 128 | + private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf() |
| 129 | + |
| 130 | + @JvmSynthetic |
| 131 | + internal fun from(accountCreateResponse: AccountCreateResponse) = apply { |
| 132 | + this.companyId = accountCreateResponse.companyId |
| 133 | + this.providerId = accountCreateResponse.providerId |
| 134 | + this.accountId = accountCreateResponse.accountId |
| 135 | + this.authenticationType = accountCreateResponse.authenticationType |
| 136 | + this.products = accountCreateResponse.products |
| 137 | + this.accessToken = accountCreateResponse.accessToken |
| 138 | + additionalProperties(accountCreateResponse.additionalProperties) |
| 139 | + } |
| 140 | + |
| 141 | + fun companyId(companyId: String) = companyId(JsonField.of(companyId)) |
| 142 | + |
| 143 | + @JsonProperty("company_id") |
| 144 | + @ExcludeMissing |
| 145 | + fun companyId(companyId: JsonField<String>) = apply { this.companyId = companyId } |
| 146 | + |
| 147 | + fun providerId(providerId: String) = providerId(JsonField.of(providerId)) |
| 148 | + |
| 149 | + @JsonProperty("provider_id") |
| 150 | + @ExcludeMissing |
| 151 | + fun providerId(providerId: JsonField<String>) = apply { this.providerId = providerId } |
| 152 | + |
| 153 | + fun accountId(accountId: String) = accountId(JsonField.of(accountId)) |
| 154 | + |
| 155 | + @JsonProperty("account_id") |
| 156 | + @ExcludeMissing |
| 157 | + fun accountId(accountId: JsonField<String>) = apply { this.accountId = accountId } |
| 158 | + |
| 159 | + fun authenticationType(authenticationType: AuthenticationType) = |
| 160 | + authenticationType(JsonField.of(authenticationType)) |
| 161 | + |
| 162 | + @JsonProperty("authentication_type") |
| 163 | + @ExcludeMissing |
| 164 | + fun authenticationType(authenticationType: JsonField<AuthenticationType>) = apply { |
| 165 | + this.authenticationType = authenticationType |
| 166 | + } |
| 167 | + |
| 168 | + fun products(products: List<String>) = products(JsonField.of(products)) |
| 169 | + |
| 170 | + @JsonProperty("products") |
| 171 | + @ExcludeMissing |
| 172 | + fun products(products: JsonField<List<String>>) = apply { this.products = products } |
| 173 | + |
| 174 | + fun accessToken(accessToken: String) = accessToken(JsonField.of(accessToken)) |
| 175 | + |
| 176 | + @JsonProperty("access_token") |
| 177 | + @ExcludeMissing |
| 178 | + fun accessToken(accessToken: JsonField<String>) = apply { this.accessToken = accessToken } |
| 179 | + |
| 180 | + fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply { |
| 181 | + this.additionalProperties.clear() |
| 182 | + this.additionalProperties.putAll(additionalProperties) |
| 183 | + } |
| 184 | + |
| 185 | + @JsonAnySetter |
| 186 | + fun putAdditionalProperty(key: String, value: JsonValue) = apply { |
| 187 | + this.additionalProperties.put(key, value) |
| 188 | + } |
| 189 | + |
| 190 | + fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply { |
| 191 | + this.additionalProperties.putAll(additionalProperties) |
| 192 | + } |
| 193 | + |
| 194 | + fun build(): AccountCreateResponse = |
| 195 | + AccountCreateResponse( |
| 196 | + companyId, |
| 197 | + providerId, |
| 198 | + accountId, |
| 199 | + authenticationType, |
| 200 | + products.map { it.toUnmodifiable() }, |
| 201 | + accessToken, |
| 202 | + additionalProperties.toUnmodifiable(), |
| 203 | + ) |
| 204 | + } |
| 205 | + |
| 206 | + class AuthenticationType |
| 207 | + @JsonCreator |
| 208 | + private constructor( |
| 209 | + private val value: JsonField<String>, |
| 210 | + ) { |
| 211 | + |
| 212 | + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value |
| 213 | + |
| 214 | + override fun equals(other: Any?): Boolean { |
| 215 | + if (this === other) { |
| 216 | + return true |
| 217 | + } |
| 218 | + |
| 219 | + return other is AuthenticationType && this.value == other.value |
| 220 | + } |
| 221 | + |
| 222 | + override fun hashCode() = value.hashCode() |
| 223 | + |
| 224 | + override fun toString() = value.toString() |
| 225 | + |
| 226 | + companion object { |
| 227 | + |
| 228 | + @JvmField val CREDENTIALS = AuthenticationType(JsonField.of("credentials")) |
| 229 | + |
| 230 | + @JvmField val API_TOKEN = AuthenticationType(JsonField.of("api_token")) |
| 231 | + |
| 232 | + @JvmField val OAUTH = AuthenticationType(JsonField.of("oauth")) |
| 233 | + |
| 234 | + @JvmField val ASSISTED = AuthenticationType(JsonField.of("assisted")) |
| 235 | + |
| 236 | + @JvmStatic fun of(value: String) = AuthenticationType(JsonField.of(value)) |
| 237 | + } |
| 238 | + |
| 239 | + enum class Known { |
| 240 | + CREDENTIALS, |
| 241 | + API_TOKEN, |
| 242 | + OAUTH, |
| 243 | + ASSISTED, |
| 244 | + } |
| 245 | + |
| 246 | + enum class Value { |
| 247 | + CREDENTIALS, |
| 248 | + API_TOKEN, |
| 249 | + OAUTH, |
| 250 | + ASSISTED, |
| 251 | + _UNKNOWN, |
| 252 | + } |
| 253 | + |
| 254 | + fun value(): Value = |
| 255 | + when (this) { |
| 256 | + CREDENTIALS -> Value.CREDENTIALS |
| 257 | + API_TOKEN -> Value.API_TOKEN |
| 258 | + OAUTH -> Value.OAUTH |
| 259 | + ASSISTED -> Value.ASSISTED |
| 260 | + else -> Value._UNKNOWN |
| 261 | + } |
| 262 | + |
| 263 | + fun known(): Known = |
| 264 | + when (this) { |
| 265 | + CREDENTIALS -> Known.CREDENTIALS |
| 266 | + API_TOKEN -> Known.API_TOKEN |
| 267 | + OAUTH -> Known.OAUTH |
| 268 | + ASSISTED -> Known.ASSISTED |
| 269 | + else -> throw FinchInvalidDataException("Unknown AuthenticationType: $value") |
| 270 | + } |
| 271 | + |
| 272 | + fun asString(): String = _value().asStringOrThrow() |
| 273 | + } |
| 274 | +} |
0 commit comments