Skip to content

Commit b5834d8

Browse files
authored
Chore: Add pagination metadata access in Examples (#873)
1 parent f03d203 commit b5834d8

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

EXAMPLES.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,27 @@ while (users.hasNext()) {
190190
}
191191
```
192192

193+
### Accessing pagination metadata
194+
195+
List responses are wrapped in a metadata envelope (`total`, `start`, `limit`, `length`, etc.).
196+
The items come from the iterable as usual; the envelope is read via `getResponse()`, typed to
197+
the endpoint's response class (for users, `ListUsersOffsetPaginatedResponseContent`):
198+
199+
```java
200+
SyncPagingIterable<UserResponseSchema> page = client.users().list(
201+
ListUsersRequestParameters.builder().perPage(50).build()
202+
);
203+
204+
Optional<ListUsersOffsetPaginatedResponseContent> listUsersOffsetPaginatedResponseContentOptional = resp.getResponse();
205+
listUsersOffsetPaginatedResponseContentOptional.ifPresent(m -> {
206+
m.getTotal().ifPresent(total -> System.out.println("total: " + total));
207+
m.getStart().ifPresent(start -> System.out.println("start: " + start));
208+
m.getLimit().ifPresent(limit -> System.out.println("limit: " + limit));
209+
m.getLength().ifPresent(length -> System.out.println("length: " + length));
210+
});
211+
212+
```
213+
193214
### Accessing raw HTTP responses
194215

195216
Use `withRawResponse()` to access HTTP response metadata:

0 commit comments

Comments
 (0)