Skip to content

Commit 515c9b6

Browse files
feat(client): allow providing some params positionally
1 parent fb5cd44 commit 515c9b6

297 files changed

Lines changed: 12847 additions & 2698 deletions

File tree

Some content is hidden

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

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ package com.lithic.api.core
55
import com.fasterxml.jackson.core.Version
66
import com.fasterxml.jackson.core.util.VersionUtil
77

8+
fun checkRequired(name: String, condition: Boolean) =
9+
check(condition) { "`$name` is required, but was not set" }
10+
811
fun <T : Any> checkRequired(name: String, value: T?): T =
912
checkNotNull(value) { "`$name` is required, but was not set" }
1013

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

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
package com.lithic.api.models
44

55
import com.lithic.api.core.Params
6-
import com.lithic.api.core.checkRequired
76
import com.lithic.api.core.http.Headers
87
import com.lithic.api.core.http.QueryParams
98
import java.util.Objects
9+
import java.util.Optional
10+
import kotlin.jvm.optionals.getOrNull
1011

1112
/**
1213
* Retrieve the status of account holder document uploads, or retrieve the upload URLs to process
@@ -25,12 +26,12 @@ import java.util.Objects
2526
*/
2627
class AccountHolderListDocumentsParams
2728
private constructor(
28-
private val accountHolderToken: String,
29+
private val accountHolderToken: String?,
2930
private val additionalHeaders: Headers,
3031
private val additionalQueryParams: QueryParams,
3132
) : Params {
3233

33-
fun accountHolderToken(): String = accountHolderToken
34+
fun accountHolderToken(): Optional<String> = Optional.ofNullable(accountHolderToken)
3435

3536
fun _additionalHeaders(): Headers = additionalHeaders
3637

@@ -40,14 +41,11 @@ private constructor(
4041

4142
companion object {
4243

44+
@JvmStatic fun none(): AccountHolderListDocumentsParams = builder().build()
45+
4346
/**
4447
* Returns a mutable builder for constructing an instance of
4548
* [AccountHolderListDocumentsParams].
46-
*
47-
* The following fields are required:
48-
* ```java
49-
* .accountHolderToken()
50-
* ```
5149
*/
5250
@JvmStatic fun builder() = Builder()
5351
}
@@ -68,10 +66,16 @@ private constructor(
6866
accountHolderListDocumentsParams.additionalQueryParams.toBuilder()
6967
}
7068

71-
fun accountHolderToken(accountHolderToken: String) = apply {
69+
fun accountHolderToken(accountHolderToken: String?) = apply {
7270
this.accountHolderToken = accountHolderToken
7371
}
7472

73+
/**
74+
* Alias for calling [Builder.accountHolderToken] with `accountHolderToken.orElse(null)`.
75+
*/
76+
fun accountHolderToken(accountHolderToken: Optional<String>) =
77+
accountHolderToken(accountHolderToken.getOrNull())
78+
7579
fun additionalHeaders(additionalHeaders: Headers) = apply {
7680
this.additionalHeaders.clear()
7781
putAllAdditionalHeaders(additionalHeaders)
@@ -174,25 +178,18 @@ private constructor(
174178
* Returns an immutable instance of [AccountHolderListDocumentsParams].
175179
*
176180
* Further updates to this [Builder] will not mutate the returned instance.
177-
*
178-
* The following fields are required:
179-
* ```java
180-
* .accountHolderToken()
181-
* ```
182-
*
183-
* @throws IllegalStateException if any required field is unset.
184181
*/
185182
fun build(): AccountHolderListDocumentsParams =
186183
AccountHolderListDocumentsParams(
187-
checkRequired("accountHolderToken", accountHolderToken),
184+
accountHolderToken,
188185
additionalHeaders.build(),
189186
additionalQueryParams.build(),
190187
)
191188
}
192189

193190
fun _pathParam(index: Int): String =
194191
when (index) {
195-
0 -> accountHolderToken
192+
0 -> accountHolderToken ?: ""
196193
else -> ""
197194
}
198195

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import com.lithic.api.core.checkRequired
77
import com.lithic.api.core.http.Headers
88
import com.lithic.api.core.http.QueryParams
99
import java.util.Objects
10+
import java.util.Optional
11+
import kotlin.jvm.optionals.getOrNull
1012

1113
/**
1214
* Check the status of an account holder document upload, or retrieve the upload URLs to process
@@ -26,14 +28,14 @@ import java.util.Objects
2628
class AccountHolderRetrieveDocumentParams
2729
private constructor(
2830
private val accountHolderToken: String,
29-
private val documentToken: String,
31+
private val documentToken: String?,
3032
private val additionalHeaders: Headers,
3133
private val additionalQueryParams: QueryParams,
3234
) : Params {
3335

3436
fun accountHolderToken(): String = accountHolderToken
3537

36-
fun documentToken(): String = documentToken
38+
fun documentToken(): Optional<String> = Optional.ofNullable(documentToken)
3739

3840
fun _additionalHeaders(): Headers = additionalHeaders
3941

@@ -50,7 +52,6 @@ private constructor(
5052
* The following fields are required:
5153
* ```java
5254
* .accountHolderToken()
53-
* .documentToken()
5455
* ```
5556
*/
5657
@JvmStatic fun builder() = Builder()
@@ -79,7 +80,11 @@ private constructor(
7980
this.accountHolderToken = accountHolderToken
8081
}
8182

82-
fun documentToken(documentToken: String) = apply { this.documentToken = documentToken }
83+
fun documentToken(documentToken: String?) = apply { this.documentToken = documentToken }
84+
85+
/** Alias for calling [Builder.documentToken] with `documentToken.orElse(null)`. */
86+
fun documentToken(documentToken: Optional<String>) =
87+
documentToken(documentToken.getOrNull())
8388

8489
fun additionalHeaders(additionalHeaders: Headers) = apply {
8590
this.additionalHeaders.clear()
@@ -187,15 +192,14 @@ private constructor(
187192
* The following fields are required:
188193
* ```java
189194
* .accountHolderToken()
190-
* .documentToken()
191195
* ```
192196
*
193197
* @throws IllegalStateException if any required field is unset.
194198
*/
195199
fun build(): AccountHolderRetrieveDocumentParams =
196200
AccountHolderRetrieveDocumentParams(
197201
checkRequired("accountHolderToken", accountHolderToken),
198-
checkRequired("documentToken", documentToken),
202+
documentToken,
199203
additionalHeaders.build(),
200204
additionalQueryParams.build(),
201205
)
@@ -204,7 +208,7 @@ private constructor(
204208
fun _pathParam(index: Int): String =
205209
when (index) {
206210
0 -> accountHolderToken
207-
1 -> documentToken
211+
1 -> documentToken ?: ""
208212
else -> ""
209213
}
210214

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

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,21 @@
33
package com.lithic.api.models
44

55
import com.lithic.api.core.Params
6-
import com.lithic.api.core.checkRequired
76
import com.lithic.api.core.http.Headers
87
import com.lithic.api.core.http.QueryParams
98
import java.util.Objects
9+
import java.util.Optional
10+
import kotlin.jvm.optionals.getOrNull
1011

1112
/** Get an Individual or Business Account Holder and/or their KYC or KYB evaluation status. */
1213
class AccountHolderRetrieveParams
1314
private constructor(
14-
private val accountHolderToken: String,
15+
private val accountHolderToken: String?,
1516
private val additionalHeaders: Headers,
1617
private val additionalQueryParams: QueryParams,
1718
) : Params {
1819

19-
fun accountHolderToken(): String = accountHolderToken
20+
fun accountHolderToken(): Optional<String> = Optional.ofNullable(accountHolderToken)
2021

2122
fun _additionalHeaders(): Headers = additionalHeaders
2223

@@ -26,13 +27,10 @@ private constructor(
2627

2728
companion object {
2829

30+
@JvmStatic fun none(): AccountHolderRetrieveParams = builder().build()
31+
2932
/**
3033
* Returns a mutable builder for constructing an instance of [AccountHolderRetrieveParams].
31-
*
32-
* The following fields are required:
33-
* ```java
34-
* .accountHolderToken()
35-
* ```
3634
*/
3735
@JvmStatic fun builder() = Builder()
3836
}
@@ -51,10 +49,16 @@ private constructor(
5149
additionalQueryParams = accountHolderRetrieveParams.additionalQueryParams.toBuilder()
5250
}
5351

54-
fun accountHolderToken(accountHolderToken: String) = apply {
52+
fun accountHolderToken(accountHolderToken: String?) = apply {
5553
this.accountHolderToken = accountHolderToken
5654
}
5755

56+
/**
57+
* Alias for calling [Builder.accountHolderToken] with `accountHolderToken.orElse(null)`.
58+
*/
59+
fun accountHolderToken(accountHolderToken: Optional<String>) =
60+
accountHolderToken(accountHolderToken.getOrNull())
61+
5862
fun additionalHeaders(additionalHeaders: Headers) = apply {
5963
this.additionalHeaders.clear()
6064
putAllAdditionalHeaders(additionalHeaders)
@@ -157,25 +161,18 @@ private constructor(
157161
* Returns an immutable instance of [AccountHolderRetrieveParams].
158162
*
159163
* Further updates to this [Builder] will not mutate the returned instance.
160-
*
161-
* The following fields are required:
162-
* ```java
163-
* .accountHolderToken()
164-
* ```
165-
*
166-
* @throws IllegalStateException if any required field is unset.
167164
*/
168165
fun build(): AccountHolderRetrieveParams =
169166
AccountHolderRetrieveParams(
170-
checkRequired("accountHolderToken", accountHolderToken),
167+
accountHolderToken,
171168
additionalHeaders.build(),
172169
additionalQueryParams.build(),
173170
)
174171
}
175172

176173
fun _pathParam(index: Int): String =
177174
when (index) {
178-
0 -> accountHolderToken
175+
0 -> accountHolderToken ?: ""
179176
else -> ""
180177
}
181178

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ import kotlin.jvm.optionals.getOrNull
4545
*/
4646
class AccountHolderUpdateParams
4747
private constructor(
48-
private val accountHolderToken: String,
48+
private val accountHolderToken: String?,
4949
private val body: Body,
5050
private val additionalHeaders: Headers,
5151
private val additionalQueryParams: QueryParams,
5252
) : Params {
5353

54-
fun accountHolderToken(): String = accountHolderToken
54+
fun accountHolderToken(): Optional<String> = Optional.ofNullable(accountHolderToken)
5555

5656
/** The KYB request payload for updating a business. */
5757
fun body(): Body = body
@@ -69,7 +69,6 @@ private constructor(
6969
*
7070
* The following fields are required:
7171
* ```java
72-
* .accountHolderToken()
7372
* .body()
7473
* ```
7574
*/
@@ -92,10 +91,16 @@ private constructor(
9291
additionalQueryParams = accountHolderUpdateParams.additionalQueryParams.toBuilder()
9392
}
9493

95-
fun accountHolderToken(accountHolderToken: String) = apply {
94+
fun accountHolderToken(accountHolderToken: String?) = apply {
9695
this.accountHolderToken = accountHolderToken
9796
}
9897

98+
/**
99+
* Alias for calling [Builder.accountHolderToken] with `accountHolderToken.orElse(null)`.
100+
*/
101+
fun accountHolderToken(accountHolderToken: Optional<String>) =
102+
accountHolderToken(accountHolderToken.getOrNull())
103+
99104
/** The KYB request payload for updating a business. */
100105
fun body(body: Body) = apply { this.body = body }
101106

@@ -215,15 +220,14 @@ private constructor(
215220
*
216221
* The following fields are required:
217222
* ```java
218-
* .accountHolderToken()
219223
* .body()
220224
* ```
221225
*
222226
* @throws IllegalStateException if any required field is unset.
223227
*/
224228
fun build(): AccountHolderUpdateParams =
225229
AccountHolderUpdateParams(
226-
checkRequired("accountHolderToken", accountHolderToken),
230+
accountHolderToken,
227231
checkRequired("body", body),
228232
additionalHeaders.build(),
229233
additionalQueryParams.build(),
@@ -234,7 +238,7 @@ private constructor(
234238

235239
fun _pathParam(index: Int): String =
236240
when (index) {
237-
0 -> accountHolderToken
241+
0 -> accountHolderToken ?: ""
238242
else -> ""
239243
}
240244

0 commit comments

Comments
 (0)