Skip to content

Commit 353250b

Browse files
chore: add sorbet section to README (#15)
1 parent 6d5ad33 commit 353250b

File tree

1 file changed

+30
-20
lines changed

1 file changed

+30
-20
lines changed

README.md

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Finch Ruby API library
22

3-
The Finch Ruby library provides convenient access to the Finch REST API from any Ruby 3.0.0+
4-
application.
3+
The Finch Ruby library provides convenient access to the Finch REST API from any Ruby 3.0.0+ application.
54

65
It is generated with [Stainless](https://www.stainless.com/).
76

@@ -13,8 +12,7 @@ The underlying REST API documentation can be found on [developer.tryfinch.com](h
1312

1413
## Installation
1514

16-
To use this gem during the beta, install directly from GitHub with Bundler by
17-
adding the following to your application's `Gemfile`:
15+
To use this gem during the beta, install directly from GitHub with Bundler by adding the following to your application's `Gemfile`:
1816

1917
```ruby
2018
gem "finch-api", git: "https://github.com/Finch-API/finch-api-ruby", branch: "main"
@@ -26,8 +24,7 @@ To fetch an initial copy of the gem:
2624
bundle install
2725
```
2826

29-
To update the version used by your application when updates are pushed to
30-
GitHub:
27+
To update the version used by your application when updates are pushed to GitHub:
3128

3229
```sh
3330
bundle update finch-api
@@ -43,14 +40,14 @@ finch = FinchAPI::Client.new(access_token: "My Access Token")
4340

4441
page = finch.hris.directory.list
4542

46-
puts(page.id)
43+
item = page.individuals[0]
44+
45+
puts(item.id)
4746
```
4847

4948
### Errors
5049

51-
When the library is unable to connect to the API, or if the API returns a
52-
non-success status code (i.e., 4xx or 5xx response), a subclass of
53-
`FinchAPI::Error` will be thrown:
50+
When the library is unable to connect to the API, or if the API returns a non-success status code (i.e., 4xx or 5xx response), a subclass of `FinchAPI::Error` will be thrown:
5451

5552
```ruby
5653
begin
@@ -78,10 +75,9 @@ Error codes are as followed:
7875

7976
### Retries
8077

81-
Certain errors will be automatically retried 2 times by default, with a short
82-
exponential backoff. Connection errors (for example, due to a network
83-
connectivity problem), 408 Request Timeout, 409 Conflict, 429 Rate Limit, >=500 Internal errors,
84-
and timeouts will all be retried by default.
78+
Certain errors will be automatically retried 2 times by default, with a short exponential backoff.
79+
80+
Connection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict, 429 Rate Limit, >=500 Internal errors, and timeouts will all be retried by default.
8581

8682
You can use the `max_retries` option to configure or disable this:
8783

@@ -98,8 +94,8 @@ finch.hris.directory.list(request_options: {max_retries: 5})
9894
### Timeouts
9995

10096
By default, requests will time out after 60 seconds.
101-
Timeouts are applied separately to the initial connection and the overall request time,
102-
so in some cases a request could wait 2\*timeout seconds before it fails.
97+
98+
Timeouts are applied separately to the initial connection and the overall request time, so in some cases a request could wait 2\*timeout seconds before it fails.
10399

104100
You can use the `timeout` option to configure or disable this:
105101

@@ -113,12 +109,26 @@ finch = FinchAPI::Client.new(
113109
finch.hris.directory.list(request_options: {timeout: 5})
114110
```
115111

112+
## Sorbet Support
113+
114+
This library is written with [Sorbet type definitions](https://sorbet.org/docs/rbi). However, there is no runtime dependency on the Sorbet runtime.
115+
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.
117+
118+
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:
119+
120+
```ruby
121+
model = DirectoryListParams.new
122+
123+
finch.hris.directory.list(**model)
124+
```
125+
116126
## Versioning
117127

118-
This package follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions. As the
119-
library is in initial development and has a major version of `0`, APIs may change
120-
at any time.
128+
This package follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions. As the library is in initial development and has a major version of `0`, APIs may change at any time.
129+
130+
This package considers improvements to the (non-runtime) `*.rbi` and `*.rbs` type definitions to be non-breaking changes.
121131

122132
## Requirements
123133

124-
Ruby 3.0 or higher.
134+
Ruby 3.0.0 or higher.

0 commit comments

Comments
 (0)