Skip to content

Commit 9b1ea1d

Browse files
chore: add sorbet section to README (#117)
1 parent 13e5aee commit 9b1ea1d

File tree

1 file changed

+27
-19
lines changed

1 file changed

+27
-19
lines changed

README.md

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

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

65
## Documentation
76

@@ -11,8 +10,7 @@ The underlying REST API documentation can be found on [docs.withorb.com](https:/
1110

1211
## Installation
1312

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

1715
```ruby
1816
gem "orb", git: "https://github.com/orbcorp/orb-ruby", branch: "main"
@@ -24,8 +22,7 @@ To fetch an initial copy of the gem:
2422
bundle install
2523
```
2624

27-
To update the version used by your application when updates are pushed to
28-
GitHub:
25+
To update the version used by your application when updates are pushed to GitHub:
2926

3027
```sh
3128
bundle update orb
@@ -48,9 +45,7 @@ puts(customer.id)
4845

4946
### Errors
5047

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-
`Orb::Error` will be thrown:
48+
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 `Orb::Error` will be thrown:
5449

5550
```ruby
5651
begin
@@ -78,10 +73,9 @@ Error codes are as followed:
7873

7974
### Retries
8075

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.
76+
Certain errors will be automatically retried 2 times by default, with a short exponential backoff.
77+
78+
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.
8579

8680
You can use the `max_retries` option to configure or disable this:
8781

@@ -102,8 +96,8 @@ orb.customers.create(
10296
### Timeouts
10397

10498
By default, requests will time out after 60 seconds.
105-
Timeouts are applied separately to the initial connection and the overall request time,
106-
so in some cases a request could wait 2\*timeout seconds before it fails.
99+
100+
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.
107101

108102
You can use the `timeout` option to configure or disable this:
109103

@@ -121,12 +115,26 @@ orb.customers.create(
121115
)
122116
```
123117

118+
## Sorbet Support
119+
120+
This library is written with [Sorbet type definitions](https://sorbet.org/docs/rbi). However, there is no runtime dependency on the Sorbet runtime.
121+
122+
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.
123+
124+
Due to limitations with the Sorbet type system, where a method otherwise can take an instance of `Orb::BaseModel` class, you will need to use the `**` splat operator to pass the arguments:
125+
126+
```ruby
127+
model = CustomerCreateParams.new(email: "example-customer@withorb.com", name: "My Customer")
128+
129+
orb.customers.create(**model)
130+
```
131+
124132
## Versioning
125133

126-
This package follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions. As the
127-
library is in initial development and has a major version of `0`, APIs may change
128-
at any time.
134+
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.
135+
136+
This package considers improvements to the (non-runtime) `*.rbi` and `*.rbs` type definitions to be non-breaking changes.
129137

130138
## Requirements
131139

132-
Ruby 3.0 or higher.
140+
Ruby 3.0.0 or higher.

0 commit comments

Comments
 (0)