seatsio 35.1.0 → 36.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 +1 -1
- data/Gemfile.lock +2 -2
- data/README.md +23 -2
- data/lib/seatsio/chart_reports.rb +31 -5
- data/lib/seatsio/domain.rb +73 -46
- data/lib/seatsio/events.rb +1 -2
- data/lib/seatsio/pagination/cursor.rb +3 -3
- data/lib/seatsio/seasons.rb +77 -0
- data/lib/seatsio/version.rb +1 -1
- data/lib/seatsio/workspaces.rb +0 -1
- data/lib/seatsio.rb +3 -3
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 229d0d1752b24b273a977af9c0547f5aba5035756a438b7e7b8f8ca249a38473
|
4
|
+
data.tar.gz: a2fdbca2977e4b07e02680cd3c586bc5d360acb7709668a970b4dd12c737cb51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a54ead9e014c28239e158da656661013ae7ca9f5b743c7e5c13c18844884c39c16fe80515389d0e0141f7b596f964da17f1b460fd6b64dcf3301fe51599afe82
|
7
|
+
data.tar.gz: a9cc825746a3aa613013efa4aad2ddd03ba8b7a47a1850db032e877d5e5239a64fada00ece19e7504cbcf1c72e40674b1dd74871b457295def38ba841a5646c8
|
data/.github/workflows/build.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
seatsio (
|
4
|
+
seatsio (36.0.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -19,7 +19,7 @@ GEM
|
|
19
19
|
mime-types (3.3.1)
|
20
20
|
mime-types-data (~> 3.2015)
|
21
21
|
mime-types-data (3.2021.0225)
|
22
|
-
minitest (5.
|
22
|
+
minitest (5.15.0)
|
23
23
|
netrc (0.11.0)
|
24
24
|
public_suffix (4.0.6)
|
25
25
|
rake (13.0.6)
|
data/README.md
CHANGED
@@ -13,13 +13,34 @@ seatsio-ruby follows semver since v23.3.0.
|
|
13
13
|
|
14
14
|
You can find a full API reference at https://www.rubydoc.info/gems/seatsio/
|
15
15
|
|
16
|
-
##
|
16
|
+
## Usage
|
17
|
+
|
18
|
+
### General instructions
|
19
|
+
|
20
|
+
To use this library, you'll need to create a `Seatsio::Client`:
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
require('seatsio')
|
24
|
+
client = Seatsio::Client.new(Seatsio::Region.EU(), "my-workspace-secret-key")
|
25
|
+
...
|
26
|
+
```
|
27
|
+
|
28
|
+
You can find your _workspace secret key_ in the [settings section of the workspace](https://app.seats.io/workspace-settings).
|
29
|
+
|
30
|
+
The region should correspond to the region of your account:
|
31
|
+
|
32
|
+
- `Seatsio::Region.EU()`: Europe
|
33
|
+
- `Seatsio::Region.NA()`: North-America
|
34
|
+
- `Seatsio::Region.SA()`: South-America
|
35
|
+
- `Seatsio::Region.OC()`: Oceania
|
36
|
+
|
37
|
+
If you're unsure about your region, have a look at your [company settings page](https://app.seats.io/company-settings).
|
17
38
|
|
18
39
|
### Creating a chart and an event
|
19
40
|
|
20
41
|
```ruby
|
21
42
|
require('seatsio')
|
22
|
-
client = Seatsio::Client.new(Seatsio::Region.EU(), "my-workspace-secret-key")
|
43
|
+
client = Seatsio::Client.new(Seatsio::Region.EU(), "my-workspace-secret-key")
|
23
44
|
chart = client.charts.create
|
24
45
|
event = client.events.create chart_key: chart.key
|
25
46
|
```
|
@@ -11,28 +11,54 @@ module Seatsio
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def by_label(chart_key, book_whole_tables = nil)
|
14
|
-
|
14
|
+
fetch_chart_report('byLabel', chart_key, book_whole_tables)
|
15
15
|
end
|
16
16
|
|
17
17
|
def by_object_type(chart_key, book_whole_tables = nil)
|
18
|
-
|
18
|
+
fetch_chart_report('byObjectType', chart_key, book_whole_tables)
|
19
|
+
end
|
20
|
+
|
21
|
+
def summary_by_object_type(chart_key, book_whole_tables = nil)
|
22
|
+
fetch_summary_report('byObjectType', chart_key, book_whole_tables)
|
19
23
|
end
|
20
24
|
|
21
25
|
def by_category_key(chart_key, book_whole_tables = nil)
|
22
|
-
|
26
|
+
fetch_chart_report('byCategoryKey', chart_key, book_whole_tables)
|
27
|
+
end
|
28
|
+
|
29
|
+
def summary_by_category_key(chart_key, book_whole_tables = nil)
|
30
|
+
fetch_summary_report('byCategoryKey', chart_key, book_whole_tables)
|
23
31
|
end
|
24
32
|
|
25
33
|
def by_category_label(chart_key, book_whole_tables = nil)
|
26
|
-
|
34
|
+
fetch_chart_report('byCategoryLabel', chart_key, book_whole_tables)
|
35
|
+
end
|
36
|
+
|
37
|
+
def summary_by_category_label(chart_key, book_whole_tables = nil)
|
38
|
+
fetch_summary_report('byCategoryLabel', chart_key, book_whole_tables)
|
39
|
+
end
|
40
|
+
|
41
|
+
def by_section(chart_key, book_whole_tables = nil)
|
42
|
+
fetch_chart_report('bySection', chart_key, book_whole_tables)
|
43
|
+
end
|
44
|
+
|
45
|
+
def summary_by_section(event_key, book_whole_tables = nil)
|
46
|
+
fetch_summary_report('bySection', event_key, book_whole_tables)
|
27
47
|
end
|
28
48
|
|
29
49
|
private
|
30
50
|
|
31
|
-
def
|
51
|
+
def fetch_chart_report(report_type, chart_key, book_whole_tables)
|
32
52
|
params = book_whole_tables.nil? ? {} : { bookWholeTables: book_whole_tables }
|
33
53
|
url = "reports/charts/#{chart_key}/#{report_type}"
|
34
54
|
body = @http_client.get(url, params)
|
35
55
|
ChartReport.new(body)
|
36
56
|
end
|
57
|
+
|
58
|
+
def fetch_summary_report(report_type, event_key, book_whole_tables)
|
59
|
+
params = book_whole_tables.nil? ? {} : { bookWholeTables: book_whole_tables }
|
60
|
+
url = "reports/charts/#{event_key}/#{report_type}/summary"
|
61
|
+
@http_client.get(url, params)
|
62
|
+
end
|
37
63
|
end
|
38
64
|
end
|
data/lib/seatsio/domain.rb
CHANGED
@@ -22,19 +22,19 @@ module Seatsio
|
|
22
22
|
@archived = data['archived']
|
23
23
|
@validation = data['validation']
|
24
24
|
@social_distancing_rulesets = data['socialDistancingRulesets'].map {
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
25
|
+
|key, r| [key, SocialDistancingRuleset.new(r['name'],
|
26
|
+
number_of_disabled_seats_to_the_sides: r['numberOfDisabledSeatsToTheSides'],
|
27
|
+
disable_seats_in_front_and_behind: r['disableSeatsInFrontAndBehind'],
|
28
|
+
disable_diagonal_seats_in_front_and_behind: r['disableDiagonalSeatsInFrontAndBehind'],
|
29
|
+
number_of_disabled_aisle_seats: r['numberOfDisabledAisleSeats'],
|
30
|
+
max_group_size: r['maxGroupSize'],
|
31
|
+
max_occupancy_absolute: r['maxOccupancyAbsolute'],
|
32
|
+
max_occupancy_percentage: r['maxOccupancyPercentage'],
|
33
|
+
one_group_per_table: r['oneGroupPerTable'],
|
34
|
+
fixed_group_layout: r['fixedGroupLayout'],
|
35
|
+
disabled_seats: r['disabledSeats'],
|
36
|
+
enabled_seats: r['enabledSeats'],
|
37
|
+
index: r['index'])]
|
38
38
|
}.to_h
|
39
39
|
end
|
40
40
|
end
|
@@ -115,10 +115,10 @@ module Seatsio
|
|
115
115
|
|
116
116
|
def == (other)
|
117
117
|
self.key == other.key &&
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
118
|
+
self.name == other.name &&
|
119
|
+
self.color == other.color &&
|
120
|
+
self.index == other.index &&
|
121
|
+
self.objects == other.objects
|
122
122
|
end
|
123
123
|
|
124
124
|
end
|
@@ -139,19 +139,46 @@ module Seatsio
|
|
139
139
|
@created_on = parse_date(data['createdOn'])
|
140
140
|
@updated_on = parse_date(data['updatedOn'])
|
141
141
|
@channels = data['channels'].map {
|
142
|
-
|
142
|
+
|d| Channel.new(d['key'], d['name'], d['color'], d['index'], d['objects'])
|
143
143
|
} if data['channels']
|
144
144
|
@social_distancing_ruleset_key = data['socialDistancingRulesetKey']
|
145
145
|
end
|
146
146
|
|
147
|
+
def is_season
|
148
|
+
false
|
149
|
+
end
|
150
|
+
|
151
|
+
def self.from_json(data)
|
152
|
+
if data['isSeason']
|
153
|
+
Season.new(data)
|
154
|
+
else
|
155
|
+
Event.new(data)
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
147
159
|
def self.create_list(list = [])
|
148
160
|
result = []
|
149
161
|
|
150
162
|
list.each do |item|
|
151
|
-
result << Event.
|
163
|
+
result << Event.from_json(item)
|
152
164
|
end
|
153
165
|
|
154
|
-
|
166
|
+
result
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
class Season < Event
|
171
|
+
|
172
|
+
attr_accessor :partial_season_keys, :events
|
173
|
+
|
174
|
+
def initialize(data)
|
175
|
+
super(data)
|
176
|
+
@partial_season_keys = data['partialSeasonKeys']
|
177
|
+
@events = data['events'] ? Event.create_list(data['events']) : nil
|
178
|
+
end
|
179
|
+
|
180
|
+
def is_season
|
181
|
+
true
|
155
182
|
end
|
156
183
|
end
|
157
184
|
|
@@ -521,41 +548,41 @@ module Seatsio
|
|
521
548
|
end
|
522
549
|
|
523
550
|
def self.fixed(name, disabled_seats: [], index: 0)
|
524
|
-
|
551
|
+
SocialDistancingRuleset.new(name, index: index, disabled_seats: disabled_seats, fixed_group_layout: true)
|
525
552
|
end
|
526
553
|
|
527
554
|
def self.rule_based(name, number_of_disabled_seats_to_the_sides: 0, disable_seats_in_front_and_behind: false, disable_diagonal_seats_in_front_and_behind: false,
|
528
555
|
number_of_disabled_aisle_seats: 0, max_group_size: 0, max_occupancy_absolute: 0, max_occupancy_percentage: 0, one_group_per_table: false,
|
529
556
|
disabled_seats: [], enabled_seats: [], index: 0)
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
557
|
+
SocialDistancingRuleset.new(name,
|
558
|
+
number_of_disabled_seats_to_the_sides: number_of_disabled_seats_to_the_sides,
|
559
|
+
disable_seats_in_front_and_behind: disable_seats_in_front_and_behind,
|
560
|
+
disable_diagonal_seats_in_front_and_behind: disable_diagonal_seats_in_front_and_behind,
|
561
|
+
number_of_disabled_aisle_seats: number_of_disabled_aisle_seats,
|
562
|
+
max_group_size: max_group_size,
|
563
|
+
max_occupancy_absolute: max_occupancy_absolute,
|
564
|
+
max_occupancy_percentage: max_occupancy_percentage,
|
565
|
+
one_group_per_table: one_group_per_table,
|
566
|
+
fixed_group_layout: false,
|
567
|
+
disabled_seats: disabled_seats,
|
568
|
+
enabled_seats: enabled_seats,
|
569
|
+
index: index)
|
543
570
|
end
|
544
571
|
|
545
572
|
def == (other)
|
546
573
|
self.name == other.name &&
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
574
|
+
self.number_of_disabled_seats_to_the_sides == other.number_of_disabled_seats_to_the_sides &&
|
575
|
+
self.disable_seats_in_front_and_behind == other.disable_seats_in_front_and_behind &&
|
576
|
+
self.disable_diagonal_seats_in_front_and_behind == other.disable_diagonal_seats_in_front_and_behind &&
|
577
|
+
self.number_of_disabled_aisle_seats == other.number_of_disabled_aisle_seats &&
|
578
|
+
self.max_group_size == other.max_group_size &&
|
579
|
+
self.max_occupancy_absolute == other.max_occupancy_absolute &&
|
580
|
+
self.max_occupancy_percentage == other.max_occupancy_percentage &&
|
581
|
+
self.one_group_per_table == other.one_group_per_table &&
|
582
|
+
self.fixed_group_layout == other.fixed_group_layout &&
|
583
|
+
self.disabled_seats == other.disabled_seats &&
|
584
|
+
self.enabled_seats == other.enabled_seats &&
|
585
|
+
self.index == other.index
|
559
586
|
end
|
560
587
|
end
|
561
588
|
|
data/lib/seatsio/events.rb
CHANGED
@@ -4,7 +4,6 @@ require "seatsio/httpClient"
|
|
4
4
|
require "seatsio/domain"
|
5
5
|
require "json"
|
6
6
|
require "cgi"
|
7
|
-
require "seatsio/domain"
|
8
7
|
require "seatsio/events/change_object_status_request"
|
9
8
|
require "seatsio/events/change_best_available_object_status_request"
|
10
9
|
|
@@ -108,7 +107,7 @@ module Seatsio
|
|
108
107
|
|
109
108
|
def retrieve(key:)
|
110
109
|
response = @http_client.get("events/#{key}")
|
111
|
-
Event.
|
110
|
+
Event.from_json(response)
|
112
111
|
end
|
113
112
|
|
114
113
|
def list
|
@@ -19,7 +19,7 @@ module Seatsio
|
|
19
19
|
@first_page = false
|
20
20
|
end
|
21
21
|
|
22
|
-
def each(start = 0)
|
22
|
+
def each(start = 0, &block)
|
23
23
|
return to_enum(:each, start) unless block_given?
|
24
24
|
|
25
25
|
Array(@collection[start..-1]).each do |element|
|
@@ -30,7 +30,7 @@ module Seatsio
|
|
30
30
|
|
31
31
|
start = [@collection.size, start].max
|
32
32
|
fetch_next_page
|
33
|
-
each(start, &
|
33
|
+
each(start, &block)
|
34
34
|
end
|
35
35
|
|
36
36
|
def set_query_param(key, value)
|
@@ -85,7 +85,7 @@ module Seatsio
|
|
85
85
|
items = response['items']
|
86
86
|
parsed_items = []
|
87
87
|
|
88
|
-
items.each {|item| parsed_items << @cls.new(item)}
|
88
|
+
items.each {|item| parsed_items << (@cls.respond_to?(:from_json) ? @cls.from_json(item) : @cls.new(item))}
|
89
89
|
|
90
90
|
@collection += parsed_items
|
91
91
|
set_query_param(:start_after_id, items.last['id']) unless last?
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'seatsio/exception'
|
2
|
+
require 'base64'
|
3
|
+
require 'seatsio/httpClient'
|
4
|
+
require 'seatsio/domain'
|
5
|
+
require 'json'
|
6
|
+
require 'cgi'
|
7
|
+
|
8
|
+
module Seatsio
|
9
|
+
|
10
|
+
class SeasonsClient
|
11
|
+
def initialize(http_client, seatsio_client)
|
12
|
+
@http_client = http_client
|
13
|
+
@seatsio_client = seatsio_client
|
14
|
+
end
|
15
|
+
|
16
|
+
def create(chart_key:, key: nil, number_of_events: nil, event_keys: nil,
|
17
|
+
table_booking_config: nil, social_distancing_ruleset_key: nil)
|
18
|
+
request = build_create_season_request(chart_key: chart_key, key: key, number_of_events: number_of_events, event_keys: event_keys,
|
19
|
+
table_booking_config: table_booking_config, social_distancing_ruleset_key: social_distancing_ruleset_key)
|
20
|
+
response = @http_client.post('seasons', request)
|
21
|
+
Season.new(response)
|
22
|
+
end
|
23
|
+
|
24
|
+
def create_partial_season(top_level_season_key:, partial_season_key: nil, event_keys: nil)
|
25
|
+
request = {}
|
26
|
+
request['key'] = partial_season_key if partial_season_key
|
27
|
+
request['eventKeys'] = event_keys if event_keys
|
28
|
+
response = @http_client.post("/seasons/#{top_level_season_key}/partial-seasons", request)
|
29
|
+
Season.new(response)
|
30
|
+
end
|
31
|
+
|
32
|
+
def retrieve(key:)
|
33
|
+
@seatsio_client.events.retrieve(key: key)
|
34
|
+
end
|
35
|
+
|
36
|
+
def create_events(key:, number_of_events: nil, event_keys: nil)
|
37
|
+
request = {}
|
38
|
+
request['eventKeys'] = event_keys if event_keys
|
39
|
+
request['numberOfEvents'] = number_of_events if number_of_events
|
40
|
+
response = @http_client.post("/seasons/#{key}/actions/create-events", request)
|
41
|
+
Season.new(response)
|
42
|
+
end
|
43
|
+
|
44
|
+
def add_events_to_partial_season(top_level_season_key:, partial_season_key:, event_keys:)
|
45
|
+
request = {}
|
46
|
+
request['eventKeys'] = event_keys
|
47
|
+
response = @http_client.post("/seasons/#{top_level_season_key}/partial-seasons/#{partial_season_key}/actions/add-events", request)
|
48
|
+
Season.new(response)
|
49
|
+
end
|
50
|
+
|
51
|
+
def remove_event_from_partial_season(top_level_season_key:, partial_season_key:, event_key:)
|
52
|
+
response = @http_client.delete("/seasons/#{top_level_season_key}/partial-seasons/#{partial_season_key}/events/#{event_key}")
|
53
|
+
Season.new(response)
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def build_create_season_request(chart_key: nil, key: nil, number_of_events: nil, event_keys: nil, table_booking_config: nil, social_distancing_ruleset_key: nil)
|
59
|
+
request = {}
|
60
|
+
request['chartKey'] = chart_key if chart_key
|
61
|
+
request['key'] = key if key
|
62
|
+
request['numberOfEvents'] = number_of_events if number_of_events
|
63
|
+
request['eventKeys'] = event_keys if event_keys
|
64
|
+
request['tableBookingConfig'] = table_booking_config_to_request(table_booking_config) if table_booking_config != nil
|
65
|
+
request['socialDistancingRulesetKey'] = social_distancing_ruleset_key if social_distancing_ruleset_key != nil
|
66
|
+
request
|
67
|
+
end
|
68
|
+
|
69
|
+
def table_booking_config_to_request(table_booking_config)
|
70
|
+
request = {}
|
71
|
+
request['mode'] = table_booking_config.mode
|
72
|
+
request['tables'] = table_booking_config.tables if table_booking_config.tables != nil
|
73
|
+
request
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
end
|
data/lib/seatsio/version.rb
CHANGED
data/lib/seatsio/workspaces.rb
CHANGED
data/lib/seatsio.rb
CHANGED
@@ -3,6 +3,7 @@ require 'seatsio/charts'
|
|
3
3
|
require 'seatsio/subaccounts'
|
4
4
|
require 'seatsio/workspaces'
|
5
5
|
require 'seatsio/events'
|
6
|
+
require 'seatsio/seasons'
|
6
7
|
require 'seatsio/hold_tokens'
|
7
8
|
require 'seatsio/chart_reports'
|
8
9
|
require 'seatsio/event_reports'
|
@@ -10,7 +11,7 @@ require 'seatsio/usage_reports'
|
|
10
11
|
|
11
12
|
module Seatsio
|
12
13
|
class Client
|
13
|
-
attr_reader :charts, :subaccounts, :workspaces, :events,
|
14
|
+
attr_reader :charts, :subaccounts, :workspaces, :events, :seasons,
|
14
15
|
:hold_tokens, :chart_reports, :event_reports, :usage_reports
|
15
16
|
|
16
17
|
def initialize(region, secret_key, workspace_key = nil, max_retries = 5)
|
@@ -20,15 +21,14 @@ module Seatsio
|
|
20
21
|
@subaccounts = SubaccountsClient.new(@http_client)
|
21
22
|
@workspaces = WorkspacesClient.new(@http_client)
|
22
23
|
@events = EventsClient.new(@http_client)
|
24
|
+
@seasons = SeasonsClient.new(@http_client, self)
|
23
25
|
@hold_tokens = HoldTokensClient.new(@http_client)
|
24
26
|
@chart_reports = ChartReportsClient.new(@http_client)
|
25
27
|
@event_reports = EventReportsClient.new(@http_client)
|
26
28
|
@usage_reports = UsageReportsClient.new(@http_client)
|
27
29
|
end
|
28
|
-
|
29
30
|
end
|
30
31
|
|
31
|
-
|
32
32
|
class Region
|
33
33
|
attr_reader :url
|
34
34
|
|
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: 36.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:
|
11
|
+
date: 2022-02-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -124,6 +124,7 @@ files:
|
|
124
124
|
- lib/seatsio/hold_tokens.rb
|
125
125
|
- lib/seatsio/httpClient.rb
|
126
126
|
- lib/seatsio/pagination/cursor.rb
|
127
|
+
- lib/seatsio/seasons.rb
|
127
128
|
- lib/seatsio/subaccounts.rb
|
128
129
|
- lib/seatsio/usage_reports.rb
|
129
130
|
- lib/seatsio/util.rb
|