Skip to content

Commit 7eb759b

Browse files
committed
Added UPGRADING note.
1 parent ff9b968 commit 7eb759b

File tree

5 files changed

+33
-2
lines changed

5 files changed

+33
-2
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,6 +1122,12 @@ rescue Strava::Errors::Fault => e
11221122
end
11231123
```
11241124

1125+
Faraday can optionally exclude HTTP method, path and query params from the errors raised. The client implementation options will now default to `Faraday::Response::RaiseError::DEFAULT_OPTIONS` with `include_request` set to `true`. You can change this behavior by setting `Strava::Web::RaiseResponseError::DEFAULT_OPTIONS`.
1126+
1127+
```ruby
1128+
Strava::Web::RaiseResponseError::DEFAULT_OPTIONS = { include_request: false }
1129+
```
1130+
11251131
## Tools
11261132

11271133
For a complete set of command-line tools, check out [strava-ruby-cli](https://github.com/dblock/strava-ruby-cli) built on top of this gem.

UPGRADING.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Upgrading Strava-Ruby-Client
22

3+
### Upgrading to >= 2.3.0
4+
5+
Faraday can optionally exclude HTTP method, path and query params from the errors raised. The client implementation options will now default to `Faraday::Response::RaiseError::DEFAULT_OPTIONS` with `include_request` set to `true`. You can change this behavior by setting `Strava::Web::RaiseResponseError::DEFAULT_OPTIONS`.
6+
7+
```ruby
8+
Strava::Web::RaiseResponseError::DEFAULT_OPTIONS = { include_request: false }
9+
```
10+
11+
See [#91](https://github.com/dblock/strava-ruby-client/pull/91) for details.
12+
313
### Upgrading to >= 2.2.0
414

515
Support for Ruby 2.x has been dropped. The minimum required Ruby version is now 3.0.0.
@@ -45,4 +55,4 @@ client = Strava::Api::Client.new(ca_file: OpenSSL::X509::DEFAULT_CERT_FILE, ca_p
4555

4656
The library was upgraded to require Faraday 1.0 or newer. Change all references to `Faraday::Error::ResourceNotFound` or `Faraday::Error::ConnectionFailed` to `Faraday::ConnectionFailed` and `Faraday::ResourceNotFound` respectively.
4757

48-
See [#30](https://github.com/dblock/strava-ruby-client/pull/30) for more details.
58+
See [#30](https://github.com/dblock/strava-ruby-client/pull/30) for details.

lib/strava/errors/ratelimit_error.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@ def initialize(env, response)
99
@ratelimit = Strava::Api::Ratelimit.new(env.response)
1010
super(response)
1111
end
12+
13+
def message
14+
response[:body]['message'] || super
15+
end
16+
17+
def headers
18+
response[:headers]
19+
end
20+
21+
def errors
22+
response[:body]['errors']
23+
end
1224
end
1325
end
1426
end

spec/fixtures/strava/client/activity_with_ratelimit_exceeded.yml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/strava/api/client_spec.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@
4949
expect(error.ratelimit.exceeded?).to be(true)
5050
expect(error.ratelimit.exceeded).to eql({ fifteen_minutes_remaining: 0 })
5151
expect(error.response[:request]).to be_nil
52+
expect(error.message).to eq 'Too Many Requests'
53+
expect(error.headers).to be_a Hash
54+
expect(error.errors).to eq 'Rate Limit Exceeded'
5255
end
5356
end
5457
end

0 commit comments

Comments
 (0)