Skip to content

Commit db55dc2

Browse files
stainless-app[bot]stainless-bot
authored andcommitted
chore(internal): extract a checkRequired function (#443)
1 parent ec5f82a commit db55dc2

File tree

195 files changed

+1347
-1676
lines changed

Some content is hidden

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

195 files changed

+1347
-1676
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@file:JvmName("Check")
2+
3+
package com.lithic.api.core
4+
5+
@JvmSynthetic
6+
internal fun <T : Any> checkRequired(name: String, value: T?): T =
7+
checkNotNull(value) { "`$name` is required but was not set" }

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ private constructor(
173173
}
174174

175175
fun build(): ClientOptions {
176-
checkNotNull(httpClient) { "`httpClient` is required but was not set" }
177-
checkNotNull(apiKey) { "`apiKey` is required but was not set" }
176+
checkRequired("httpClient", httpClient)
177+
checkRequired("apiKey", apiKey)
178178

179179
val headers = Headers.builder()
180180
val queryParams = QueryParams.builder()

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

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import com.lithic.api.core.JsonField
1212
import com.lithic.api.core.JsonMissing
1313
import com.lithic.api.core.JsonValue
1414
import com.lithic.api.core.NoAutoDetect
15+
import com.lithic.api.core.checkRequired
1516
import com.lithic.api.core.immutableEmptyMap
1617
import com.lithic.api.core.toImmutable
1718
import com.lithic.api.errors.LithicInvalidDataException
@@ -361,10 +362,10 @@ private constructor(
361362

362363
fun build(): Account =
363364
Account(
364-
checkNotNull(token) { "`token` is required but was not set" },
365-
checkNotNull(created) { "`created` is required but was not set" },
366-
checkNotNull(spendLimit) { "`spendLimit` is required but was not set" },
367-
checkNotNull(state) { "`state` is required but was not set" },
365+
checkRequired("token", token),
366+
checkRequired("created", created),
367+
checkRequired("spendLimit", spendLimit),
368+
checkRequired("state", state),
368369
accountHolder,
369370
(authRuleTokens ?: JsonMissing.of()).map { it.toImmutable() },
370371
cardholderCurrency,
@@ -492,9 +493,9 @@ private constructor(
492493

493494
fun build(): SpendLimit =
494495
SpendLimit(
495-
checkNotNull(daily) { "`daily` is required but was not set" },
496-
checkNotNull(lifetime) { "`lifetime` is required but was not set" },
497-
checkNotNull(monthly) { "`monthly` is required but was not set" },
496+
checkRequired("daily", daily),
497+
checkRequired("lifetime", lifetime),
498+
checkRequired("monthly", monthly),
498499
additionalProperties.toImmutable(),
499500
)
500501
}
@@ -737,12 +738,10 @@ private constructor(
737738

738739
fun build(): AccountHolder =
739740
AccountHolder(
740-
checkNotNull(token) { "`token` is required but was not set" },
741-
checkNotNull(businessAccountToken) {
742-
"`businessAccountToken` is required but was not set"
743-
},
744-
checkNotNull(email) { "`email` is required but was not set" },
745-
checkNotNull(phoneNumber) { "`phoneNumber` is required but was not set" },
741+
checkRequired("token", token),
742+
checkRequired("businessAccountToken", businessAccountToken),
743+
checkRequired("email", email),
744+
checkRequired("phoneNumber", phoneNumber),
746745
additionalProperties.toImmutable(),
747746
)
748747
}
@@ -960,11 +959,11 @@ private constructor(
960959

961960
fun build(): VerificationAddress =
962961
VerificationAddress(
963-
checkNotNull(address1) { "`address1` is required but was not set" },
964-
checkNotNull(city) { "`city` is required but was not set" },
965-
checkNotNull(country) { "`country` is required but was not set" },
966-
checkNotNull(postalCode) { "`postalCode` is required but was not set" },
967-
checkNotNull(state) { "`state` is required but was not set" },
962+
checkRequired("address1", address1),
963+
checkRequired("city", city),
964+
checkRequired("country", country),
965+
checkRequired("postalCode", postalCode),
966+
checkRequired("state", state),
968967
address2,
969968
additionalProperties.toImmutable(),
970969
)

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

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import com.lithic.api.core.JsonField
1212
import com.lithic.api.core.JsonMissing
1313
import com.lithic.api.core.JsonValue
1414
import com.lithic.api.core.NoAutoDetect
15+
import com.lithic.api.core.checkRequired
1516
import com.lithic.api.core.immutableEmptyMap
1617
import com.lithic.api.core.toImmutable
1718
import com.lithic.api.errors.LithicInvalidDataException
@@ -804,8 +805,8 @@ private constructor(
804805

805806
fun build(): AccountHolder =
806807
AccountHolder(
807-
checkNotNull(token) { "`token` is required but was not set" },
808-
checkNotNull(created) { "`created` is required but was not set" },
808+
checkRequired("token", token),
809+
checkRequired("created", created),
809810
accountToken,
810811
(beneficialOwnerEntities ?: JsonMissing.of()).map { it.toImmutable() },
811812
(beneficialOwnerIndividuals ?: JsonMissing.of()).map { it.toImmutable() },
@@ -1093,17 +1094,12 @@ private constructor(
10931094

10941095
fun build(): AccountHolderBusinessResponse =
10951096
AccountHolderBusinessResponse(
1096-
checkNotNull(address) { "`address` is required but was not set" },
1097-
checkNotNull(dbaBusinessName) {
1098-
"`dbaBusinessName` is required but was not set"
1099-
},
1100-
checkNotNull(entityToken) { "`entityToken` is required but was not set" },
1101-
checkNotNull(governmentId) { "`governmentId` is required but was not set" },
1102-
checkNotNull(legalBusinessName) {
1103-
"`legalBusinessName` is required but was not set"
1104-
},
1105-
checkNotNull(phoneNumbers) { "`phoneNumbers` is required but was not set" }
1106-
.map { it.toImmutable() },
1097+
checkRequired("address", address),
1098+
checkRequired("dbaBusinessName", dbaBusinessName),
1099+
checkRequired("entityToken", entityToken),
1100+
checkRequired("governmentId", governmentId),
1101+
checkRequired("legalBusinessName", legalBusinessName),
1102+
checkRequired("phoneNumbers", phoneNumbers).map { it.toImmutable() },
11071103
parentCompany,
11081104
additionalProperties.toImmutable(),
11091105
)
@@ -1324,13 +1320,13 @@ private constructor(
13241320

13251321
fun build(): AccountHolderIndividualResponse =
13261322
AccountHolderIndividualResponse(
1327-
checkNotNull(address) { "`address` is required but was not set" },
1328-
checkNotNull(dob) { "`dob` is required but was not set" },
1329-
checkNotNull(email) { "`email` is required but was not set" },
1330-
checkNotNull(entityToken) { "`entityToken` is required but was not set" },
1331-
checkNotNull(firstName) { "`firstName` is required but was not set" },
1332-
checkNotNull(lastName) { "`lastName` is required but was not set" },
1333-
checkNotNull(phoneNumber) { "`phoneNumber` is required but was not set" },
1323+
checkRequired("address", address),
1324+
checkRequired("dob", dob),
1325+
checkRequired("email", email),
1326+
checkRequired("entityToken", entityToken),
1327+
checkRequired("firstName", firstName),
1328+
checkRequired("lastName", lastName),
1329+
checkRequired("phoneNumber", phoneNumber),
13341330
additionalProperties.toImmutable(),
13351331
)
13361332
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import com.lithic.api.core.JsonField
1212
import com.lithic.api.core.JsonMissing
1313
import com.lithic.api.core.JsonValue
1414
import com.lithic.api.core.NoAutoDetect
15+
import com.lithic.api.core.checkRequired
1516
import com.lithic.api.core.immutableEmptyMap
1617
import com.lithic.api.core.toImmutable
1718
import com.lithic.api.errors.LithicInvalidDataException
@@ -292,11 +293,10 @@ private constructor(
292293

293294
fun build(): AccountHolderCreateResponse =
294295
AccountHolderCreateResponse(
295-
checkNotNull(token) { "`token` is required but was not set" },
296-
checkNotNull(accountToken) { "`accountToken` is required but was not set" },
297-
checkNotNull(status) { "`status` is required but was not set" },
298-
checkNotNull(statusReasons) { "`statusReasons` is required but was not set" }
299-
.map { it.toImmutable() },
296+
checkRequired("token", token),
297+
checkRequired("accountToken", accountToken),
298+
checkRequired("status", status),
299+
checkRequired("statusReasons", statusReasons).map { it.toImmutable() },
300300
created,
301301
externalId,
302302
(requiredDocuments ?: JsonMissing.of()).map { it.toImmutable() },

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
package com.lithic.api.models
44

55
import com.lithic.api.core.NoAutoDetect
6+
import com.lithic.api.core.checkRequired
67
import com.lithic.api.core.http.Headers
78
import com.lithic.api.core.http.QueryParams
89
import java.util.Objects
@@ -173,9 +174,7 @@ constructor(
173174

174175
fun build(): AccountHolderListDocumentsParams =
175176
AccountHolderListDocumentsParams(
176-
checkNotNull(accountHolderToken) {
177-
"`accountHolderToken` is required but was not set"
178-
},
177+
checkRequired("accountHolderToken", accountHolderToken),
179178
additionalHeaders.build(),
180179
additionalQueryParams.build(),
181180
)

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
package com.lithic.api.models
44

55
import com.lithic.api.core.NoAutoDetect
6+
import com.lithic.api.core.checkRequired
67
import com.lithic.api.core.http.Headers
78
import com.lithic.api.core.http.QueryParams
89
import java.util.Objects
@@ -182,10 +183,8 @@ constructor(
182183

183184
fun build(): AccountHolderRetrieveDocumentParams =
184185
AccountHolderRetrieveDocumentParams(
185-
checkNotNull(accountHolderToken) {
186-
"`accountHolderToken` is required but was not set"
187-
},
188-
checkNotNull(documentToken) { "`documentToken` is required but was not set" },
186+
checkRequired("accountHolderToken", accountHolderToken),
187+
checkRequired("documentToken", documentToken),
189188
additionalHeaders.build(),
190189
additionalQueryParams.build(),
191190
)

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
package com.lithic.api.models
44

55
import com.lithic.api.core.NoAutoDetect
6+
import com.lithic.api.core.checkRequired
67
import com.lithic.api.core.http.Headers
78
import com.lithic.api.core.http.QueryParams
89
import java.util.Objects
@@ -157,9 +158,7 @@ constructor(
157158

158159
fun build(): AccountHolderRetrieveParams =
159160
AccountHolderRetrieveParams(
160-
checkNotNull(accountHolderToken) {
161-
"`accountHolderToken` is required but was not set"
162-
},
161+
checkRequired("accountHolderToken", accountHolderToken),
163162
additionalHeaders.build(),
164163
additionalQueryParams.build(),
165164
)

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import com.lithic.api.core.JsonField
1212
import com.lithic.api.core.JsonMissing
1313
import com.lithic.api.core.JsonValue
1414
import com.lithic.api.core.NoAutoDetect
15+
import com.lithic.api.core.checkRequired
1516
import com.lithic.api.core.http.Headers
1617
import com.lithic.api.core.http.QueryParams
1718
import com.lithic.api.core.immutableEmptyMap
@@ -257,10 +258,8 @@ constructor(
257258

258259
fun build(): AccountHolderSimulateEnrollmentDocumentReviewBody =
259260
AccountHolderSimulateEnrollmentDocumentReviewBody(
260-
checkNotNull(documentUploadToken) {
261-
"`documentUploadToken` is required but was not set"
262-
},
263-
checkNotNull(status) { "`status` is required but was not set" },
261+
checkRequired("documentUploadToken", documentUploadToken),
262+
checkRequired("status", status),
264263
(acceptedEntityStatusReasons ?: JsonMissing.of()).map { it.toImmutable() },
265264
statusReason,
266265
additionalProperties.toImmutable(),

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

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import com.lithic.api.core.JsonField
1212
import com.lithic.api.core.JsonMissing
1313
import com.lithic.api.core.JsonValue
1414
import com.lithic.api.core.NoAutoDetect
15+
import com.lithic.api.core.checkRequired
1516
import com.lithic.api.core.immutableEmptyMap
1617
import com.lithic.api.core.toImmutable
1718
import com.lithic.api.errors.LithicInvalidDataException
@@ -1107,13 +1108,10 @@ private constructor(
11071108

11081109
fun build(): KybBusinessEntity =
11091110
KybBusinessEntity(
1110-
checkNotNull(address) { "`address` is required but was not set" },
1111-
checkNotNull(governmentId) { "`governmentId` is required but was not set" },
1112-
checkNotNull(legalBusinessName) {
1113-
"`legalBusinessName` is required but was not set"
1114-
},
1115-
checkNotNull(phoneNumbers) { "`phoneNumbers` is required but was not set" }
1116-
.map { it.toImmutable() },
1111+
checkRequired("address", address),
1112+
checkRequired("governmentId", governmentId),
1113+
checkRequired("legalBusinessName", legalBusinessName),
1114+
checkRequired("phoneNumbers", phoneNumbers).map { it.toImmutable() },
11171115
dbaBusinessName,
11181116
parentCompany,
11191117
additionalProperties.toImmutable(),
@@ -1334,11 +1332,11 @@ private constructor(
13341332

13351333
fun build(): Address2 =
13361334
Address2(
1337-
checkNotNull(address1) { "`address1` is required but was not set" },
1338-
checkNotNull(city) { "`city` is required but was not set" },
1339-
checkNotNull(country) { "`country` is required but was not set" },
1340-
checkNotNull(postalCode) { "`postalCode` is required but was not set" },
1341-
checkNotNull(state) { "`state` is required but was not set" },
1335+
checkRequired("address1", address1),
1336+
checkRequired("city", city),
1337+
checkRequired("country", country),
1338+
checkRequired("postalCode", postalCode),
1339+
checkRequired("state", state),
13421340
address2,
13431341
additionalProperties.toImmutable(),
13441342
)
@@ -1842,11 +1840,11 @@ private constructor(
18421840

18431841
fun build(): Address2 =
18441842
Address2(
1845-
checkNotNull(address1) { "`address1` is required but was not set" },
1846-
checkNotNull(city) { "`city` is required but was not set" },
1847-
checkNotNull(country) { "`country` is required but was not set" },
1848-
checkNotNull(postalCode) { "`postalCode` is required but was not set" },
1849-
checkNotNull(state) { "`state` is required but was not set" },
1843+
checkRequired("address1", address1),
1844+
checkRequired("city", city),
1845+
checkRequired("country", country),
1846+
checkRequired("postalCode", postalCode),
1847+
checkRequired("state", state),
18501848
address2,
18511849
additionalProperties.toImmutable(),
18521850
)
@@ -2480,11 +2478,10 @@ private constructor(
24802478

24812479
fun build(): VerificationApplication =
24822480
VerificationApplication(
2483-
checkNotNull(created) { "`created` is required but was not set" },
2484-
checkNotNull(status) { "`status` is required but was not set" },
2485-
checkNotNull(statusReasons) { "`statusReasons` is required but was not set" }
2486-
.map { it.toImmutable() },
2487-
checkNotNull(updated) { "`updated` is required but was not set" },
2481+
checkRequired("created", created),
2482+
checkRequired("status", status),
2483+
checkRequired("statusReasons", statusReasons).map { it.toImmutable() },
2484+
checkRequired("updated", updated),
24882485
additionalProperties.toImmutable(),
24892486
)
24902487
}

0 commit comments

Comments
 (0)