seatsio 67.2.0 → 67.5.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "seatsio",
3
- "version": "67.2.0",
3
+ "version": "67.5.0",
4
4
  "main": "index.js",
5
5
  "description": "Official JavaScript and Node.JS client library for the Seats.io REST API",
6
6
  "license": "MIT",
@@ -16,20 +16,16 @@ class Event {
16
16
  this.updatedOn = event.updatedOn ? new Date(event.updatedOn) : null
17
17
  this.channels = event.channels ? event.channels.map(c => new Channel(c)) : null
18
18
  this.socialDistancingRulesetKey = event.socialDistancingRulesetKey
19
- this.seasonKey = event.season ? event.season.key : null
19
+ this.topLevelSeasonKey = event.topLevelSeasonKey
20
+ this.isTopLevelSeason = event.isTopLevelSeason
21
+ this.isPartialSeason = event.isPartialSeason
22
+ this.isEventInSeason = event.isEventInSeason
23
+ this.objectCategories = event.objectCategories
20
24
  }
21
25
 
22
26
  isSeason () {
23
27
  return false
24
28
  }
25
-
26
- isTopLevelSeason () {
27
- return false
28
- }
29
-
30
- isPartialSeason () {
31
- return false
32
- }
33
29
  }
34
30
 
35
31
  module.exports = Event
@@ -20,9 +20,10 @@ class Events {
20
20
  * @param {?string} eventKey
21
21
  * @param {?TableBookingConfig} tableBookingConfig
22
22
  * @param {?string} socialDistancingRulesetKey
23
+ * @param {?object} objectCategories
23
24
  * @returns {Promise<Event>}
24
25
  */
25
- create (chartKey, eventKey = null, tableBookingConfig = null, socialDistancingRulesetKey = null) {
26
+ create (chartKey, eventKey = null, tableBookingConfig = null, socialDistancingRulesetKey = null, objectCategories = null) {
26
27
  const requestParameters = {}
27
28
 
28
29
  requestParameters.chartKey = chartKey
@@ -39,6 +40,10 @@ class Events {
39
40
  requestParameters.socialDistancingRulesetKey = socialDistancingRulesetKey
40
41
  }
41
42
 
43
+ if (objectCategories !== null) {
44
+ requestParameters.objectCategories = objectCategories
45
+ }
46
+
42
47
  return this.client.post('/events', requestParameters)
43
48
  .then((res) => new EventDeserializer().fromJson(res.data))
44
49
  }
@@ -66,9 +71,10 @@ class Events {
66
71
  * @param {?string} newEventKey
67
72
  * @param {?TableBookingConfig} tableBookingConfig
68
73
  * @param {?string} socialDistancingRulesetKey
74
+ * @param {?object} objectCategories
69
75
  * @returns {Promise}
70
76
  */
71
- update (eventKey, chartKey = null, newEventKey = null, tableBookingConfig = null, socialDistancingRulesetKey = null) {
77
+ update (eventKey, chartKey = null, newEventKey = null, tableBookingConfig = null, socialDistancingRulesetKey = null, objectCategories = null) {
72
78
  const requestParameters = {}
73
79
 
74
80
  if (chartKey !== null) {
@@ -87,6 +93,10 @@ class Events {
87
93
  requestParameters.socialDistancingRulesetKey = socialDistancingRulesetKey
88
94
  }
89
95
 
96
+ if (objectCategories !== null) {
97
+ requestParameters.objectCategories = objectCategories
98
+ }
99
+
90
100
  return this.client.post(`events/${encodeURIComponent(eventKey)}`, requestParameters)
91
101
  }
92
102
 
@@ -14,6 +14,7 @@ class StatusChange {
14
14
  this.holdToken = statusChange.holdToken ? statusChange.holdToken : null
15
15
  this.origin = statusChange.origin
16
16
  this.isPresentOnChart = statusChange.isPresentOnChart
17
+ this.notPresentOnChartReason = statusChange.notPresentOnChartReason
17
18
  this.displayedLabel = statusChange.displayedLabel ? statusChange.displayedLabel : null
18
19
  }
19
20
  }
@@ -8,22 +8,11 @@ class Season extends Event {
8
8
  super(season)
9
9
  this.partialSeasonKeys = season.partialSeasonKeys
10
10
  this.events = season.events ? season.events.map(e => new Event(e)) : undefined
11
- if (this.isTopLevelSeason()) {
12
- this.seasonKey = undefined
13
- }
14
11
  }
15
12
 
16
13
  isSeason () {
17
14
  return true
18
15
  }
19
-
20
- isTopLevelSeason () {
21
- return this.partialSeasonKeys !== undefined
22
- }
23
-
24
- isPartialSeason () {
25
- return !this.isTopLevelSeason()
26
- }
27
16
  }
28
17
 
29
18
  module.exports = Season
@@ -61,3 +61,13 @@ test('it supports a social distancing ruleset key', async () => {
61
61
 
62
62
  expect(event.socialDistancingRulesetKey).toBe('ruleset1')
63
63
  })
64
+
65
+ test('it supports object categories', async () => {
66
+ const { client, user } = await testUtils.createTestUserAndClient()
67
+ const chartKey = testUtils.getChartKey()
68
+ await testUtils.createTestChart(chartKey, user.secretKey)
69
+
70
+ const event = await client.events.create(chartKey, null, null, null, { 'A-1': 10 })
71
+
72
+ expect(event.objectCategories).toEqual({ 'A-1': 10 })
73
+ })
@@ -2,6 +2,7 @@ const testUtils = require('../testUtils.js')
2
2
  const ObjectProperties = require('../../src/Events/ObjectProperties.js')
3
3
  const EventObjectInfo = require('../../src/Events/EventObjectInfo.js')
4
4
  const StatusChangesParams = require('../../src/Events/StatusChangesParams.js')
5
+ const {TableBookingconfig} = require("../../index");
5
6
 
6
7
  test('should list all status changes', async () => {
7
8
  const { client, user } = await testUtils.createTestUserAndClient()
@@ -176,6 +177,23 @@ test('properties of status changes', async () => {
176
177
  expect(statusChange.value.origin.type).toBe('API_CALL')
177
178
  expect(statusChange.value.displayedLabel).toBe('A-1')
178
179
  expect(statusChange.value.isPresentOnChart).toBe(true)
180
+ expect(statusChange.value.notPresentOnChartReason).toBe(undefined)
181
+ })
182
+
183
+ test('not present on chart anymore', async () => {
184
+ const { client, user } = await testUtils.createTestUserAndClient()
185
+ const chartKey = testUtils.getChartKey()
186
+ await testUtils.createTestChartWithTables(chartKey, user.secretKey)
187
+ const event = await client.events.create(chartKey, null, TableBookingconfig.allByTable())
188
+ await client.events.book(event.key, 'T1')
189
+ await client.events.update(event.key, null, null, TableBookingconfig.allBySeat())
190
+
191
+ const statusChanges = client.events.statusChanges(event.key).all()
192
+ const statusChangesIterator = statusChanges[Symbol.asyncIterator]()
193
+ const statusChange = await statusChangesIterator.next()
194
+
195
+ expect(statusChange.value.isPresentOnChart).toBe(false)
196
+ expect(statusChange.value.notPresentOnChartReason).toBe('SWITCHED_TO_BOOK_BY_SEAT')
179
197
  })
180
198
 
181
199
  test('should list status changes with hold token', async () => {
@@ -20,7 +20,7 @@ test('should retrieve event', async () => {
20
20
  expect(retrievedEvent.createdOn.getTime()).toBeLessThanOrEqual(now.getTime() + 5000)
21
21
  expect(retrievedEvent.forSaleConfig).toBeFalsy()
22
22
  expect(retrievedEvent.updatedOn).toBeNull()
23
- expect(retrievedEvent.seasonKey).toBeNull()
23
+ expect(retrievedEvent.topLevelSeasonKey).toBe(undefined)
24
24
  })
25
25
 
26
26
  test('retrieve season', async () => {
@@ -34,7 +34,9 @@ test('retrieve season', async () => {
34
34
  const retrievedSeason = await client.events.retrieve(season.key)
35
35
 
36
36
  expect(retrievedSeason.isSeason()).toBe(true)
37
- expect(retrievedSeason.isTopLevelSeason()).toBe(true)
37
+ expect(retrievedSeason.isTopLevelSeason).toBe(true)
38
+ expect(retrievedSeason.isPartialSeason).toBe(false)
39
+ expect(retrievedSeason.isEventInSeason).toBe(false)
38
40
  expect(retrievedSeason.key).toBeTruthy()
39
41
  expect(retrievedSeason.id).toBeTruthy()
40
42
  expect(retrievedSeason.partialSeasonKeys).toEqual([partialSeason1.key, partialSeason2.key])
@@ -45,7 +47,7 @@ test('retrieve season', async () => {
45
47
  expect(retrievedSeason.createdOn).toBeInstanceOf(Date)
46
48
  expect(retrievedSeason.forSaleConfig).toBeFalsy()
47
49
  expect(retrievedSeason.updatedOn).toBeFalsy()
48
- expect(retrievedSeason.seasonKey).toBe(undefined)
50
+ expect(retrievedSeason.topLevelSeasonKey).toBe(undefined)
49
51
  })
50
52
 
51
53
  test('retrieve partial season', async () => {
@@ -59,7 +61,9 @@ test('retrieve partial season', async () => {
59
61
  const retrievedSeason = await client.events.retrieve(partialSeason1.key)
60
62
 
61
63
  expect(retrievedSeason.isSeason()).toBe(true)
62
- expect(retrievedSeason.isPartialSeason()).toBe(true)
64
+ expect(retrievedSeason.isTopLevelSeason).toBe(false)
65
+ expect(retrievedSeason.isPartialSeason).toBe(true)
66
+ expect(retrievedSeason.isEventInSeason).toBe(false)
63
67
  expect(retrievedSeason.key).toBeTruthy()
64
68
  expect(retrievedSeason.id).toBeTruthy()
65
69
  expect(retrievedSeason.partialSeasonKeys).toBe(undefined)
@@ -70,7 +74,7 @@ test('retrieve partial season', async () => {
70
74
  expect(retrievedSeason.createdOn).toBeInstanceOf(Date)
71
75
  expect(retrievedSeason.forSaleConfig).toBeFalsy()
72
76
  expect(retrievedSeason.updatedOn).toBeFalsy()
73
- expect(retrievedSeason.seasonKey).toBe(season.key)
77
+ expect(retrievedSeason.topLevelSeasonKey).toBe(season.key)
74
78
  })
75
79
 
76
80
  test('retrieve event in season', async () => {
@@ -82,5 +86,8 @@ test('retrieve event in season', async () => {
82
86
  const retrievedEvent = await client.events.retrieve('event1')
83
87
 
84
88
  expect(retrievedEvent.isSeason()).toBe(false)
85
- expect(retrievedEvent.seasonKey).toBe(season.key)
89
+ expect(retrievedEvent.isTopLevelSeason).toBe(false)
90
+ expect(retrievedEvent.isPartialSeason).toBe(false)
91
+ expect(retrievedEvent.isEventInSeason).toBe(true)
92
+ expect(retrievedEvent.topLevelSeasonKey).toBe(season.key)
86
93
  })
@@ -74,3 +74,29 @@ test('it supports removing the social distancing ruleset key', async () => {
74
74
  const retrievedEvent = await client.events.retrieve(event.key)
75
75
  expect(retrievedEvent.socialDistancingRulesetKey).toBe(undefined)
76
76
  })
77
+
78
+ test('it supports object categories', async () => {
79
+ const { client, user } = await testUtils.createTestUserAndClient()
80
+ const chartKey = testUtils.getChartKey()
81
+ await testUtils.createTestChart(chartKey, user.secretKey)
82
+
83
+ const event = await client.events.create(chartKey, null, null, null, { 'A-1': 9 })
84
+
85
+ await client.events.update(event.key, null, null, null, null, { 'A-1': 10 })
86
+
87
+ const retrievedEvent = await client.events.retrieve(event.key)
88
+ expect(retrievedEvent.objectCategories).toEqual({ 'A-1': 10 })
89
+ })
90
+
91
+ test('it supports removing the object categories', async () => {
92
+ const { client, user } = await testUtils.createTestUserAndClient()
93
+ const chartKey = testUtils.getChartKey()
94
+ await testUtils.createTestChart(chartKey, user.secretKey)
95
+
96
+ const event = await client.events.create(chartKey, null, null, null, { 'A-2': 9 })
97
+
98
+ await client.events.update(event.key, null, null, null, null, { })
99
+
100
+ const retrievedEvent = await client.events.retrieve(event.key)
101
+ expect(retrievedEvent.objectCategories).toBeFalsy()
102
+ })