From 20f4f55226a089e4a805c22b0c49ae9a310e6282 Mon Sep 17 00:00:00 2001 From: tanya732 Date: Wed, 3 Jun 2026 13:25:39 +0530 Subject: [PATCH] Chore: Add pagination metadata access in Examples --- EXAMPLES.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/EXAMPLES.md b/EXAMPLES.md index bb2afc8c..67608c55 100644 --- a/EXAMPLES.md +++ b/EXAMPLES.md @@ -190,6 +190,27 @@ while (users.hasNext()) { } ``` +### Accessing pagination metadata + +List responses are wrapped in a metadata envelope (`total`, `start`, `limit`, `length`, etc.). +The items come from the iterable as usual; the envelope is read via `getResponse()`, typed to +the endpoint's response class (for users, `ListUsersOffsetPaginatedResponseContent`): + +```java +SyncPagingIterable page = client.users().list( + ListUsersRequestParameters.builder().perPage(50).build() +); + +Optional listUsersOffsetPaginatedResponseContentOptional = resp.getResponse(); +listUsersOffsetPaginatedResponseContentOptional.ifPresent(m -> { + m.getTotal().ifPresent(total -> System.out.println("total: " + total)); + m.getStart().ifPresent(start -> System.out.println("start: " + start)); + m.getLimit().ifPresent(limit -> System.out.println("limit: " + limit)); + m.getLength().ifPresent(length -> System.out.println("length: " + length)); +}); + +``` + ### Accessing raw HTTP responses Use `withRawResponse()` to access HTTP response metadata: