diff --git a/.fernignore b/.fernignore index b6e71ce..52b49f5 100644 --- a/.fernignore +++ b/.fernignore @@ -2,3 +2,5 @@ src/wrapper/ src/core/auth/OAuthTokenProvider.ts src/index.ts + +README.md diff --git a/README.md b/README.md index e6f72c2..d94f348 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,10 @@ Instantiate and use the client with the following: ```typescript import { ChariotClient } from "chariot"; -const client = new ChariotClient({ token: "YOUR_TOKEN" }); +const client = new ChariotClient({ + clientId: "YOUR_CLIENT_ID", + clientSecret: "YOUR_CLIENT_SECRET", +}); await client.nonprofits.create({ user: { email: "ben.give@co.com", @@ -59,6 +62,36 @@ try { } ``` +## Automatic Pagination + +List endpoints are paginated. The SDK provides an iterator so that you +can simply loop over the items: + +```ts +const result = await client.events.list(); +for await (const event of result) { + console.log(event); +} +``` + +You can also iterate page-by-page: + +```ts +let page = await client.events.list(); +for (const event of page.data) { + console.log(event); +} +``` + +or manually: + +```ts +while (page.hasNextPage()) { + page = page.getNextPage(); + // ... +} +``` + ## Advanced ### Retries