seatsio 31.0.0 → 32.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +8 -0
- data/lib/seatsio/httpClient.rb +21 -10
- data/lib/seatsio/pagination/cursor.rb +0 -2
- data/lib/seatsio/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a4c05feef8448daa977bdc2148b893bd92986ba8da80765f23b5dc80ac57f9e
|
4
|
+
data.tar.gz: aa0229bf2f040f406ac18b788b74fa540a16420de533cdecbe8ed1aec5abdf26
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f6d5d72e8e7defd3f34b8bbb042e60440047a0e705d62b6f71053cd8f59eacc34bdc62f1bf55c56cd44433ba621fa053eff782382bceb8978c8446140f0f23a
|
7
|
+
data.tar.gz: 2ff422ca32191907b0c22659ad8f6a295f74e4843c2bc3c96be27c2a208486e36ad410696159f27c3665fffc64307ba20e9e64e024b2fc0c46abbfb59d499ddc
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -113,3 +113,11 @@ This exception contains a message string describing what went wrong, and also tw
|
|
113
113
|
|
114
114
|
* *errors*: a list of errors that the server returned. In most cases, this array will contain only one element, an instance of ApiError, containing an error code and a message.
|
115
115
|
* *requestId*: the identifier of the request you made. Please mention this to us when you have questions, as it will make debugging easier.
|
116
|
+
|
117
|
+
|
118
|
+
## Rate limiting - exponential backoff
|
119
|
+
|
120
|
+
This library supports [exponential backoff](https://en.wikipedia.org/wiki/Exponential_backoff).
|
121
|
+
|
122
|
+
When you send too many concurrent requests, the server returns an error `429 - Too Many Requests`. We react to this by waiting for a while, and then retrying the request.
|
123
|
+
If the request still fails with an error `429`, we wait a little longer, and try again. This happens at most 5 times, before we give up (after approximately 15 seconds).
|
data/lib/seatsio/httpClient.rb
CHANGED
@@ -14,27 +14,24 @@ module Seatsio
|
|
14
14
|
|
15
15
|
def execute(*args)
|
16
16
|
begin
|
17
|
-
headers = {:Authorization => "Basic #{@secret_key}"}
|
17
|
+
headers = { :Authorization => "Basic #{@secret_key}" }
|
18
18
|
unless @workspace_key.nil?
|
19
19
|
headers[:'X-Workspace-Key'] = @workspace_key
|
20
20
|
end
|
21
21
|
if args[2].include? :params
|
22
22
|
headers[:params] = args[2][:params]
|
23
23
|
end
|
24
|
-
#if args[2] != nil || args[0] == :post
|
25
|
-
# headers[:params] = args[2]
|
26
|
-
#end
|
27
24
|
|
28
25
|
url = "#{@base_url}/#{args[1]}"
|
29
26
|
|
30
|
-
request_options = {method: args[0], url: url, headers: headers}
|
27
|
+
request_options = { method: args[0], url: url, headers: headers }
|
31
28
|
|
32
29
|
if args[0] == :post
|
33
30
|
args[2].delete :params
|
34
31
|
request_options[:payload] = args[2].to_json
|
35
32
|
end
|
36
33
|
|
37
|
-
response =
|
34
|
+
response = execute_with_retries(request_options)
|
38
35
|
|
39
36
|
# If RAW
|
40
37
|
if args[3]
|
@@ -44,9 +41,6 @@ module Seatsio
|
|
44
41
|
rescue RestClient::NotFound => e
|
45
42
|
raise Exception::NotFoundException.new(e.response)
|
46
43
|
rescue RestClient::ExceptionWithResponse => e
|
47
|
-
if e.response.include? "there is no page after" || e.response.empty?
|
48
|
-
raise Exception::NoMorePagesException
|
49
|
-
end
|
50
44
|
raise Exception::SeatsioException.new(e.response)
|
51
45
|
rescue RestClient::Exceptions::Timeout
|
52
46
|
raise Exception::SeatsioException.new("Timeout ERROR")
|
@@ -55,12 +49,29 @@ module Seatsio
|
|
55
49
|
end
|
56
50
|
end
|
57
51
|
|
52
|
+
def execute_with_retries(request_options)
|
53
|
+
retry_count = 0
|
54
|
+
while true
|
55
|
+
begin
|
56
|
+
return RestClient::Request.execute(request_options)
|
57
|
+
rescue RestClient::ExceptionWithResponse => e
|
58
|
+
if e.response.code != 429 || retry_count >= 5
|
59
|
+
raise e
|
60
|
+
else
|
61
|
+
wait_time = (2 ** (retry_count + 2)) / 10.0
|
62
|
+
sleep(wait_time)
|
63
|
+
retry_count += 1
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
58
69
|
def get_raw(endpoint, params = {})
|
59
70
|
execute(:get, endpoint, params, true)
|
60
71
|
end
|
61
72
|
|
62
73
|
def get(endpoint, params = {})
|
63
|
-
payload = {:params => params}
|
74
|
+
payload = { :params => params }
|
64
75
|
execute(:get, endpoint, payload)
|
65
76
|
end
|
66
77
|
|
data/lib/seatsio/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: seatsio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 32.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Seats.io
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|