Skip to content

Commit e9a29bf

Browse files
committed
refactor(api)!: replace transactionToken param in favour of transactionTokens
This commit also adds more enum members to the `eventTypes` param. # Migration The `transactionTokens` query param now accepts a list of transaction tokens instead of a single transaction token. Before: `DisputeListParams.builder().transactionToken("<token>")` After: `DisputeListParams.builder().transactionTokens(listOf("<token>"))`
1 parent 9251d2a commit e9a29bf

14 files changed

Lines changed: 261 additions & 69 deletions

README.md

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ LithicClient client = LithicOkHttpClient.builder()
5959
.build();
6060
```
6161

62-
| Property | Environment variable | Required | Default value |
63-
| -------- | ------------------------- | -------- | ------------- |
64-
| apiKey | `LITHIC_API_KEY` | true ||
65-
| webhookSecret | `LITHIC_WEBHOOK_SECRET` | false ||
62+
| Property | Environment variable | Required | Default value |
63+
| ------------- | ----------------------- | -------- | ------------- |
64+
| apiKey | `LITHIC_API_KEY` | true | |
65+
| webhookSecret | `LITHIC_WEBHOOK_SECRET` | false | |
6666

6767
Read the documentation for more configuration options.
6868

@@ -139,12 +139,6 @@ To write an unrecognized enum value, pass a string to the wrapper class's `of` c
139139
Card.builder().state(State.of("NEW_STATE")).build()
140140
```
141141

142-
143-
144-
145-
146-
147-
148142
## Requests
149143

150144
### Parameters and bodies
@@ -201,7 +195,6 @@ if (state.isMissing()) {
201195
}
202196
```
203197

204-
205198
### Additional model properties
206199

207200
Sometimes, the server response may include additional properties that are not yet available in this library's types. You can access them using the model's `_additionalProperties` method:
@@ -210,7 +203,6 @@ Sometimes, the server response may include additional properties that are not ye
210203
JsonValue secret = card._additionalProperties().get("secret_field");
211204
```
212205

213-
214206
---
215207

216208
## Pagination
@@ -276,7 +268,6 @@ You can use `lithic.webhooks().verifySignature(body, headers, secret?)` or `lith
276268

277269
---
278270

279-
280271
## Error handling
281272

282273
This library throws exceptions in a single hierarchy for easy handling:
@@ -303,24 +294,32 @@ This library throws exceptions in a single hierarchy for easy handling:
303294
## Network options
304295

305296
### Retries
297+
306298
Requests that experience certain errors are automatically retried 2 times by default, with a short exponential backoff. Connection errors (for example, due to a network connectivity problem), 409 Conflict, 429 Rate Limit, and >=500 Internal errors will all be retried by default.
307299
You can provide a `maxRetries` on the client builder to configure this:
300+
308301
```java
309302
LithicClient client = LithicOkHttpClient.builder()
310303
.fromEnv()
311304
.maxRetries(4)
312305
.build();
313306
```
307+
314308
### Timeouts
309+
315310
Requests time out after 60 seconds by default. You can configure this on the client builder:
311+
316312
```java
317313
LithicClient client = LithicOkHttpClient.builder()
318314
.fromEnv()
319315
.timeout(Duration.ofSeconds(30))
320316
.build();
321317
```
318+
322319
### Proxies
320+
323321
Requests can be routed through a proxy. You can configure this on the client builder:
322+
324323
```java
325324
LithicClient client = LithicOkHttpClient.builder()
326325
.fromEnv()
@@ -330,11 +329,14 @@ LithicClient client = LithicOkHttpClient.builder()
330329
))
331330
.build();
332331
```
332+
333333
### Environments
334+
334335
Requests are made to the production environment by default. You can connect to other environments, like `sandbox`, via the client builder:
336+
335337
```java
336338
LithicClient client = LithicOkHttpClient.builder()
337339
.fromEnv()
338340
.sandbox()
339341
.build();
340-
```
342+
```

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

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import java.util.Optional
1313

1414
class DisputeListParams
1515
constructor(
16-
private val transactionToken: String?,
16+
private val transactionTokens: List<String>?,
1717
private val status: Status?,
1818
private val pageSize: Long?,
1919
private val begin: OffsetDateTime?,
@@ -24,7 +24,7 @@ constructor(
2424
private val additionalHeaders: Map<String, List<String>>,
2525
) {
2626

27-
fun transactionToken(): Optional<String> = Optional.ofNullable(transactionToken)
27+
fun transactionTokens(): Optional<List<String>> = Optional.ofNullable(transactionTokens)
2828

2929
fun status(): Optional<Status> = Optional.ofNullable(status)
3030

@@ -41,7 +41,9 @@ constructor(
4141
@JvmSynthetic
4242
internal fun getQueryParams(): Map<String, List<String>> {
4343
val params = mutableMapOf<String, List<String>>()
44-
this.transactionToken?.let { params.put("transaction_token", listOf(it.toString())) }
44+
this.transactionTokens?.let {
45+
params.put("transaction_tokens", listOf(it.joinToString(separator = ",")))
46+
}
4547
this.status?.let { params.put("status", listOf(it.toString())) }
4648
this.pageSize?.let { params.put("page_size", listOf(it.toString())) }
4749
this.begin?.let { params.put("begin", listOf(it.toString())) }
@@ -64,7 +66,7 @@ constructor(
6466
}
6567

6668
return other is DisputeListParams &&
67-
this.transactionToken == other.transactionToken &&
69+
this.transactionTokens == other.transactionTokens &&
6870
this.status == other.status &&
6971
this.pageSize == other.pageSize &&
7072
this.begin == other.begin &&
@@ -77,7 +79,7 @@ constructor(
7779

7880
override fun hashCode(): Int {
7981
return Objects.hash(
80-
transactionToken,
82+
transactionTokens,
8183
status,
8284
pageSize,
8385
begin,
@@ -90,7 +92,7 @@ constructor(
9092
}
9193

9294
override fun toString() =
93-
"DisputeListParams{transactionToken=$transactionToken, status=$status, pageSize=$pageSize, begin=$begin, end=$end, startingAfter=$startingAfter, endingBefore=$endingBefore, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}"
95+
"DisputeListParams{transactionTokens=$transactionTokens, status=$status, pageSize=$pageSize, begin=$begin, end=$end, startingAfter=$startingAfter, endingBefore=$endingBefore, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders}"
9496

9597
fun toBuilder() = Builder().from(this)
9698

@@ -102,7 +104,7 @@ constructor(
102104
@NoAutoDetect
103105
class Builder {
104106

105-
private var transactionToken: String? = null
107+
private var transactionTokens: List<String>? = null
106108
private var status: Status? = null
107109
private var pageSize: Long? = null
108110
private var begin: OffsetDateTime? = null
@@ -114,7 +116,7 @@ constructor(
114116

115117
@JvmSynthetic
116118
internal fun from(disputeListParams: DisputeListParams) = apply {
117-
this.transactionToken = disputeListParams.transactionToken
119+
this.transactionTokens = disputeListParams.transactionTokens
118120
this.status = disputeListParams.status
119121
this.pageSize = disputeListParams.pageSize
120122
this.begin = disputeListParams.begin
@@ -125,9 +127,9 @@ constructor(
125127
additionalHeaders(disputeListParams.additionalHeaders)
126128
}
127129

128-
/** List disputes of a given transaction token. */
129-
fun transactionToken(transactionToken: String) = apply {
130-
this.transactionToken = transactionToken
130+
/** Transaction tokens to filter by. */
131+
fun transactionTokens(transactionTokens: List<String>) = apply {
132+
this.transactionTokens = transactionTokens
131133
}
132134

133135
/** List disputes of a specific status. */
@@ -202,7 +204,7 @@ constructor(
202204

203205
fun build(): DisputeListParams =
204206
DisputeListParams(
205-
transactionToken,
207+
transactionTokens?.toUnmodifiable(),
206208
status,
207209
pageSize,
208210
begin,

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

Lines changed: 68 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,17 @@ private constructor(
3737
/**
3838
* Event types:
3939
*
40+
* - `card.created` - Notification that a card has been created.
41+
* - `card.shipped` - Physical card shipment notification. See
42+
* https://docs.lithic.com/docs/cards#physical-card-shipped-webhook.
43+
* - `card_transaction.updated` - Transaction Lifecycle webhook. See
44+
* https://docs.lithic.com/docs/transaction-webhooks.
4045
* - `dispute.updated` - A dispute has been updated.
4146
* - `digital_wallet.tokenization_approval_request` - Card network's request to Lithic to
4247
* activate a digital wallet token.
48+
* - `digital_wallet.tokenization_two_factor_authentication_code` - A code to be passed to an
49+
* end user to complete digital wallet authentication. See
50+
* https://docs.lithic.com/docs/tokenization-control#digital-wallet-tokenization-auth-code.
4351
*/
4452
fun eventType(): EventType = eventType.getRequired("event_type")
4553

@@ -58,9 +66,17 @@ private constructor(
5866
/**
5967
* Event types:
6068
*
69+
* - `card.created` - Notification that a card has been created.
70+
* - `card.shipped` - Physical card shipment notification. See
71+
* https://docs.lithic.com/docs/cards#physical-card-shipped-webhook.
72+
* - `card_transaction.updated` - Transaction Lifecycle webhook. See
73+
* https://docs.lithic.com/docs/transaction-webhooks.
6174
* - `dispute.updated` - A dispute has been updated.
6275
* - `digital_wallet.tokenization_approval_request` - Card network's request to Lithic to
6376
* activate a digital wallet token.
77+
* - `digital_wallet.tokenization_two_factor_authentication_code` - A code to be passed to an
78+
* end user to complete digital wallet authentication. See
79+
* https://docs.lithic.com/docs/tokenization-control#digital-wallet-tokenization-auth-code.
6480
*/
6581
@JsonProperty("event_type") @ExcludeMissing fun _eventType() = eventType
6682

@@ -152,18 +168,34 @@ private constructor(
152168
/**
153169
* Event types:
154170
*
171+
* - `card.created` - Notification that a card has been created.
172+
* - `card.shipped` - Physical card shipment notification. See
173+
* https://docs.lithic.com/docs/cards#physical-card-shipped-webhook.
174+
* - `card_transaction.updated` - Transaction Lifecycle webhook. See
175+
* https://docs.lithic.com/docs/transaction-webhooks.
155176
* - `dispute.updated` - A dispute has been updated.
156177
* - `digital_wallet.tokenization_approval_request` - Card network's request to Lithic to
157178
* activate a digital wallet token.
179+
* - `digital_wallet.tokenization_two_factor_authentication_code` - A code to be passed to
180+
* an end user to complete digital wallet authentication. See
181+
* https://docs.lithic.com/docs/tokenization-control#digital-wallet-tokenization-auth-code.
158182
*/
159183
fun eventType(eventType: EventType) = eventType(JsonField.of(eventType))
160184

161185
/**
162186
* Event types:
163187
*
188+
* - `card.created` - Notification that a card has been created.
189+
* - `card.shipped` - Physical card shipment notification. See
190+
* https://docs.lithic.com/docs/cards#physical-card-shipped-webhook.
191+
* - `card_transaction.updated` - Transaction Lifecycle webhook. See
192+
* https://docs.lithic.com/docs/transaction-webhooks.
164193
* - `dispute.updated` - A dispute has been updated.
165194
* - `digital_wallet.tokenization_approval_request` - Card network's request to Lithic to
166195
* activate a digital wallet token.
196+
* - `digital_wallet.tokenization_two_factor_authentication_code` - A code to be passed to
197+
* an end user to complete digital wallet authentication. See
198+
* https://docs.lithic.com/docs/tokenization-control#digital-wallet-tokenization-auth-code.
167199
*/
168200
@JsonProperty("event_type")
169201
@ExcludeMissing
@@ -237,39 +269,70 @@ private constructor(
237269

238270
companion object {
239271

240-
@JvmField val DISPUTE_UPDATED = EventType(JsonField.of("dispute.updated"))
272+
@JvmField val CARD_CREATED = EventType(JsonField.of("card.created"))
273+
274+
@JvmField val CARD_SHIPPED = EventType(JsonField.of("card.shipped"))
275+
276+
@JvmField
277+
val CARD_TRANSACTION_UPDATED = EventType(JsonField.of("card_transaction.updated"))
241278

242279
@JvmField
243280
val DIGITAL_WALLET_TOKENIZATION_APPROVAL_REQUEST =
244281
EventType(JsonField.of("digital_wallet.tokenization_approval_request"))
245282

283+
@JvmField
284+
val DIGITAL_WALLET_TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE =
285+
EventType(
286+
JsonField.of("digital_wallet.tokenization_two_factor_authentication_code")
287+
)
288+
289+
@JvmField val DISPUTE_UPDATED = EventType(JsonField.of("dispute.updated"))
290+
246291
@JvmStatic fun of(value: String) = EventType(JsonField.of(value))
247292
}
248293

249294
enum class Known {
250-
DISPUTE_UPDATED,
295+
CARD_CREATED,
296+
CARD_SHIPPED,
297+
CARD_TRANSACTION_UPDATED,
251298
DIGITAL_WALLET_TOKENIZATION_APPROVAL_REQUEST,
299+
DIGITAL_WALLET_TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE,
300+
DISPUTE_UPDATED,
252301
}
253302

254303
enum class Value {
255-
DISPUTE_UPDATED,
304+
CARD_CREATED,
305+
CARD_SHIPPED,
306+
CARD_TRANSACTION_UPDATED,
256307
DIGITAL_WALLET_TOKENIZATION_APPROVAL_REQUEST,
308+
DIGITAL_WALLET_TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE,
309+
DISPUTE_UPDATED,
257310
_UNKNOWN,
258311
}
259312

260313
fun value(): Value =
261314
when (this) {
262-
DISPUTE_UPDATED -> Value.DISPUTE_UPDATED
315+
CARD_CREATED -> Value.CARD_CREATED
316+
CARD_SHIPPED -> Value.CARD_SHIPPED
317+
CARD_TRANSACTION_UPDATED -> Value.CARD_TRANSACTION_UPDATED
263318
DIGITAL_WALLET_TOKENIZATION_APPROVAL_REQUEST ->
264319
Value.DIGITAL_WALLET_TOKENIZATION_APPROVAL_REQUEST
320+
DIGITAL_WALLET_TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE ->
321+
Value.DIGITAL_WALLET_TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE
322+
DISPUTE_UPDATED -> Value.DISPUTE_UPDATED
265323
else -> Value._UNKNOWN
266324
}
267325

268326
fun known(): Known =
269327
when (this) {
270-
DISPUTE_UPDATED -> Known.DISPUTE_UPDATED
328+
CARD_CREATED -> Known.CARD_CREATED
329+
CARD_SHIPPED -> Known.CARD_SHIPPED
330+
CARD_TRANSACTION_UPDATED -> Known.CARD_TRANSACTION_UPDATED
271331
DIGITAL_WALLET_TOKENIZATION_APPROVAL_REQUEST ->
272332
Known.DIGITAL_WALLET_TOKENIZATION_APPROVAL_REQUEST
333+
DIGITAL_WALLET_TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE ->
334+
Known.DIGITAL_WALLET_TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE
335+
DISPUTE_UPDATED -> Known.DISPUTE_UPDATED
273336
else -> throw LithicInvalidDataException("Unknown EventType: $value")
274337
}
275338

0 commit comments

Comments
 (0)