Skip to content

Commit bc2c608

Browse files
stainless-app[bot]stainless-bot
authored andcommitted
fix(client): add some missing validate() calls (#437)
chore(internal): refactor `validate` methods
1 parent 0343b4b commit bc2c608

File tree

225 files changed

+4037
-2918
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

225 files changed

+4037
-2918
lines changed

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

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -161,17 +161,19 @@ private constructor(
161161
private var validated: Boolean = false
162162

163163
fun validate(): Account = apply {
164-
if (!validated) {
165-
token()
166-
created()
167-
spendLimit().validate()
168-
state()
169-
accountHolder().map { it.validate() }
170-
authRuleTokens()
171-
cardholderCurrency()
172-
verificationAddress().map { it.validate() }
173-
validated = true
164+
if (validated) {
165+
return@apply
174166
}
167+
168+
token()
169+
created()
170+
spendLimit().validate()
171+
state()
172+
accountHolder().ifPresent { it.validate() }
173+
authRuleTokens()
174+
cardholderCurrency()
175+
verificationAddress().ifPresent { it.validate() }
176+
validated = true
175177
}
176178

177179
fun toBuilder() = Builder().from(this)
@@ -419,12 +421,14 @@ private constructor(
419421
private var validated: Boolean = false
420422

421423
fun validate(): SpendLimit = apply {
422-
if (!validated) {
423-
daily()
424-
lifetime()
425-
monthly()
426-
validated = true
424+
if (validated) {
425+
return@apply
427426
}
427+
428+
daily()
429+
lifetime()
430+
monthly()
431+
validated = true
428432
}
429433

430434
fun toBuilder() = Builder().from(this)
@@ -640,13 +644,15 @@ private constructor(
640644
private var validated: Boolean = false
641645

642646
fun validate(): AccountHolder = apply {
643-
if (!validated) {
644-
token()
645-
businessAccountToken()
646-
email()
647-
phoneNumber()
648-
validated = true
647+
if (validated) {
648+
return@apply
649649
}
650+
651+
token()
652+
businessAccountToken()
653+
email()
654+
phoneNumber()
655+
validated = true
650656
}
651657

652658
fun toBuilder() = Builder().from(this)
@@ -842,15 +848,17 @@ private constructor(
842848
private var validated: Boolean = false
843849

844850
fun validate(): VerificationAddress = apply {
845-
if (!validated) {
846-
address1()
847-
city()
848-
country()
849-
postalCode()
850-
state()
851-
address2()
852-
validated = true
851+
if (validated) {
852+
return@apply
853853
}
854+
855+
address1()
856+
city()
857+
country()
858+
postalCode()
859+
state()
860+
address2()
861+
validated = true
854862
}
855863

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

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

Lines changed: 54 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -356,29 +356,31 @@ private constructor(
356356
private var validated: Boolean = false
357357

358358
fun validate(): AccountHolder = apply {
359-
if (!validated) {
360-
token()
361-
created()
362-
accountToken()
363-
beneficialOwnerEntities().map { it.forEach { it.validate() } }
364-
beneficialOwnerIndividuals().map { it.forEach { it.validate() } }
365-
businessAccountToken()
366-
businessEntity().map { it.validate() }
367-
controlPerson().map { it.validate() }
368-
email()
369-
exemptionType()
370-
externalId()
371-
individual().map { it.validate() }
372-
natureOfBusiness()
373-
phoneNumber()
374-
requiredDocuments().map { it.forEach { it.validate() } }
375-
status()
376-
statusReasons()
377-
userType()
378-
verificationApplication().map { it.validate() }
379-
websiteUrl()
380-
validated = true
359+
if (validated) {
360+
return@apply
381361
}
362+
363+
token()
364+
created()
365+
accountToken()
366+
beneficialOwnerEntities().ifPresent { it.forEach { it.validate() } }
367+
beneficialOwnerIndividuals().ifPresent { it.forEach { it.validate() } }
368+
businessAccountToken()
369+
businessEntity().ifPresent { it.validate() }
370+
controlPerson().ifPresent { it.validate() }
371+
email()
372+
exemptionType()
373+
externalId()
374+
individual().ifPresent { it.validate() }
375+
natureOfBusiness()
376+
phoneNumber()
377+
requiredDocuments().ifPresent { it.forEach { it.validate() } }
378+
status()
379+
statusReasons()
380+
userType()
381+
verificationApplication().ifPresent { it.validate() }
382+
websiteUrl()
383+
validated = true
382384
}
383385

384386
fun toBuilder() = Builder().from(this)
@@ -935,16 +937,18 @@ private constructor(
935937
private var validated: Boolean = false
936938

937939
fun validate(): AccountHolderBusinessResponse = apply {
938-
if (!validated) {
939-
address().validate()
940-
dbaBusinessName()
941-
entityToken()
942-
governmentId()
943-
legalBusinessName()
944-
phoneNumbers()
945-
parentCompany()
946-
validated = true
940+
if (validated) {
941+
return@apply
947942
}
943+
944+
address().validate()
945+
dbaBusinessName()
946+
entityToken()
947+
governmentId()
948+
legalBusinessName()
949+
phoneNumbers()
950+
parentCompany()
951+
validated = true
948952
}
949953

950954
fun toBuilder() = Builder().from(this)
@@ -1207,16 +1211,18 @@ private constructor(
12071211
private var validated: Boolean = false
12081212

12091213
fun validate(): AccountHolderIndividualResponse = apply {
1210-
if (!validated) {
1211-
address().validate()
1212-
dob()
1213-
email()
1214-
entityToken()
1215-
firstName()
1216-
lastName()
1217-
phoneNumber()
1218-
validated = true
1214+
if (validated) {
1215+
return@apply
12191216
}
1217+
1218+
address().validate()
1219+
dob()
1220+
email()
1221+
entityToken()
1222+
firstName()
1223+
lastName()
1224+
phoneNumber()
1225+
validated = true
12201226
}
12211227

12221228
fun toBuilder() = Builder().from(this)
@@ -1714,13 +1720,15 @@ private constructor(
17141720
private var validated: Boolean = false
17151721

17161722
fun validate(): AccountHolderVerificationApplication = apply {
1717-
if (!validated) {
1718-
created()
1719-
status()
1720-
statusReasons()
1721-
updated()
1722-
validated = true
1723+
if (validated) {
1724+
return@apply
17231725
}
1726+
1727+
created()
1728+
status()
1729+
statusReasons()
1730+
updated()
1731+
validated = true
17241732
}
17251733

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

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -123,16 +123,18 @@ private constructor(
123123
private var validated: Boolean = false
124124

125125
fun validate(): AccountHolderCreateResponse = apply {
126-
if (!validated) {
127-
token()
128-
accountToken()
129-
status()
130-
statusReasons()
131-
created()
132-
externalId()
133-
requiredDocuments().map { it.forEach { it.validate() } }
134-
validated = true
126+
if (validated) {
127+
return@apply
135128
}
129+
130+
token()
131+
accountToken()
132+
status()
133+
statusReasons()
134+
created()
135+
externalId()
136+
requiredDocuments().ifPresent { it.forEach { it.validate() } }
137+
validated = true
136138
}
137139

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

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,12 @@ private constructor(
3737
private var validated: Boolean = false
3838

3939
fun validate(): AccountHolderListDocumentsResponse = apply {
40-
if (!validated) {
41-
data().map { it.forEach { it.validate() } }
42-
validated = true
40+
if (validated) {
41+
return@apply
4342
}
43+
44+
data().ifPresent { it.forEach { it.validate() } }
45+
validated = true
4446
}
4547

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

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ private constructor(
8484
private val additionalProperties: Map<String, JsonValue> = immutableEmptyMap(),
8585
) {
8686

87-
private var validated: Boolean = false
88-
8987
fun data(): List<AccountHolder> = data.getNullable("data") ?: listOf()
9088

9189
fun hasMore(): Boolean = hasMore.getRequired("has_more")
@@ -100,12 +98,16 @@ private constructor(
10098
@ExcludeMissing
10199
fun _additionalProperties(): Map<String, JsonValue> = additionalProperties
102100

101+
private var validated: Boolean = false
102+
103103
fun validate(): Response = apply {
104-
if (!validated) {
105-
data().map { it.validate() }
106-
hasMore()
107-
validated = true
104+
if (validated) {
105+
return@apply
108106
}
107+
108+
data().map { it.validate() }
109+
hasMore()
110+
validated = true
109111
}
110112

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

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,6 @@ private constructor(
8787
private val additionalProperties: Map<String, JsonValue> = immutableEmptyMap(),
8888
) {
8989

90-
private var validated: Boolean = false
91-
9290
fun data(): List<AccountHolder> = data.getNullable("data") ?: listOf()
9391

9492
fun hasMore(): Boolean = hasMore.getRequired("has_more")
@@ -103,12 +101,16 @@ private constructor(
103101
@ExcludeMissing
104102
fun _additionalProperties(): Map<String, JsonValue> = additionalProperties
105103

104+
private var validated: Boolean = false
105+
106106
fun validate(): Response = apply {
107-
if (!validated) {
108-
data().map { it.validate() }
109-
hasMore()
110-
validated = true
107+
if (validated) {
108+
return@apply
111109
}
110+
111+
data().map { it.validate() }
112+
hasMore()
113+
validated = true
112114
}
113115

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

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,15 @@ constructor(
138138
private var validated: Boolean = false
139139

140140
fun validate(): AccountHolderSimulateEnrollmentDocumentReviewBody = apply {
141-
if (!validated) {
142-
documentUploadToken()
143-
status()
144-
acceptedEntityStatusReasons()
145-
statusReason()
146-
validated = true
141+
if (validated) {
142+
return@apply
147143
}
144+
145+
documentUploadToken()
146+
status()
147+
acceptedEntityStatusReasons()
148+
statusReason()
149+
validated = true
148150
}
149151

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

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,14 @@ constructor(
121121
private var validated: Boolean = false
122122

123123
fun validate(): AccountHolderSimulateEnrollmentReviewBody = apply {
124-
if (!validated) {
125-
accountHolderToken()
126-
status()
127-
statusReasons()
128-
validated = true
124+
if (validated) {
125+
return@apply
129126
}
127+
128+
accountHolderToken()
129+
status()
130+
statusReasons()
131+
validated = true
130132
}
131133

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

0 commit comments

Comments
 (0)