seatsio 13 → 15
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/.travis.yml +1 -1
- data/lib/seatsio.rb +3 -1
- data/lib/seatsio/charts.rb +3 -2
- data/lib/seatsio/domain.rb +123 -3
- data/lib/seatsio/events.rb +2 -2
- data/lib/seatsio/usage_reports.rb +31 -0
- data/lib/seatsio/version.rb +1 -1
- 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: 7c3b001909f9735c7b6797461fa06e3480c69e65729f695de85d5208227280cf
|
4
|
+
data.tar.gz: cbb40c10e79f61ca6f9f8c35a08f5d38061fb0fd20a7813a58a59a671070442e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6283f25b4b2b10f27b28c756757a98281f249b9d6bfcdb4fa4b07d54807741c55fdebdf75a7593bcdab026f97e8056f03b80109e0148c4d347ab175de87e7596
|
7
|
+
data.tar.gz: 274b9f2a84dfe1c3448362c5358006e30c1742fb140f88b46d05b902cc06838104f9b2453d47a7d1eecf2676fa44d75b844c6b2b6028955cdb5921f4b2d7d350
|
data/.travis.yml
CHANGED
data/lib/seatsio.rb
CHANGED
@@ -6,12 +6,13 @@ require 'seatsio/events'
|
|
6
6
|
require 'seatsio/hold_tokens'
|
7
7
|
require 'seatsio/chart_reports'
|
8
8
|
require 'seatsio/event_reports'
|
9
|
+
require 'seatsio/usage_reports'
|
9
10
|
|
10
11
|
module Seatsio
|
11
12
|
# Main Seatsio Class
|
12
13
|
class Client
|
13
14
|
attr_reader :charts, :accounts, :subaccounts, :events,
|
14
|
-
:hold_tokens, :chart_reports, :event_reports
|
15
|
+
:hold_tokens, :chart_reports, :event_reports, :usage_reports
|
15
16
|
|
16
17
|
def initialize(secret_key, base_url = 'https://api.seatsio.net')
|
17
18
|
@charts = ChartsClient.new(secret_key, base_url)
|
@@ -21,6 +22,7 @@ module Seatsio
|
|
21
22
|
@hold_tokens = HoldTokensClient.new(secret_key, base_url)
|
22
23
|
@chart_reports = ChartReportsClient.new(secret_key, base_url)
|
23
24
|
@event_reports = EventReportsClient.new(secret_key, base_url)
|
25
|
+
@usage_reports = UsageReportsClient.new(secret_key, base_url)
|
24
26
|
end
|
25
27
|
end
|
26
28
|
end
|
data/lib/seatsio/charts.rb
CHANGED
@@ -88,13 +88,14 @@ module Seatsio
|
|
88
88
|
@http_client.post("charts/#{chart_key}/version/draft/actions/publish")
|
89
89
|
end
|
90
90
|
|
91
|
-
def list(chart_filter: nil, tag: nil, expand_events: nil)
|
91
|
+
def list(chart_filter: nil, tag: nil, expand_events: nil, with_validation: false)
|
92
92
|
cursor = Pagination::Cursor.new(Domain::Chart, 'charts', @http_client)
|
93
93
|
cursor.set_query_param('filter', chart_filter)
|
94
94
|
cursor.set_query_param('tag', tag)
|
95
95
|
|
96
96
|
cursor.set_query_param('expand', 'events') if expand_events
|
97
|
-
|
97
|
+
cursor.set_query_param('validation', with_validation) if with_validation
|
98
|
+
|
98
99
|
cursor
|
99
100
|
end
|
100
101
|
|
data/lib/seatsio/domain.rb
CHANGED
@@ -22,7 +22,7 @@ module Seatsio::Domain
|
|
22
22
|
|
23
23
|
attr_reader :id, :key, :status, :name, :published_version_thumbnail_url,
|
24
24
|
:draft_version_thumbnail_url, :events, :tags, :archived, :venue_type,
|
25
|
-
:categories
|
25
|
+
:categories, :validation
|
26
26
|
|
27
27
|
def initialize(data)
|
28
28
|
@id = data['id']
|
@@ -36,7 +36,7 @@ module Seatsio::Domain
|
|
36
36
|
@archived = data['archived']
|
37
37
|
@venue_type = data['venueType']
|
38
38
|
@categories = ChartCategories.new(data['categories'])
|
39
|
-
|
39
|
+
@validation = data['validation']
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
@@ -292,13 +292,133 @@ module Seatsio::Domain
|
|
292
292
|
end
|
293
293
|
end
|
294
294
|
|
295
|
+
class UsageSummaryForAllMoths
|
296
|
+
attr_reader :items
|
297
|
+
|
298
|
+
def initialize(data)
|
299
|
+
items = []
|
300
|
+
data.each do |item|
|
301
|
+
items << UsageSummaryForMonth.new(item)
|
302
|
+
end
|
303
|
+
@items = items
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
307
|
+
class UsageSummaryForMonth
|
308
|
+
def initialize(data)
|
309
|
+
@month = Month.from_json(data['month'])
|
310
|
+
@num_used_objects = data['numUsedObjects']
|
311
|
+
@num_first_bookings = data['numFirstBookings']
|
312
|
+
@num_first_bookings_by_status = data['numFirstBookingsByStatus']
|
313
|
+
@num_first_bookings_or_selections = data['numFirstBookingsOrSelections']
|
314
|
+
end
|
315
|
+
end
|
316
|
+
|
317
|
+
class UsageDetails
|
318
|
+
|
319
|
+
attr_reader :subaccount
|
320
|
+
|
321
|
+
def initialize(data)
|
322
|
+
@subaccount = data['subaccount'] ? UsageSubaccount.new(data['subaccount']) : nil
|
323
|
+
@usage_by_chart = data['usageByChart'].map {|usage| UsageByChart.new(usage)}
|
324
|
+
end
|
325
|
+
end
|
326
|
+
|
327
|
+
class UsageSubaccount
|
328
|
+
|
329
|
+
attr_reader :id
|
330
|
+
|
331
|
+
def initialize(data)
|
332
|
+
@id = data['id']
|
333
|
+
end
|
334
|
+
end
|
335
|
+
|
336
|
+
class UsageByChart
|
337
|
+
|
338
|
+
attr_reader :chart, :usage_by_event
|
339
|
+
|
340
|
+
def initialize(data)
|
341
|
+
@chart = data['chart'] ? UsageChart.new(data['chart']) : nil
|
342
|
+
@usage_by_event = data['usageByEvent'].map {|usage| UsageByEvent.new(usage)}
|
343
|
+
end
|
344
|
+
end
|
345
|
+
|
346
|
+
class UsageChart
|
347
|
+
|
348
|
+
attr_reader :name, :key
|
349
|
+
|
350
|
+
def initialize(data)
|
351
|
+
@name = data['name']
|
352
|
+
@key = data['key']
|
353
|
+
end
|
354
|
+
end
|
355
|
+
|
356
|
+
class UsageByEvent
|
357
|
+
|
358
|
+
attr_reader :event, :num_used_objects, :num_first_bookings, :num_first_bookings_or_selections,
|
359
|
+
:num_ga_selections_without_booking, :num_non_ga_selections_without_booking, :num_object_selections
|
360
|
+
|
361
|
+
def initialize(data)
|
362
|
+
@event = UsageEvent.new(data['event'])
|
363
|
+
@num_used_objects = data['numUsedObjects']
|
364
|
+
@num_first_bookings = data['numFirstBookings']
|
365
|
+
@num_first_bookings_or_selections = data['numFirstBookingsOrSelections']
|
366
|
+
@num_ga_selections_without_booking = data['numGASelectionsWithoutBooking']
|
367
|
+
@num_non_ga_selections_without_booking = data['numNonGASelectionsWithoutBooking']
|
368
|
+
@num_object_selections = data['numObjectSelections']
|
369
|
+
end
|
370
|
+
end
|
371
|
+
|
372
|
+
class UsageEvent
|
373
|
+
|
374
|
+
attr_reader :id, :key
|
375
|
+
|
376
|
+
def initialize(data)
|
377
|
+
@id = data['id']
|
378
|
+
@key = data['key']
|
379
|
+
end
|
380
|
+
end
|
381
|
+
|
382
|
+
class UsageForObject
|
383
|
+
|
384
|
+
attr_reader :object, :num_first_bookings, :first_booking_date, :num_first_bookings, :num_first_bookings_or_selections
|
385
|
+
|
386
|
+
def initialize(data)
|
387
|
+
@object = data['object']
|
388
|
+
@num_first_bookings = data['numFirstBookings']
|
389
|
+
@first_booking_date = data['firstBookingDate'] ? DateTime.iso8601(data['firstBookingDate']) : nil
|
390
|
+
@num_first_selections = data['numFirstSelections']
|
391
|
+
@num_first_bookings_or_selections = data['numFirstBookingsOrSelections']
|
392
|
+
end
|
393
|
+
end
|
394
|
+
|
395
|
+
class Month
|
396
|
+
|
397
|
+
attr_reader :year, :month
|
398
|
+
|
399
|
+
def self.from_json(data)
|
400
|
+
@year = data['year']
|
401
|
+
@month = data['month']
|
402
|
+
self
|
403
|
+
end
|
404
|
+
|
405
|
+
def initialize(year, month)
|
406
|
+
@year = year
|
407
|
+
@month = month
|
408
|
+
end
|
409
|
+
|
410
|
+
def serialize
|
411
|
+
@year.to_s + "-" + @month.to_s.rjust(2, "0")
|
412
|
+
end
|
413
|
+
end
|
414
|
+
|
295
415
|
class StatusChange
|
296
416
|
attr_reader :extra_data, :object_label, :date, :id, :status, :event_id
|
297
417
|
|
298
418
|
def initialize(data)
|
299
419
|
@id = data['id']
|
300
420
|
@status = data['status']
|
301
|
-
@date = data['date']
|
421
|
+
@date = DateTime.iso8601(data['date'])
|
302
422
|
@object_label = data['objectLabel']
|
303
423
|
@event_id = data['eventId']
|
304
424
|
@extra_data = data['extraData']
|
data/lib/seatsio/events.rb
CHANGED
@@ -15,8 +15,8 @@ module Seatsio
|
|
15
15
|
@http_client = ::Seatsio::HttpClient.new(secret_key, base_url)
|
16
16
|
end
|
17
17
|
|
18
|
-
def create(
|
19
|
-
payload = build_event_request(chart_key:
|
18
|
+
def create(chart_key: nil, event_key: nil, book_whole_tables: nil, table_booking_modes: nil)
|
19
|
+
payload = build_event_request(chart_key: chart_key, event_key: event_key, book_whole_tables: book_whole_tables, table_booking_modes: table_booking_modes)
|
20
20
|
response = @http_client.post("events", payload)
|
21
21
|
Domain::Event.new(response)
|
22
22
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'seatsio/exception'
|
2
|
+
require 'seatsio/httpClient'
|
3
|
+
require 'seatsio/domain'
|
4
|
+
require 'json'
|
5
|
+
require 'cgi'
|
6
|
+
|
7
|
+
module Seatsio
|
8
|
+
class UsageReportsClient
|
9
|
+
def initialize(secret_key, base_url)
|
10
|
+
@http_client = ::Seatsio::HttpClient.new(secret_key, base_url)
|
11
|
+
end
|
12
|
+
|
13
|
+
def summary_for_all_months
|
14
|
+
url = "reports/usage"
|
15
|
+
body = @http_client.get(url)
|
16
|
+
Domain::UsageSummaryForAllMoths.new(body)
|
17
|
+
end
|
18
|
+
|
19
|
+
def details_for_month(month)
|
20
|
+
url = "reports/usage/month/" + month.serialize
|
21
|
+
body = @http_client.get(url)
|
22
|
+
body.map {|item| Domain::UsageDetails.new(item)}
|
23
|
+
end
|
24
|
+
|
25
|
+
def details_for_event_in_month(eventId, month)
|
26
|
+
url = "reports/usage/month/" + month.serialize + "/event/" + eventId.to_s
|
27
|
+
body = @http_client.get(url)
|
28
|
+
body.map {|item| Domain::UsageForObject.new(item)}
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
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: '15'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Seats.io
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -135,6 +135,7 @@ files:
|
|
135
135
|
- lib/seatsio/httpClient.rb
|
136
136
|
- lib/seatsio/pagination/cursor.rb
|
137
137
|
- lib/seatsio/subaccounts.rb
|
138
|
+
- lib/seatsio/usage_reports.rb
|
138
139
|
- lib/seatsio/util.rb
|
139
140
|
- lib/seatsio/version.rb
|
140
141
|
- releasing.md
|