Skip to content

Commit ac11497

Browse files
feat(api): add tags field to Payment and related response models
1 parent 33a0da9 commit ac11497

16 files changed

Lines changed: 484 additions & 7 deletions

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 213
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic/lithic-42c58dcdae350a8544a75a19ad38aaeb70f3ed98dc642b4a7b47a4b92d8c9c91.yml
3-
openapi_spec_hash: c26c7c8fab1f49977c23bb698ec64e28
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic/lithic-b42f0fb5ca219622c46728ac767a2a23ec6a8aecd2b32c92efa449fd69576a6d.yml
3+
openapi_spec_hash: b591dcd3405c0738c10b626852284a1b
44
config_hash: 126e04f676f61e5871a82889336dbf9d

lithic-java-core/src/main/kotlin/com/lithic/api/models/Payment.kt

Lines changed: 153 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ private constructor(
5757
private val currency: JsonField<String>,
5858
private val expectedReleaseDate: JsonField<LocalDate>,
5959
private val externalBankAccountToken: JsonField<String>,
60+
private val tags: JsonField<Tags>,
6061
private val type: JsonField<TransferType>,
6162
private val userDefinedId: JsonField<String>,
6263
private val additionalProperties: MutableMap<String, JsonValue>,
@@ -114,6 +115,7 @@ private constructor(
114115
@JsonProperty("external_bank_account_token")
115116
@ExcludeMissing
116117
externalBankAccountToken: JsonField<String> = JsonMissing.of(),
118+
@JsonProperty("tags") @ExcludeMissing tags: JsonField<Tags> = JsonMissing.of(),
117119
@JsonProperty("type") @ExcludeMissing type: JsonField<TransferType> = JsonMissing.of(),
118120
@JsonProperty("user_defined_id")
119121
@ExcludeMissing
@@ -139,6 +141,7 @@ private constructor(
139141
currency,
140142
expectedReleaseDate,
141143
externalBankAccountToken,
144+
tags,
142145
type,
143146
userDefinedId,
144147
mutableMapOf(),
@@ -308,6 +311,15 @@ private constructor(
308311
fun externalBankAccountToken(): Optional<String> =
309312
externalBankAccountToken.getOptional("external_bank_account_token")
310313

314+
/**
315+
* Key-value pairs for tagging resources. Tags allow you to associate arbitrary metadata with a
316+
* resource for your own purposes.
317+
*
318+
* @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the
319+
* server responded with an unexpected value).
320+
*/
321+
fun tags(): Optional<Tags> = tags.getOptional("tags")
322+
311323
/**
312324
* @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the
313325
* server responded with an unexpected value).
@@ -483,6 +495,13 @@ private constructor(
483495
@ExcludeMissing
484496
fun _externalBankAccountToken(): JsonField<String> = externalBankAccountToken
485497

498+
/**
499+
* Returns the raw JSON value of [tags].
500+
*
501+
* Unlike [tags], this method doesn't throw if the JSON field has an unexpected type.
502+
*/
503+
@JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField<Tags> = tags
504+
486505
/**
487506
* Returns the raw JSON value of [type].
488507
*
@@ -563,6 +582,7 @@ private constructor(
563582
private var currency: JsonField<String> = JsonMissing.of()
564583
private var expectedReleaseDate: JsonField<LocalDate> = JsonMissing.of()
565584
private var externalBankAccountToken: JsonField<String> = JsonMissing.of()
585+
private var tags: JsonField<Tags> = JsonMissing.of()
566586
private var type: JsonField<TransferType> = JsonMissing.of()
567587
private var userDefinedId: JsonField<String> = JsonMissing.of()
568588
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()
@@ -589,6 +609,7 @@ private constructor(
589609
currency = payment.currency
590610
expectedReleaseDate = payment.expectedReleaseDate
591611
externalBankAccountToken = payment.externalBankAccountToken
612+
tags = payment.tags
592613
type = payment.type
593614
userDefinedId = payment.userDefinedId
594615
additionalProperties = payment.additionalProperties.toMutableMap()
@@ -890,6 +911,20 @@ private constructor(
890911
this.externalBankAccountToken = externalBankAccountToken
891912
}
892913

914+
/**
915+
* Key-value pairs for tagging resources. Tags allow you to associate arbitrary metadata
916+
* with a resource for your own purposes.
917+
*/
918+
fun tags(tags: Tags) = tags(JsonField.of(tags))
919+
920+
/**
921+
* Sets [Builder.tags] to an arbitrary JSON value.
922+
*
923+
* You should usually call [Builder.tags] with a well-typed [Tags] value instead. This
924+
* method is primarily for setting the field to an undocumented or not yet supported value.
925+
*/
926+
fun tags(tags: JsonField<Tags>) = apply { this.tags = tags }
927+
893928
fun type(type: TransferType) = type(JsonField.of(type))
894929

895930
/**
@@ -989,6 +1024,7 @@ private constructor(
9891024
currency,
9901025
expectedReleaseDate,
9911026
externalBankAccountToken,
1027+
tags,
9921028
type,
9931029
userDefinedId,
9941030
additionalProperties.toMutableMap(),
@@ -1030,6 +1066,7 @@ private constructor(
10301066
currency()
10311067
expectedReleaseDate()
10321068
externalBankAccountToken()
1069+
tags().ifPresent { it.validate() }
10331070
type().ifPresent { it.validate() }
10341071
userDefinedId()
10351072
validated = true
@@ -1070,6 +1107,7 @@ private constructor(
10701107
(if (currency.asKnown().isPresent) 1 else 0) +
10711108
(if (expectedReleaseDate.asKnown().isPresent) 1 else 0) +
10721109
(if (externalBankAccountToken.asKnown().isPresent) 1 else 0) +
1110+
(tags.asKnown().getOrNull()?.validity() ?: 0) +
10731111
(type.asKnown().getOrNull()?.validity() ?: 0) +
10741112
(if (userDefinedId.asKnown().isPresent) 1 else 0)
10751113

@@ -5138,6 +5176,118 @@ private constructor(
51385176
override fun toString() = value.toString()
51395177
}
51405178

5179+
/**
5180+
* Key-value pairs for tagging resources. Tags allow you to associate arbitrary metadata with a
5181+
* resource for your own purposes.
5182+
*/
5183+
class Tags
5184+
@JsonCreator
5185+
private constructor(
5186+
@com.fasterxml.jackson.annotation.JsonValue
5187+
private val additionalProperties: Map<String, JsonValue>
5188+
) {
5189+
5190+
@JsonAnyGetter
5191+
@ExcludeMissing
5192+
fun _additionalProperties(): Map<String, JsonValue> = additionalProperties
5193+
5194+
fun toBuilder() = Builder().from(this)
5195+
5196+
companion object {
5197+
5198+
/** Returns a mutable builder for constructing an instance of [Tags]. */
5199+
@JvmStatic fun builder() = Builder()
5200+
}
5201+
5202+
/** A builder for [Tags]. */
5203+
class Builder internal constructor() {
5204+
5205+
private var additionalProperties: MutableMap<String, JsonValue> = mutableMapOf()
5206+
5207+
@JvmSynthetic
5208+
internal fun from(tags: Tags) = apply {
5209+
additionalProperties = tags.additionalProperties.toMutableMap()
5210+
}
5211+
5212+
fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
5213+
this.additionalProperties.clear()
5214+
putAllAdditionalProperties(additionalProperties)
5215+
}
5216+
5217+
fun putAdditionalProperty(key: String, value: JsonValue) = apply {
5218+
additionalProperties.put(key, value)
5219+
}
5220+
5221+
fun putAllAdditionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
5222+
this.additionalProperties.putAll(additionalProperties)
5223+
}
5224+
5225+
fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) }
5226+
5227+
fun removeAllAdditionalProperties(keys: Set<String>) = apply {
5228+
keys.forEach(::removeAdditionalProperty)
5229+
}
5230+
5231+
/**
5232+
* Returns an immutable instance of [Tags].
5233+
*
5234+
* Further updates to this [Builder] will not mutate the returned instance.
5235+
*/
5236+
fun build(): Tags = Tags(additionalProperties.toImmutable())
5237+
}
5238+
5239+
private var validated: Boolean = false
5240+
5241+
/**
5242+
* Validates that the types of all values in this object match their expected types
5243+
* recursively.
5244+
*
5245+
* This method is _not_ forwards compatible with new types from the API for existing fields.
5246+
*
5247+
* @throws LithicInvalidDataException if any value type in this object doesn't match its
5248+
* expected type.
5249+
*/
5250+
fun validate(): Tags = apply {
5251+
if (validated) {
5252+
return@apply
5253+
}
5254+
5255+
validated = true
5256+
}
5257+
5258+
fun isValid(): Boolean =
5259+
try {
5260+
validate()
5261+
true
5262+
} catch (e: LithicInvalidDataException) {
5263+
false
5264+
}
5265+
5266+
/**
5267+
* Returns a score indicating how many valid values are contained in this object
5268+
* recursively.
5269+
*
5270+
* Used for best match union deserialization.
5271+
*/
5272+
@JvmSynthetic
5273+
internal fun validity(): Int =
5274+
additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() }
5275+
5276+
override fun equals(other: Any?): Boolean {
5277+
if (this === other) {
5278+
return true
5279+
}
5280+
5281+
return other is Tags && additionalProperties == other.additionalProperties
5282+
}
5283+
5284+
private val hashCode: Int by lazy { Objects.hash(additionalProperties) }
5285+
5286+
override fun hashCode(): Int = hashCode
5287+
5288+
override fun toString() = "Tags{additionalProperties=$additionalProperties}"
5289+
}
5290+
51415291
class TransferType @JsonCreator private constructor(private val value: JsonField<String>) :
51425292
Enum {
51435293

@@ -5343,6 +5493,7 @@ private constructor(
53435493
currency == other.currency &&
53445494
expectedReleaseDate == other.expectedReleaseDate &&
53455495
externalBankAccountToken == other.externalBankAccountToken &&
5496+
tags == other.tags &&
53465497
type == other.type &&
53475498
userDefinedId == other.userDefinedId &&
53485499
additionalProperties == other.additionalProperties
@@ -5370,6 +5521,7 @@ private constructor(
53705521
currency,
53715522
expectedReleaseDate,
53725523
externalBankAccountToken,
5524+
tags,
53735525
type,
53745526
userDefinedId,
53755527
additionalProperties,
@@ -5379,5 +5531,5 @@ private constructor(
53795531
override fun hashCode(): Int = hashCode
53805532

53815533
override fun toString() =
5382-
"Payment{token=$token, category=$category, created=$created, descriptor=$descriptor, direction=$direction, events=$events, family=$family, financialAccountToken=$financialAccountToken, method=$method, methodAttributes=$methodAttributes, pendingAmount=$pendingAmount, relatedAccountTokens=$relatedAccountTokens, result=$result, settledAmount=$settledAmount, source=$source, status=$status, updated=$updated, currency=$currency, expectedReleaseDate=$expectedReleaseDate, externalBankAccountToken=$externalBankAccountToken, type=$type, userDefinedId=$userDefinedId, additionalProperties=$additionalProperties}"
5534+
"Payment{token=$token, category=$category, created=$created, descriptor=$descriptor, direction=$direction, events=$events, family=$family, financialAccountToken=$financialAccountToken, method=$method, methodAttributes=$methodAttributes, pendingAmount=$pendingAmount, relatedAccountTokens=$relatedAccountTokens, result=$result, settledAmount=$settledAmount, source=$source, status=$status, updated=$updated, currency=$currency, expectedReleaseDate=$expectedReleaseDate, externalBankAccountToken=$externalBankAccountToken, tags=$tags, type=$type, userDefinedId=$userDefinedId, additionalProperties=$additionalProperties}"
53835535
}

0 commit comments

Comments
 (0)