Skip to content

Commit 566f588

Browse files
fix: update README
fix: update README
1 parent 63de3ee commit 566f588

1 file changed

Lines changed: 27 additions & 21 deletions

File tree

README.md

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ The Lithic Java SDK provides convenient access to the Lithic REST API from appli
44

55
This package is currently in beta (pre-v1.0.0). We expect some breaking changes to rarely-used areas of the SDK, and appreciate your [feedback](mailto:sdk-feedback@lithic.com).
66

7+
The Lithic Java SDK is similar to the Lithic Kotlin SDK but with minor differences that make it more ergonomic for use in Java, such as `Optional` instead of nullable values, `Stream` instead of `Sequence`, and `CompletableFuture` instead of suspend functions.
8+
79
## Documentation
810

911
The API documentation can be found [here](https://docs.lithic.com).
@@ -46,7 +48,7 @@ LithicClient client = LithicOkHttpClient.builder()
4648
Alternately, use `LithicOkHttpClient.fromEnv()` to read client arguments from environment variables:
4749

4850
```java
49-
LithicClient client = LithicClient.fromEnv();
51+
LithicClient client = LithicOkHttpClient.fromEnv();
5052

5153
// Note: you can also call fromEnv() from the client builder, for example if you need to set additional properties
5254
LithicClient client = LithicOkHttpClient.builder()
@@ -119,16 +121,13 @@ this SDK. If an unrecognized value is found, the enum is set to a special sentin
119121
```java
120122
switch (card.state().value()) {
121123
case Card.State.Value.CLOSED:
122-
case Card.State.Value.OPEN:
123-
case Card.State.Value.PAUSED:
124-
case Card.State.Value.PENDING_ACTIVATION:
125-
case Card.State.Value.PENDING_FULFILLMENT:
126124
// ... handle recognized enum values
127-
return;
125+
break;
126+
...
128127
case Card.State.Value._UNKNOWN:
129-
// ... handle unrecognized enum value as string
130128
String cardState = card.state().asString();
131-
return;
129+
// ... handle unrecognized enum value as string
130+
break;
132131
}
133132
```
134133

@@ -173,7 +172,7 @@ Model properties that are optional or allow a null value are represented as `Opt
173172

174173
```java
175174
// Card.cvv() returns Optional<String>
176-
card.cvv().isPresent(); // false
175+
card.cvv().isPresent(); // false;
177176
```
178177

179178
### Response properties as JSON
@@ -187,7 +186,7 @@ JsonField state() = card._state();
187186
if (state().isMissing()) {
188187
// Value was not specified in the JSON response
189188
} else if (state().isNull()) {
190-
// Value was provided as a literall null
189+
// Value was provided as a literal null
191190
} else {
192191
// See if value was provided as a string
193192
Optional<String> jsonString = state().asString();
@@ -223,8 +222,8 @@ for (Card card : page.autoPager()) {
223222

224223
// As a Stream:
225224
client.cards().list(params).autoPager().stream()
226-
.limit(50)
227-
.forEach(card -> System.out.println(card));
225+
.limit(50)
226+
.forEach(card -> System.out.println(card));
228227
```
229228

230229
Note that fetching each page blocks the current thread.
@@ -239,13 +238,11 @@ A page of results has a `data()` method to fetch the list of objects, as well as
239238
```java
240239
CardListPage page = client.cards().list(params);
241240
while (page != null) {
242-
System.out.println(page.FIXME());
241+
for (Card card : page.data()) {
242+
System.out.println(card);
243+
}
243244

244-
for (Card card : page.data()) {
245-
System.out.println(card);
246-
}
247-
248-
page = page.getNextPage().orElse(null);
245+
page = page.getNextPage().orElse(null);
249246
}
250247
```
251248

@@ -292,21 +289,30 @@ Requests that experience certain errors are automatically retried 2 times by def
292289
You can provide a `maxRetries` on the client builder to configure this:
293290

294291
```java
295-
LithicClient client = LithicOkHttpClient.builder().fromEnv().maxRetries(4).build();
292+
LithicClient client = LithicOkHttpClient.builder()
293+
.fromEnv()
294+
.maxRetries(4)
295+
.build();
296296
```
297297

298298
### Timeouts
299299

300300
Requests time out after 60 seconds by default. You can configure this on the client builder:
301301

302302
```java
303-
LithicClient client = LithicOkHttpClient.builder().fromEnv().timeout(Duration.ofSeconds(30)).build();
303+
LithicClient client = LithicOkHttpClient.builder()
304+
.fromEnv()
305+
.timeout(Duration.ofSeconds(30))
306+
.build();
304307
```
305308

306309
### Environments
307310

308311
Requests are made to the production environment by default. You can connect to other environments, like `sandbox`, via the client builder:
309312

310313
```java
311-
LithicClient client = LithicOkHttpClient.builder().fromEnv().sandbox().build()
314+
LithicClient client = LithicOkHttpClient.builder()
315+
.fromEnv()
316+
.sandbox()
317+
.build();
312318
```

0 commit comments

Comments
 (0)