seatsio 1.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 +7 -0
- data/.editorconfig +14 -0
- data/.gitignore +9 -0
- data/.travis.yml +12 -0
- data/Gemfile +6 -0
- data/README.md +81 -0
- data/Rakefile +11 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/seatsio/accounts.rb +20 -0
- data/lib/seatsio/chart_reports.rb +19 -0
- data/lib/seatsio/charts.rb +124 -0
- data/lib/seatsio/domain.rb +283 -0
- data/lib/seatsio/event_reports.rb +73 -0
- data/lib/seatsio/events/change_best_available_object_status_request.rb +11 -0
- data/lib/seatsio/events/change_object_status_request.rb +30 -0
- data/lib/seatsio/events.rb +150 -0
- data/lib/seatsio/exception.rb +12 -0
- data/lib/seatsio/hold_tokens.rb +38 -0
- data/lib/seatsio/httpClient.rb +71 -0
- data/lib/seatsio/pagination/cursor.rb +97 -0
- data/lib/seatsio/subaccounts.rb +89 -0
- data/lib/seatsio/util.rb +3 -0
- data/lib/seatsio/version.rb +3 -0
- data/lib/seatsio.rb +26 -0
- data/seatsio.gemspec +29 -0
- metadata +164 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: efff7272547e4765151626aaa6a42d90d334954098906ee1d0f3222e896c77c8
|
4
|
+
data.tar.gz: 95f20cfc064c466dea4e8c7d7e57a45cc6b9269068a2bbb9de0b865407b539e9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 17b0870cd210ab7aa811c1a98afd96b4429c1782313e47b1ef15554ee44cf18e27047cd64c3bad50dd503f8b2cb22c5da81c259f571efbc4bdd278276a24d89e
|
7
|
+
data.tar.gz: b5e058d594c300716bee307b40b3306807265fd5f5313c41c363a1a7dc98f31f8a6fa5b2b33bcc46213f833cb080d634800200880047102b0fe2bd297a338a6e
|
data/.editorconfig
ADDED
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
# seatsio-ruby, the official Seats.io Ruby client library
|
2
|
+
|
3
|
+
[](https://travis-ci.org/seatsio/seatsio-ruby)
|
4
|
+
[](https://coveralls.io/github/seatsio/seatsio-ruby?branch=master)
|
5
|
+
|
6
|
+
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+
|
7
|
+
|
8
|
+
|
9
|
+
# Versioning
|
10
|
+
|
11
|
+
seatsio-ruby only uses major version numbers: v5, v6, v7 etc. Each release - backwards compatible or not - receives a new major version number.
|
12
|
+
|
13
|
+
The reason: we want to play safe and assume that each release might break backwards compatibility.
|
14
|
+
|
15
|
+
## Examples
|
16
|
+
|
17
|
+
### Creating a chart and an event
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
require('seatsio')
|
21
|
+
client = Seatsio::Client.new("my-secret-key") # can be found on https://app.seats.io/settings
|
22
|
+
chart = client.charts.create
|
23
|
+
event = client.events.create(chart.key)
|
24
|
+
```
|
25
|
+
|
26
|
+
### Booking objects
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
require('seatsio')
|
30
|
+
client = Seatsio::Client.new("my-secret-key")
|
31
|
+
client.events.book(event.key, ["A-1", "A-2"])
|
32
|
+
```
|
33
|
+
|
34
|
+
### Releasing objects
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
require('seatsio')
|
38
|
+
client = Seatsio::Client.new("my-secret-key")
|
39
|
+
client.events.release(event.key, ["A-1", "A-2"])
|
40
|
+
```
|
41
|
+
|
42
|
+
### Booking objects that have been held
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
require('seatsio')
|
46
|
+
client = Seatsio::Client.new("my-secret-key")
|
47
|
+
client.events.book(event.key, ["A-1", "A-2"], "a-hold-token")
|
48
|
+
```
|
49
|
+
|
50
|
+
### Changing object status
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
require('seatsio')
|
54
|
+
client = Seatsio::Client.new("my-secret-key")
|
55
|
+
client.events.change_object_status("<EVENT KEY>", ["A-1", "A-2"], "my-custom-status")
|
56
|
+
```
|
57
|
+
|
58
|
+
### Listing all charts
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
require('seatsio')
|
62
|
+
client = Seatsio::Client.new("my-secret-key")
|
63
|
+
charts = client.charts.list # returns a Enumerable
|
64
|
+
```
|
65
|
+
|
66
|
+
### Listing the first page of charts (default page size is 20)
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
require('seatsio')
|
70
|
+
client = Seatsio::Client.new("my-secret-key")
|
71
|
+
charts = client.charts.list.first_page # returns a Enumerable
|
72
|
+
```
|
73
|
+
|
74
|
+
# Error handling
|
75
|
+
|
76
|
+
When an API call results in a 4xx or 5xx error (e.g. when a chart could not be found), a SeatsioException is thrown.
|
77
|
+
|
78
|
+
This exception contains a message string describing what went wrong, and also two other properties:
|
79
|
+
|
80
|
+
* *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.
|
81
|
+
* *requestId*: the identifier of the request you made. Please mention this to us when you have questions, as it will make debugging easier.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "seatsio"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require "seatsio/exception"
|
2
|
+
require "base64"
|
3
|
+
require "seatsio/httpClient"
|
4
|
+
require "seatsio/domain"
|
5
|
+
require "json"
|
6
|
+
require "cgi"
|
7
|
+
require "seatsio/domain"
|
8
|
+
|
9
|
+
module Seatsio
|
10
|
+
class AccountsClient
|
11
|
+
def initialize(secret_key, base_url)
|
12
|
+
@http_client = ::Seatsio::HttpClient.new(secret_key, base_url)
|
13
|
+
end
|
14
|
+
|
15
|
+
def retrieve_my_account
|
16
|
+
response = @http_client.get('accounts/me')
|
17
|
+
Domain::Account.new(response)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'seatsio/exception'
|
2
|
+
require 'seatsio/httpClient'
|
3
|
+
require 'seatsio/domain'
|
4
|
+
require 'json'
|
5
|
+
require 'cgi'
|
6
|
+
|
7
|
+
module Seatsio
|
8
|
+
class ChartReportsClient
|
9
|
+
def initialize(secret_key, base_url)
|
10
|
+
@http_client = ::Seatsio::HttpClient.new(secret_key, base_url)
|
11
|
+
end
|
12
|
+
|
13
|
+
def by_label(chart_key)
|
14
|
+
url = "reports/charts/#{chart_key}/byLabel"
|
15
|
+
body = @http_client.get(url)
|
16
|
+
Domain::ChartReport.new(body)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,124 @@
|
|
1
|
+
require 'seatsio/exception'
|
2
|
+
require 'base64'
|
3
|
+
require 'seatsio/httpClient'
|
4
|
+
require 'seatsio/domain'
|
5
|
+
require 'seatsio/pagination/cursor'
|
6
|
+
require 'json'
|
7
|
+
require 'cgi'
|
8
|
+
|
9
|
+
module Seatsio
|
10
|
+
# Seatsio Charts client
|
11
|
+
class ChartsClient
|
12
|
+
attr_reader :archive
|
13
|
+
|
14
|
+
def initialize(secret_key, base_url)
|
15
|
+
@http_client = Seatsio::HttpClient.new(secret_key, base_url)
|
16
|
+
@archive = Pagination::Cursor.new(Domain::Chart, 'charts/archive', @http_client)
|
17
|
+
end
|
18
|
+
|
19
|
+
# @return [Seatsio::Domain::Chart]
|
20
|
+
def retrieve(chart_key)
|
21
|
+
response = @http_client.get("charts/#{chart_key}")
|
22
|
+
Domain::Chart.new(response)
|
23
|
+
end
|
24
|
+
|
25
|
+
def retrieve_with_events(chart_key)
|
26
|
+
response = @http_client.get("charts/#{chart_key}?expand=events")
|
27
|
+
Domain::Chart.new(response)
|
28
|
+
end
|
29
|
+
|
30
|
+
def create(name = nil, venue_type = nil, categories = nil)
|
31
|
+
payload = build_chart_request name: name, venue_type: venue_type, categories: categories
|
32
|
+
response = @http_client.post('charts', payload)
|
33
|
+
Domain::Chart.new(response)
|
34
|
+
end
|
35
|
+
|
36
|
+
def update(key, new_name = nil, categories = nil)
|
37
|
+
payload = build_chart_request name: new_name, categories: categories
|
38
|
+
@http_client.post("charts/#{key}", payload)
|
39
|
+
end
|
40
|
+
|
41
|
+
def add_tag(key, tag)
|
42
|
+
@http_client.post("charts/#{key}/tags/#{CGI::escape(tag)}")
|
43
|
+
end
|
44
|
+
|
45
|
+
def remove_tag(key, tag)
|
46
|
+
@http_client.delete("charts/#{key}/tags/#{tag}")
|
47
|
+
end
|
48
|
+
|
49
|
+
def copy(key)
|
50
|
+
response = @http_client.post("charts/#{key}/version/published/actions/copy")
|
51
|
+
Domain::Chart.new(response)
|
52
|
+
end
|
53
|
+
|
54
|
+
def copy_to_subaccount(chart_key, subaccount_id)
|
55
|
+
url = "charts/#{chart_key}/version/published/actions/copy-to/#{subaccount_id}"
|
56
|
+
response = @http_client.post url
|
57
|
+
Domain::Chart.new(response)
|
58
|
+
end
|
59
|
+
|
60
|
+
def copy_draft_version(key)
|
61
|
+
response = @http_client.post("charts/#{key}/version/draft/actions/copy")
|
62
|
+
Domain::Chart.new(response)
|
63
|
+
end
|
64
|
+
|
65
|
+
def retrieve_published_version(key)
|
66
|
+
response = @http_client.get("charts/#{key}/version/published")
|
67
|
+
Domain::Chart.new(response)
|
68
|
+
end
|
69
|
+
|
70
|
+
def retrieve_draft_version(key)
|
71
|
+
response = @http_client.get("charts/#{key}/version/draft")
|
72
|
+
Domain::ChartDraft.new(response)
|
73
|
+
end
|
74
|
+
|
75
|
+
def retrieve_draft_version_thumbnail(key)
|
76
|
+
@http_client.get_raw("charts/#{key}/version/draft/thumbnail")
|
77
|
+
end
|
78
|
+
|
79
|
+
def retrieve_published_version_thumbnail(key)
|
80
|
+
@http_client.get_raw("charts/#{key}/version/published/thumbnail")
|
81
|
+
end
|
82
|
+
|
83
|
+
def discard_draft_version(key)
|
84
|
+
@http_client.post("charts/#{key}/version/draft/actions/discard")
|
85
|
+
end
|
86
|
+
|
87
|
+
def publish_draft_version(chart_key)
|
88
|
+
@http_client.post("charts/#{chart_key}/version/draft/actions/publish")
|
89
|
+
end
|
90
|
+
|
91
|
+
def list(chart_filter = nil, tag = nil, expand_events = nil)
|
92
|
+
cursor = Pagination::Cursor.new(Domain::Chart, 'charts', @http_client)
|
93
|
+
cursor.set_query_param('filter', chart_filter)
|
94
|
+
cursor.set_query_param('tag', tag)
|
95
|
+
|
96
|
+
cursor.set_query_param('expand', 'events') if expand_events
|
97
|
+
|
98
|
+
cursor
|
99
|
+
end
|
100
|
+
|
101
|
+
def list_all_tags
|
102
|
+
response = @http_client.get('charts/tags')
|
103
|
+
response['tags']
|
104
|
+
end
|
105
|
+
|
106
|
+
def move_to_archive(chart_key)
|
107
|
+
@http_client.post("charts/#{chart_key}/actions/move-to-archive")
|
108
|
+
end
|
109
|
+
|
110
|
+
def move_out_of_archive(chart_key)
|
111
|
+
@http_client.post("charts/#{chart_key}/actions/move-out-of-archive")
|
112
|
+
end
|
113
|
+
|
114
|
+
private
|
115
|
+
|
116
|
+
def build_chart_request(name: nil, venue_type: nil, categories: nil)
|
117
|
+
result = {}
|
118
|
+
result['name'] = name if name
|
119
|
+
result['venueType'] = venue_type if venue_type
|
120
|
+
result['categories'] = categories if categories
|
121
|
+
result
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
@@ -0,0 +1,283 @@
|
|
1
|
+
require 'seatsio/util'
|
2
|
+
|
3
|
+
module Seatsio::Domain
|
4
|
+
|
5
|
+
class ChartCategories
|
6
|
+
attr_accessor :list, :max_category_key
|
7
|
+
|
8
|
+
def initialize(data)
|
9
|
+
if data
|
10
|
+
@list = data['list']
|
11
|
+
@max_category_key = data['maxCategoryKey']
|
12
|
+
else
|
13
|
+
@list = []
|
14
|
+
@max_category_key = ''
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class Chart
|
20
|
+
|
21
|
+
attr_reader :id, :key, :status, :name, :published_version_thumbnail_url,
|
22
|
+
:draft_version_thumbnail_url, :events, :tags, :archived, :venue_type,
|
23
|
+
:categories
|
24
|
+
|
25
|
+
def initialize(data)
|
26
|
+
@id = data['id']
|
27
|
+
@key = data['key']
|
28
|
+
@status = data['status']
|
29
|
+
@name = data['name']
|
30
|
+
@published_version_thumbnail_url = data['publishedVersionThumbnailUrl']
|
31
|
+
@draft_version_thumbnail_url = data['draftVersionThumbnailUrl']
|
32
|
+
@events = Event.create_list(data['events']) if data['events']
|
33
|
+
@tags = data['tags']
|
34
|
+
@archived = data['archived']
|
35
|
+
@venue_type = data['venueType']
|
36
|
+
@categories = ChartCategories.new(data['categories'])
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
class ChartDraft < Chart
|
42
|
+
attr_reader :version
|
43
|
+
def initialize(data)
|
44
|
+
super(data)
|
45
|
+
@version = data['version']
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
class ForSaleConfig
|
50
|
+
|
51
|
+
attr_reader :for_sale, :objects, :categories
|
52
|
+
|
53
|
+
def initialize(data)
|
54
|
+
if data
|
55
|
+
@for_sale = data['forSale']
|
56
|
+
@objects = data['objects']
|
57
|
+
@categories = data['categories']
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
class Event
|
63
|
+
|
64
|
+
attr_accessor :id, :key, :chart_key, :book_whole_tables, :supports_best_available,
|
65
|
+
:table_booking_modes, :for_sale_config, :created_on, :updated_on
|
66
|
+
|
67
|
+
def initialize(data)
|
68
|
+
@id = data['id']
|
69
|
+
@key = data['key']
|
70
|
+
@chart_key = data['chartKey']
|
71
|
+
@book_whole_tables = data['bookWholeTables']
|
72
|
+
@supports_best_available = data['supportsBestAvailable']
|
73
|
+
@table_booking_modes = data['tableBookingModes']
|
74
|
+
@for_sale_config = ForSaleConfig.new(data['forSaleConfig']) if data['forSaleConfig']
|
75
|
+
@created_on = parse_date(data['createdOn'])
|
76
|
+
@updated_on = parse_date(data['updatedOn'])
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.create_list(list = [])
|
80
|
+
result = []
|
81
|
+
|
82
|
+
list.each do |item|
|
83
|
+
result << Event.new(item)
|
84
|
+
end
|
85
|
+
|
86
|
+
return result
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
class APIResponse
|
91
|
+
|
92
|
+
attr_reader :next_page_starts_after, :previous_page_ends_before, :items
|
93
|
+
|
94
|
+
def initialize(data)
|
95
|
+
@next_page_starts_after = data.fetch('next_page_starts_after', nil).to_i
|
96
|
+
@previous_page_ends_before = data.fetch('previous_page_ends_before', nil).to_i
|
97
|
+
@items = data.fetch('items', [])
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
class ChartValidationSettings
|
102
|
+
attr_reader :validate_duplicate_labels, :validate_objects_without_categories,
|
103
|
+
:validate_unlabeled_objects
|
104
|
+
|
105
|
+
def initialize(data)
|
106
|
+
@validate_duplicate_labels = data['VALIDATE_DUPLICATE_LABELS']
|
107
|
+
@validate_objects_without_categories = data['VALIDATE_OBJECTS_WITHOUT_CATEGORIES']
|
108
|
+
@validate_unlabeled_objects = data['VALIDATE_UNLABELED_OBJECTS']
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
class AccountSettings
|
113
|
+
attr_reader :draft_chart_drawings_enabled, :chart_validation
|
114
|
+
|
115
|
+
def initialize(data)
|
116
|
+
@draft_chart_drawings_enabled = data['draftChartDrawingsEnabled']
|
117
|
+
@chart_validation = ChartValidationSettings.new(data['chartValidation'])
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
class Account
|
122
|
+
attr_reader :id, :secret_key, :designer_key, :public_key, :name,
|
123
|
+
:email, :active, :settings
|
124
|
+
|
125
|
+
def initialize(data)
|
126
|
+
@id = data['id']
|
127
|
+
@secret_key = data['secretKey']
|
128
|
+
@designer_key = data['designerKey']
|
129
|
+
@public_key = data['publicKey']
|
130
|
+
@name = data['name']
|
131
|
+
@email = data['email']
|
132
|
+
@active = data['active']
|
133
|
+
@settings = AccountSettings.new(data['settings']) if data['settings'] != nil
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
class Subaccount < Account
|
138
|
+
end
|
139
|
+
|
140
|
+
class ObjectStatus
|
141
|
+
FREE = 'free'
|
142
|
+
BOOKED = 'booked'
|
143
|
+
HELD = 'reservedByToken'
|
144
|
+
|
145
|
+
attr_reader :status, :hold_token, :order_id, :ticket_type,
|
146
|
+
:quantity, :extra_data
|
147
|
+
|
148
|
+
def initialize(data)
|
149
|
+
@status = data['status']
|
150
|
+
@hold_token = data['holdToken']
|
151
|
+
@order_id = data['orderId']
|
152
|
+
@ticket_type = data['ticketType']
|
153
|
+
@quantity = data['quantity']
|
154
|
+
@extra_data = data['extraData']
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
class ChangeObjectStatusResult
|
159
|
+
|
160
|
+
attr_reader :labels
|
161
|
+
|
162
|
+
def initialize(data)
|
163
|
+
if data
|
164
|
+
@labels = data['labels'] if data.include? 'labels'
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
class HoldToken
|
170
|
+
|
171
|
+
attr_reader :hold_token, :expires_at, :expires_in_seconds
|
172
|
+
|
173
|
+
def initialize(data)
|
174
|
+
@hold_token = data['holdToken']
|
175
|
+
@expires_at = Time.parse(data['expiresAt'])
|
176
|
+
@expires_in_seconds = data['expiresInSeconds']
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
class BestAvailableObjects
|
181
|
+
|
182
|
+
attr_reader :next_to_each_other, :objects, :labels
|
183
|
+
|
184
|
+
def initialize(data)
|
185
|
+
@next_to_each_other = data['nextToEachOther']
|
186
|
+
@objects = data['objects']
|
187
|
+
@labels = data['labels']
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
class ChartReportItem
|
192
|
+
|
193
|
+
attr_reader :label, :labels, :category_key, :category_label, :section, :entrance, :capacity, :object_type
|
194
|
+
|
195
|
+
def initialize(data)
|
196
|
+
@label = data['label']
|
197
|
+
@labels = data['labels']
|
198
|
+
@category_label = data['categoryLabel']
|
199
|
+
@category_key = data['categoryKey']
|
200
|
+
@section = data['section']
|
201
|
+
@entrance = data['entrance']
|
202
|
+
@capacity = data['capacity']
|
203
|
+
@object_type = data['objectType']
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
class ChartReport
|
208
|
+
|
209
|
+
attr_reader :items
|
210
|
+
|
211
|
+
def initialize(data)
|
212
|
+
items = {}
|
213
|
+
data.each do |key, values|
|
214
|
+
items[key] = []
|
215
|
+
values.each do |value|
|
216
|
+
items[key] << ChartReportItem.new(value)
|
217
|
+
end
|
218
|
+
end
|
219
|
+
@items = items
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
class EventReport
|
224
|
+
|
225
|
+
attr_reader :items
|
226
|
+
|
227
|
+
def initialize(data)
|
228
|
+
if data.is_a? Array
|
229
|
+
items = []
|
230
|
+
data.each do |item|
|
231
|
+
items << EventReportItem.new(item)
|
232
|
+
end
|
233
|
+
@items = items
|
234
|
+
else
|
235
|
+
items = {}
|
236
|
+
data.each do |key, values|
|
237
|
+
items[key] = []
|
238
|
+
values.each do |value|
|
239
|
+
items[key] << EventReportItem.new(value)
|
240
|
+
end
|
241
|
+
end
|
242
|
+
@items = items
|
243
|
+
end
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
class EventReportItem
|
248
|
+
attr_reader :labels, :label, :order_id, :extra_data, :capacity, :status,
|
249
|
+
:category_key, :entrance, :object_type, :hold_token, :category_label,
|
250
|
+
:ticket_type, :num_booked, :for_sale, :section
|
251
|
+
|
252
|
+
def initialize(data)
|
253
|
+
@status = data['status']
|
254
|
+
@label = data['label']
|
255
|
+
@labels = data['labels']
|
256
|
+
@category_label = data['categoryLabel']
|
257
|
+
@category_key = data['categoryKey']
|
258
|
+
@ticket_type = data['ticketType']
|
259
|
+
@order_id = data['orderId']
|
260
|
+
@for_sale = data['forSale']
|
261
|
+
@hold_token = data['holdToken']
|
262
|
+
@section = data['section']
|
263
|
+
@entrance = data['entrance']
|
264
|
+
@num_booked = data['numBooked']
|
265
|
+
@capacity = data['capacity']
|
266
|
+
@object_type = data['objectType']
|
267
|
+
@extra_data = data['extraData']
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
class StatusChange
|
272
|
+
attr_reader :extra_data, :object_label, :date, :id, :status, :event_id
|
273
|
+
|
274
|
+
def initialize(data)
|
275
|
+
@id = data['id']
|
276
|
+
@status = data['status']
|
277
|
+
@date = data['date']# TODO: parse_date(data.get("date"))
|
278
|
+
@object_label = data['objectLabel']
|
279
|
+
@event_id = data['eventId']
|
280
|
+
@extra_data = data['extraData']
|
281
|
+
end
|
282
|
+
end
|
283
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'seatsio/exception'
|
2
|
+
require 'seatsio/httpClient'
|
3
|
+
require 'seatsio/domain'
|
4
|
+
require 'json'
|
5
|
+
require 'cgi'
|
6
|
+
|
7
|
+
module Seatsio
|
8
|
+
# Client for fetching event reports
|
9
|
+
class EventReportsClient
|
10
|
+
def initialize(secret_key, base_url)
|
11
|
+
@http_client = ::Seatsio::HttpClient.new(secret_key, base_url)
|
12
|
+
end
|
13
|
+
|
14
|
+
def summary_by_status(event_key)
|
15
|
+
fetch_summary_report('byStatus', event_key)
|
16
|
+
end
|
17
|
+
|
18
|
+
def summary_by_category_key(event_key)
|
19
|
+
fetch_summary_report('byCategoryKey', event_key)
|
20
|
+
end
|
21
|
+
|
22
|
+
def summary_by_category_label(event_key)
|
23
|
+
fetch_summary_report('byCategoryLabel', event_key)
|
24
|
+
end
|
25
|
+
|
26
|
+
def summary_by_section(event_key)
|
27
|
+
fetch_summary_report('bySection', event_key)
|
28
|
+
end
|
29
|
+
|
30
|
+
def by_label(event_key, label = nil)
|
31
|
+
fetch_report('byLabel', event_key, label)
|
32
|
+
end
|
33
|
+
|
34
|
+
def by_status(event_key, status = nil)
|
35
|
+
fetch_report('byStatus', event_key, status)
|
36
|
+
end
|
37
|
+
|
38
|
+
def by_category_label(event_key, category_label = nil)
|
39
|
+
fetch_report('byCategoryLabel', event_key, category_label)
|
40
|
+
end
|
41
|
+
|
42
|
+
def by_category_key(event_key, category_key = nil)
|
43
|
+
fetch_report('byCategoryKey', event_key, category_key)
|
44
|
+
end
|
45
|
+
|
46
|
+
def by_order_id(event_key, order_id = nil)
|
47
|
+
fetch_report('byOrderId', event_key, order_id)
|
48
|
+
end
|
49
|
+
|
50
|
+
def by_section(event_key, section = nil)
|
51
|
+
fetch_report('bySection', event_key, section)
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def fetch_summary_report(report_type, event_key)
|
57
|
+
url = "reports/events/#{event_key}/#{report_type}/summary"
|
58
|
+
@http_client.get(url)
|
59
|
+
end
|
60
|
+
|
61
|
+
def fetch_report(report_type, event_key, report_filter = nil)
|
62
|
+
if report_filter
|
63
|
+
url = "reports/events/#{event_key}/#{report_type}/#{report_filter}"
|
64
|
+
body = @http_client.get(url)
|
65
|
+
Domain::EventReport.new(body[report_filter])
|
66
|
+
else
|
67
|
+
url = "reports/events/#{event_key}/#{report_type}"
|
68
|
+
body = @http_client.get(url)
|
69
|
+
Domain::EventReport.new(body)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|