Skip to content

Commit c31350d

Browse files
feat(client): allow providing some params positionally
1 parent aa64e9e commit c31350d

324 files changed

Lines changed: 11026 additions & 2397 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.

modern-treasury-java-core/src/main/kotlin/com/moderntreasury/api/core/Check.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ package com.moderntreasury.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

modern-treasury-java-core/src/main/kotlin/com/moderntreasury/api/models/AccountCollectionFlowRetrieveParams.kt

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

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

1112
/** get account_collection_flow */
1213
class AccountCollectionFlowRetrieveParams
1314
private constructor(
14-
private val id: String,
15+
private val id: String?,
1516
private val additionalHeaders: Headers,
1617
private val additionalQueryParams: QueryParams,
1718
) : Params {
1819

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

2122
fun _additionalHeaders(): Headers = additionalHeaders
2223

@@ -26,14 +27,11 @@ private constructor(
2627

2728
companion object {
2829

30+
@JvmStatic fun none(): AccountCollectionFlowRetrieveParams = builder().build()
31+
2932
/**
3033
* Returns a mutable builder for constructing an instance of
3134
* [AccountCollectionFlowRetrieveParams].
32-
*
33-
* The following fields are required:
34-
* ```java
35-
* .id()
36-
* ```
3735
*/
3836
@JvmStatic fun builder() = Builder()
3937
}
@@ -55,7 +53,10 @@ private constructor(
5553
accountCollectionFlowRetrieveParams.additionalQueryParams.toBuilder()
5654
}
5755

58-
fun id(id: String) = apply { this.id = id }
56+
fun id(id: String?) = apply { this.id = id }
57+
58+
/** Alias for calling [Builder.id] with `id.orElse(null)`. */
59+
fun id(id: Optional<String>) = id(id.getOrNull())
5960

6061
fun additionalHeaders(additionalHeaders: Headers) = apply {
6162
this.additionalHeaders.clear()
@@ -159,25 +160,18 @@ private constructor(
159160
* Returns an immutable instance of [AccountCollectionFlowRetrieveParams].
160161
*
161162
* Further updates to this [Builder] will not mutate the returned instance.
162-
*
163-
* The following fields are required:
164-
* ```java
165-
* .id()
166-
* ```
167-
*
168-
* @throws IllegalStateException if any required field is unset.
169163
*/
170164
fun build(): AccountCollectionFlowRetrieveParams =
171165
AccountCollectionFlowRetrieveParams(
172-
checkRequired("id", id),
166+
id,
173167
additionalHeaders.build(),
174168
additionalQueryParams.build(),
175169
)
176170
}
177171

178172
fun _pathParam(index: Int): String =
179173
when (index) {
180-
0 -> id
174+
0 -> id ?: ""
181175
else -> ""
182176
}
183177

modern-treasury-java-core/src/main/kotlin/com/moderntreasury/api/models/AccountCollectionFlowUpdateParams.kt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,19 @@ import com.moderntreasury.api.core.http.QueryParams
1818
import com.moderntreasury.api.errors.ModernTreasuryInvalidDataException
1919
import java.util.Collections
2020
import java.util.Objects
21+
import java.util.Optional
2122
import kotlin.jvm.optionals.getOrNull
2223

2324
/** update account_collection_flow */
2425
class AccountCollectionFlowUpdateParams
2526
private constructor(
26-
private val id: String,
27+
private val id: String?,
2728
private val body: AccountCollectionFlowUpdateRequest,
2829
private val additionalHeaders: Headers,
2930
private val additionalQueryParams: QueryParams,
3031
) : Params {
3132

32-
fun id(): String = id
33+
fun id(): Optional<String> = Optional.ofNullable(id)
3334

3435
/**
3536
* Required. The updated status of the account collection flow. Can only be used to mark a flow
@@ -63,7 +64,6 @@ private constructor(
6364
*
6465
* The following fields are required:
6566
* ```java
66-
* .id()
6767
* .status()
6868
* ```
6969
*/
@@ -89,7 +89,10 @@ private constructor(
8989
accountCollectionFlowUpdateParams.additionalQueryParams.toBuilder()
9090
}
9191

92-
fun id(id: String) = apply { this.id = id }
92+
fun id(id: String?) = apply { this.id = id }
93+
94+
/** Alias for calling [Builder.id] with `id.orElse(null)`. */
95+
fun id(id: Optional<String>) = id(id.getOrNull())
9396

9497
/**
9598
* Sets the entire request body.
@@ -238,15 +241,14 @@ private constructor(
238241
*
239242
* The following fields are required:
240243
* ```java
241-
* .id()
242244
* .status()
243245
* ```
244246
*
245247
* @throws IllegalStateException if any required field is unset.
246248
*/
247249
fun build(): AccountCollectionFlowUpdateParams =
248250
AccountCollectionFlowUpdateParams(
249-
checkRequired("id", id),
251+
id,
250252
body.build(),
251253
additionalHeaders.build(),
252254
additionalQueryParams.build(),
@@ -257,7 +259,7 @@ private constructor(
257259

258260
fun _pathParam(index: Int): String =
259261
when (index) {
260-
0 -> id
262+
0 -> id ?: ""
261263
else -> ""
262264
}
263265

modern-treasury-java-core/src/main/kotlin/com/moderntreasury/api/models/AccountDetailCreateParams.kt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ import kotlin.jvm.optionals.getOrNull
2525
class AccountDetailCreateParams
2626
private constructor(
2727
private val accountsType: AccountsType,
28-
private val accountId: String,
28+
private val accountId: String?,
2929
private val body: AccountDetailCreateRequest,
3030
private val additionalHeaders: Headers,
3131
private val additionalQueryParams: QueryParams,
3232
) : Params {
3333

3434
fun accountsType(): AccountsType = accountsType
3535

36-
fun accountId(): String = accountId
36+
fun accountId(): Optional<String> = Optional.ofNullable(accountId)
3737

3838
/**
3939
* The account number for the bank account.
@@ -83,7 +83,6 @@ private constructor(
8383
* The following fields are required:
8484
* ```java
8585
* .accountsType()
86-
* .accountId()
8786
* .accountNumber()
8887
* ```
8988
*/
@@ -110,7 +109,10 @@ private constructor(
110109

111110
fun accountsType(accountsType: AccountsType) = apply { this.accountsType = accountsType }
112111

113-
fun accountId(accountId: String) = apply { this.accountId = accountId }
112+
fun accountId(accountId: String?) = apply { this.accountId = accountId }
113+
114+
/** Alias for calling [Builder.accountId] with `accountId.orElse(null)`. */
115+
fun accountId(accountId: Optional<String>) = accountId(accountId.getOrNull())
114116

115117
/**
116118
* Sets the entire request body.
@@ -280,7 +282,6 @@ private constructor(
280282
* The following fields are required:
281283
* ```java
282284
* .accountsType()
283-
* .accountId()
284285
* .accountNumber()
285286
* ```
286287
*
@@ -289,7 +290,7 @@ private constructor(
289290
fun build(): AccountDetailCreateParams =
290291
AccountDetailCreateParams(
291292
checkRequired("accountsType", accountsType),
292-
checkRequired("accountId", accountId),
293+
accountId,
293294
body.build(),
294295
additionalHeaders.build(),
295296
additionalQueryParams.build(),
@@ -301,7 +302,7 @@ private constructor(
301302
fun _pathParam(index: Int): String =
302303
when (index) {
303304
0 -> accountsType.toString()
304-
1 -> accountId
305+
1 -> accountId ?: ""
305306
else -> ""
306307
}
307308

modern-treasury-java-core/src/main/kotlin/com/moderntreasury/api/models/AccountDetailDeleteParams.kt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@ import com.moderntreasury.api.core.toImmutable
1414
import com.moderntreasury.api.errors.ModernTreasuryInvalidDataException
1515
import java.util.Objects
1616
import java.util.Optional
17+
import kotlin.jvm.optionals.getOrNull
1718

1819
/** Delete a single account detail for an external account. */
1920
class AccountDetailDeleteParams
2021
private constructor(
2122
private val accountsType: AccountsType,
2223
private val accountId: String,
23-
private val id: String,
24+
private val id: String?,
2425
private val additionalHeaders: Headers,
2526
private val additionalQueryParams: QueryParams,
2627
private val additionalBodyProperties: Map<String, JsonValue>,
@@ -30,7 +31,7 @@ private constructor(
3031

3132
fun accountId(): String = accountId
3233

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

3536
fun _additionalBodyProperties(): Map<String, JsonValue> = additionalBodyProperties
3637

@@ -49,7 +50,6 @@ private constructor(
4950
* ```java
5051
* .accountsType()
5152
* .accountId()
52-
* .id()
5353
* ```
5454
*/
5555
@JvmStatic fun builder() = Builder()
@@ -80,7 +80,10 @@ private constructor(
8080

8181
fun accountId(accountId: String) = apply { this.accountId = accountId }
8282

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

8588
fun additionalHeaders(additionalHeaders: Headers) = apply {
8689
this.additionalHeaders.clear()
@@ -211,7 +214,6 @@ private constructor(
211214
* ```java
212215
* .accountsType()
213216
* .accountId()
214-
* .id()
215217
* ```
216218
*
217219
* @throws IllegalStateException if any required field is unset.
@@ -220,7 +222,7 @@ private constructor(
220222
AccountDetailDeleteParams(
221223
checkRequired("accountsType", accountsType),
222224
checkRequired("accountId", accountId),
223-
checkRequired("id", id),
225+
id,
224226
additionalHeaders.build(),
225227
additionalQueryParams.build(),
226228
additionalBodyProperties.toImmutable(),
@@ -234,7 +236,7 @@ private constructor(
234236
when (index) {
235237
0 -> accountsType.toString()
236238
1 -> accountId
237-
2 -> id
239+
2 -> id ?: ""
238240
else -> ""
239241
}
240242

modern-treasury-java-core/src/main/kotlin/com/moderntreasury/api/models/AccountDetailListParams.kt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import kotlin.jvm.optionals.getOrNull
1414
class AccountDetailListParams
1515
private constructor(
1616
private val accountsType: AccountsType,
17-
private val accountId: String,
17+
private val accountId: String?,
1818
private val afterCursor: String?,
1919
private val perPage: Long?,
2020
private val additionalHeaders: Headers,
@@ -23,7 +23,7 @@ private constructor(
2323

2424
fun accountsType(): AccountsType = accountsType
2525

26-
fun accountId(): String = accountId
26+
fun accountId(): Optional<String> = Optional.ofNullable(accountId)
2727

2828
fun afterCursor(): Optional<String> = Optional.ofNullable(afterCursor)
2929

@@ -43,7 +43,6 @@ private constructor(
4343
* The following fields are required:
4444
* ```java
4545
* .accountsType()
46-
* .accountId()
4746
* ```
4847
*/
4948
@JvmStatic fun builder() = Builder()
@@ -71,7 +70,10 @@ private constructor(
7170

7271
fun accountsType(accountsType: AccountsType) = apply { this.accountsType = accountsType }
7372

74-
fun accountId(accountId: String) = apply { this.accountId = accountId }
73+
fun accountId(accountId: String?) = apply { this.accountId = accountId }
74+
75+
/** Alias for calling [Builder.accountId] with `accountId.orElse(null)`. */
76+
fun accountId(accountId: Optional<String>) = accountId(accountId.getOrNull())
7577

7678
fun afterCursor(afterCursor: String?) = apply { this.afterCursor = afterCursor }
7779

@@ -196,15 +198,14 @@ private constructor(
196198
* The following fields are required:
197199
* ```java
198200
* .accountsType()
199-
* .accountId()
200201
* ```
201202
*
202203
* @throws IllegalStateException if any required field is unset.
203204
*/
204205
fun build(): AccountDetailListParams =
205206
AccountDetailListParams(
206207
checkRequired("accountsType", accountsType),
207-
checkRequired("accountId", accountId),
208+
accountId,
208209
afterCursor,
209210
perPage,
210211
additionalHeaders.build(),
@@ -215,7 +216,7 @@ private constructor(
215216
fun _pathParam(index: Int): String =
216217
when (index) {
217218
0 -> accountsType.toString()
218-
1 -> accountId
219+
1 -> accountId ?: ""
219220
else -> ""
220221
}
221222

0 commit comments

Comments
 (0)