Skip to content

Commit 00b0b73

Browse files
chore: add more examples to README.md (#16)
1 parent 353250b commit 00b0b73

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

README.md

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,26 @@ finch = FinchAPI::Client.new(access_token: "My Access Token")
4040

4141
page = finch.hris.directory.list
4242

43-
item = page.individuals[0]
43+
puts(page.id)
44+
```
45+
46+
## Pagination
47+
48+
List methods in the Finch API are paginated.
4449

45-
puts(item.id)
50+
This library provides auto-paginating iterators with each list response, so you do not have to request successive pages manually:
51+
52+
```ruby
53+
page = finch.hris.directory.list
54+
55+
# Fetch single item from page.
56+
directory = page.individuals[0]
57+
puts(directory.id)
58+
59+
# Automatically fetches more pages as needed.
60+
page.auto_paging_each do |directory|
61+
puts(directory.id)
62+
end
4663
```
4764

4865
### Errors
@@ -111,9 +128,9 @@ finch.hris.directory.list(request_options: {timeout: 5})
111128

112129
## Sorbet Support
113130

114-
This library is written with [Sorbet type definitions](https://sorbet.org/docs/rbi). However, there is no runtime dependency on the Sorbet runtime.
131+
This library is written with [Sorbet type definitions](https://sorbet.org/docs/rbi). However, there is no runtime dependency on the `sorbet-runtime`.
115132

116-
What this means is that while you can use Sorbet to type check your code statically, and benefit from the [Sorbet Language Server](https://sorbet.org/docs/lsp) in your editor, there is no runtime type checking and execution overhead from Sorbet.
133+
What this means is that while you can use Sorbet to type check your code statically, and benefit from the [Sorbet Language Server](https://sorbet.org/docs/lsp) in your editor, there is no runtime type checking and execution overhead from Sorbet itself.
117134

118135
Due to limitations with the Sorbet type system, where a method otherwise can take an instance of `FinchAPI::BaseModel` class, you will need to use the `**` splat operator to pass the arguments:
119136

0 commit comments

Comments
 (0)