seatsio 29.0.0 → 32.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/build.yml +26 -0
- data/.github/workflows/publish.yml +21 -0
- data/Gemfile.lock +1 -1
- data/README.md +16 -8
- data/lib/seatsio.rb +30 -2
- data/lib/seatsio/domain.rb +7 -13
- data/lib/seatsio/httpClient.rb +21 -10
- data/lib/seatsio/pagination/cursor.rb +0 -2
- data/lib/seatsio/version.rb +1 -1
- metadata +8 -7
- data/.travis.yml +0 -19
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
|
@@ -0,0 +1,26 @@
|
|
1
|
+
name: 'Build'
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ master ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ master ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
test:
|
11
|
+
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
strategy:
|
14
|
+
matrix:
|
15
|
+
ruby-version: ['2.3']
|
16
|
+
|
17
|
+
steps:
|
18
|
+
- uses: actions/checkout@v2
|
19
|
+
- uses: ruby/setup-ruby@v1
|
20
|
+
with:
|
21
|
+
ruby-version: ${{ matrix.ruby-version }}
|
22
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
23
|
+
- uses: zcong1993/setup-timezone@master
|
24
|
+
with:
|
25
|
+
timezone: Europe/Brussels
|
26
|
+
- run: bundle exec rake
|
@@ -0,0 +1,21 @@
|
|
1
|
+
name: 'Publish'
|
2
|
+
|
3
|
+
on:
|
4
|
+
release:
|
5
|
+
types: [created]
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
build:
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
|
11
|
+
steps:
|
12
|
+
- uses: actions/checkout@v2
|
13
|
+
- run: |
|
14
|
+
mkdir -p $HOME/.gem
|
15
|
+
touch $HOME/.gem/credentials
|
16
|
+
chmod 0600 $HOME/.gem/credentials
|
17
|
+
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
18
|
+
gem build *.gemspec
|
19
|
+
gem push *.gem
|
20
|
+
env:
|
21
|
+
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_API_KEY}}"
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# seatsio-ruby, the official Seats.io Ruby client library
|
2
2
|
|
3
|
-
|
3
|
+

|
4
4
|
|
5
5
|
This is the official Ruby client library for the [Seats.io V2 REST API](https://docs.seats.io/docs/api-overview), supporting Ruby 2.2.0+
|
6
6
|
|
@@ -14,7 +14,7 @@ seatsio-ruby follows semver since v23.3.0.
|
|
14
14
|
|
15
15
|
```ruby
|
16
16
|
require('seatsio')
|
17
|
-
client = Seatsio::Client.new("my-workspace-secret-key") # can be found on https://app.seats.io/workspace-settings
|
17
|
+
client = Seatsio::Client.new(Seatsio::Region.EU(), "my-workspace-secret-key") # can be found on https://app.seats.io/workspace-settings
|
18
18
|
chart = client.charts.create
|
19
19
|
event = client.events.create key: chart.key
|
20
20
|
```
|
@@ -23,7 +23,7 @@ event = client.events.create key: chart.key
|
|
23
23
|
|
24
24
|
```ruby
|
25
25
|
require('seatsio')
|
26
|
-
client = Seatsio::Client.new("my-workspace-secret-key")
|
26
|
+
client = Seatsio::Client.new(Seatsio::Region.EU(), "my-workspace-secret-key")
|
27
27
|
client.events.book(event.key, ["A-1", "A-2"])
|
28
28
|
```
|
29
29
|
|
@@ -31,7 +31,7 @@ client.events.book(event.key, ["A-1", "A-2"])
|
|
31
31
|
|
32
32
|
```ruby
|
33
33
|
require('seatsio')
|
34
|
-
client = Seatsio::Client.new("my-workspace-secret-key")
|
34
|
+
client = Seatsio::Client.new(Seatsio::Region.EU(), "my-workspace-secret-key")
|
35
35
|
client.events.release(event.key, ["A-1", "A-2"])
|
36
36
|
```
|
37
37
|
|
@@ -39,7 +39,7 @@ client.events.release(event.key, ["A-1", "A-2"])
|
|
39
39
|
|
40
40
|
```ruby
|
41
41
|
require('seatsio')
|
42
|
-
client = Seatsio::Client.new("my-workspace-secret-key")
|
42
|
+
client = Seatsio::Client.new(Seatsio::Region.EU(), "my-workspace-secret-key")
|
43
43
|
client.events.book(event.key, ["A-1", "A-2"], hold_token: "a-hold-token")
|
44
44
|
```
|
45
45
|
|
@@ -47,7 +47,7 @@ client.events.book(event.key, ["A-1", "A-2"], hold_token: "a-hold-token")
|
|
47
47
|
|
48
48
|
```ruby
|
49
49
|
require('seatsio')
|
50
|
-
client = Seatsio::Client.new("my-workspace-secret-key")
|
50
|
+
client = Seatsio::Client.new(Seatsio::Region.EU(), "my-workspace-secret-key")
|
51
51
|
client.events.change_object_status("<EVENT KEY>", ["A-1", "A-2"], "my-custom-status")
|
52
52
|
```
|
53
53
|
|
@@ -55,7 +55,7 @@ client.events.change_object_status("<EVENT KEY>", ["A-1", "A-2"], "my-custom-sta
|
|
55
55
|
|
56
56
|
```ruby
|
57
57
|
require('seatsio')
|
58
|
-
client = Seatsio::Client.new("my-workspace-secret-key")
|
58
|
+
client = Seatsio::Client.new(Seatsio::Region.EU(), "my-workspace-secret-key")
|
59
59
|
charts = client.charts.list
|
60
60
|
charts.each do |chart|
|
61
61
|
puts chart.key
|
@@ -101,7 +101,7 @@ end
|
|
101
101
|
|
102
102
|
```ruby
|
103
103
|
require('seatsio')
|
104
|
-
client = Seatsio::Client.new("my-company-admin-key")
|
104
|
+
client = Seatsio::Client.new(Seatsio::Region.EU(), "my-company-admin-key")
|
105
105
|
client.workspaces.create name: "a workspace"
|
106
106
|
```
|
107
107
|
|
@@ -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.rb
CHANGED
@@ -9,12 +9,12 @@ require 'seatsio/event_reports'
|
|
9
9
|
require 'seatsio/usage_reports'
|
10
10
|
|
11
11
|
module Seatsio
|
12
|
-
# Main Seatsio Class
|
13
12
|
class Client
|
14
13
|
attr_reader :charts, :subaccounts, :workspaces, :events,
|
15
14
|
:hold_tokens, :chart_reports, :event_reports, :usage_reports
|
16
15
|
|
17
|
-
def initialize(secret_key, workspace_key = nil
|
16
|
+
def initialize(region, secret_key, workspace_key = nil)
|
17
|
+
base_url = region.url
|
18
18
|
@charts = ChartsClient.new(secret_key, workspace_key, base_url)
|
19
19
|
@subaccounts = SubaccountsClient.new(secret_key, workspace_key, base_url)
|
20
20
|
@workspaces = WorkspacesClient.new(secret_key, base_url)
|
@@ -25,4 +25,32 @@ module Seatsio
|
|
25
25
|
@usage_reports = UsageReportsClient.new(secret_key, workspace_key, base_url)
|
26
26
|
end
|
27
27
|
end
|
28
|
+
|
29
|
+
class Region
|
30
|
+
attr_reader :url
|
31
|
+
|
32
|
+
def initialize(url)
|
33
|
+
@url = url
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.EU()
|
37
|
+
return Region.new(Region.url_for_id("eu"))
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.NA()
|
41
|
+
return Region.new(Region.url_for_id("na"))
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.SA()
|
45
|
+
return Region.new(Region.url_for_id("sa"))
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.OC()
|
49
|
+
return Region.new(Region.url_for_id("oc"))
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.url_for_id(id)
|
53
|
+
return "https://api-" + id + ".seatsio.net"
|
54
|
+
end
|
55
|
+
end
|
28
56
|
end
|
data/lib/seatsio/domain.rb
CHANGED
@@ -264,7 +264,7 @@ module Seatsio
|
|
264
264
|
class ChartReportItem
|
265
265
|
|
266
266
|
attr_reader :label, :labels, :category_key, :category_label, :section, :entrance, :capacity, :object_type,
|
267
|
-
:left_neighbour, :right_neighbour
|
267
|
+
:left_neighbour, :right_neighbour, :book_as_a_whole
|
268
268
|
|
269
269
|
def initialize(data)
|
270
270
|
@label = data['label']
|
@@ -277,6 +277,7 @@ module Seatsio
|
|
277
277
|
@object_type = data['objectType']
|
278
278
|
@left_neighbour = data['leftNeighbour']
|
279
279
|
@right_neighbour = data['rightNeighbour']
|
280
|
+
@book_as_a_whole = data['bookAsAWhole']
|
280
281
|
end
|
281
282
|
end
|
282
283
|
|
@@ -327,7 +328,8 @@ module Seatsio
|
|
327
328
|
:category_key, :entrance, :object_type, :hold_token, :category_label,
|
328
329
|
:ticket_type, :num_booked, :num_free, :num_held, :for_sale, :section,
|
329
330
|
:is_accessible, :is_companion_seat, :has_restricted_view, :displayed_object_type,
|
330
|
-
:left_neighbour, :right_neighbour, :is_selectable, :is_disabled_by_social_distancing, :channel
|
331
|
+
:left_neighbour, :right_neighbour, :is_selectable, :is_disabled_by_social_distancing, :channel,
|
332
|
+
:book_as_a_whole
|
331
333
|
|
332
334
|
def initialize(data)
|
333
335
|
@status = data['status']
|
@@ -356,6 +358,7 @@ module Seatsio
|
|
356
358
|
@is_selectable = data['isSelectable']
|
357
359
|
@is_disabled_by_social_distancing = data['isDisabledBySocialDistancing']
|
358
360
|
@channel = data['channel']
|
361
|
+
@book_as_a_whole = data['bookAsAWhole']
|
359
362
|
end
|
360
363
|
end
|
361
364
|
|
@@ -383,23 +386,14 @@ module Seatsio
|
|
383
386
|
|
384
387
|
class UsageDetails
|
385
388
|
|
386
|
-
attr_reader :workspace
|
389
|
+
attr_reader :workspace, :usage_by_chart
|
387
390
|
|
388
391
|
def initialize(data)
|
389
|
-
@workspace = data['workspace']
|
392
|
+
@workspace = data['workspace']
|
390
393
|
@usage_by_chart = data['usageByChart'].map { |usage| UsageByChart.new(usage) }
|
391
394
|
end
|
392
395
|
end
|
393
396
|
|
394
|
-
class UsageWorkspace
|
395
|
-
|
396
|
-
attr_reader :id
|
397
|
-
|
398
|
-
def initialize(data)
|
399
|
-
@id = data['id']
|
400
|
-
end
|
401
|
-
end
|
402
|
-
|
403
397
|
class UsageByChart
|
404
398
|
|
405
399
|
attr_reader :chart, :usage_by_event
|
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
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -100,9 +100,10 @@ extensions: []
|
|
100
100
|
extra_rdoc_files: []
|
101
101
|
files:
|
102
102
|
- ".editorconfig"
|
103
|
+
- ".github/workflows/build.yml"
|
104
|
+
- ".github/workflows/publish.yml"
|
103
105
|
- ".gitignore"
|
104
106
|
- ".ruby-version"
|
105
|
-
- ".travis.yml"
|
106
107
|
- Gemfile
|
107
108
|
- Gemfile.lock
|
108
109
|
- README.md
|
@@ -132,7 +133,7 @@ files:
|
|
132
133
|
homepage: http://seats.io
|
133
134
|
licenses: []
|
134
135
|
metadata: {}
|
135
|
-
post_install_message:
|
136
|
+
post_install_message:
|
136
137
|
rdoc_options: []
|
137
138
|
require_paths:
|
138
139
|
- lib
|
@@ -147,8 +148,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
147
148
|
- !ruby/object:Gem::Version
|
148
149
|
version: '0'
|
149
150
|
requirements: []
|
150
|
-
rubygems_version: 3.
|
151
|
-
signing_key:
|
151
|
+
rubygems_version: 3.1.2
|
152
|
+
signing_key:
|
152
153
|
specification_version: 4
|
153
154
|
summary: the official Seats.io Ruby client library
|
154
155
|
test_files: []
|
data/.travis.yml
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
sudo: false
|
2
|
-
language: ruby
|
3
|
-
rvm:
|
4
|
-
- 2.3.0
|
5
|
-
before_install: gem install bundler -v 1.16.1
|
6
|
-
notifications:
|
7
|
-
slack:
|
8
|
-
rooms:
|
9
|
-
- seatsio:AGaZISx4HlvoEx6WTbVaX50V
|
10
|
-
on_pull_requests: false
|
11
|
-
on_failure: always
|
12
|
-
on_success: change
|
13
|
-
deploy:
|
14
|
-
provider: rubygems
|
15
|
-
gem: seatsio
|
16
|
-
on:
|
17
|
-
tags: true
|
18
|
-
api_key:
|
19
|
-
secure: mQmsVgbIYF16i0rzDYQoOzcXwG8ppJl/czjTWf/KaEtSCWG5tQKBzflXFIkrfoP7EyjC+2TvT4Z5tWIBUVR4gG2KjcV2lGgq2vV/sVYrmUIXO2LZHBu5n35QHBF//0IOvbZMufm7W8PIVM6do1tMxdRE+qMZVtb5M9YIQpDHc6jXru/PKxOffwTNEWMVX1Xjfz4wtuJCpvhR+BHuBoi9uE4dyWrF5WgkL2aELUvHpUmc2wn0gGypqJ9Whrcxq8n3EREvO0kiSMww+MMdWd57ACo4q5J8Za+h4tXvVd49EyEdevjWMvT0wYx+nSz+/vk4B9vOmd5Un9/gzoLbq8qEpAgEHXKw/J6l9KHlJDMNy2dVsMzqSOceEtBx5LA0fizWD4U2XfI0GaiM5Rdt96iNtVlU9lQuiXPhcz7igEFVRSZAkzTNHlh0cAr2FJIBBh27fffrblF/xRw1ziLwDnjutTg8lZsxmdjTrnMkAAuNWMIXKzWvh7n2bZ+jqwzp5bSqp1ckOCae7ozsG1Kx1eS8pMepsvMtmb5w6dsuWGVAI8ASd8XmYFHKisKmi6xHYOGw7uy7yE7rXHa0Ypx/K4xKCoqhv+5Y7RdTvT2tkqC0mwMOh/Io2eslgjTA0vy87sVKyLTCU/ElKRTd2165cRL2JRNH3l/X0gxglT4WpXQEEXs=
|