seatsio 67.3.0 → 67.6.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.3.0",
3
+ "version": "67.6.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",
@@ -14,7 +14,7 @@
14
14
  "url": "https://github.com/seatsio/seatsio-js"
15
15
  },
16
16
  "dependencies": {
17
- "axios": "0.25.0"
17
+ "axios": "0.26.0"
18
18
  },
19
19
  "devDependencies": {
20
20
  "browserify": "latest",
@@ -30,8 +30,8 @@
30
30
  "gulp-tap": "latest",
31
31
  "gulp-uglify": "latest",
32
32
  "gulp-uglify-es": "latest",
33
- "jest": "27.4.7",
34
- "jest-cli": "27.4.7",
33
+ "jest": "27.5.1",
34
+ "jest-cli": "27.5.1",
35
35
  "uuid": "8.3.2"
36
36
  }
37
37
  }
@@ -20,6 +20,7 @@ class Event {
20
20
  this.isTopLevelSeason = event.isTopLevelSeason
21
21
  this.isPartialSeason = event.isPartialSeason
22
22
  this.isEventInSeason = event.isEventInSeason
23
+ this.objectCategories = event.objectCategories
23
24
  }
24
25
 
25
26
  isSeason () {
@@ -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
  }
@@ -1,4 +1,5 @@
1
1
  const Season = require('./Season')
2
+ const EventDeserializer = require('../Events/EventDeserializer')
2
3
 
3
4
  class Seasons {
4
5
  /**
@@ -84,7 +85,7 @@ class Seasons {
84
85
  }
85
86
 
86
87
  return this.client.post(`/seasons/${encodeURIComponent(key)}/actions/create-events`, requestParameters)
87
- .then((res) => new Season(res.data))
88
+ .then((res) => res.data.events.map(e => new EventDeserializer().fromJson(e)))
88
89
  }
89
90
 
90
91
  /**
@@ -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 () => {
@@ -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
+ })
@@ -5,9 +5,9 @@ test('create events in season by event keys', async () => {
5
5
  const chart = await client.charts.create()
6
6
  const season = await client.seasons.create(chart.key)
7
7
 
8
- const updatedSeason = await client.seasons.createEvents(season.key, null, ['event1', 'event2'])
8
+ const events = await client.seasons.createEvents(season.key, null, ['event1', 'event2'])
9
9
 
10
- expect(updatedSeason.events.map(e => e.key)).toEqual(['event1', 'event2'])
10
+ expect(events.map(e => e.key)).toEqual(['event2', 'event1'])
11
11
  })
12
12
 
13
13
  test('create events in season by number of events', async () => {
@@ -15,7 +15,7 @@ test('create events in season by number of events', async () => {
15
15
  const chart = await client.charts.create()
16
16
  const season = await client.seasons.create(chart.key)
17
17
 
18
- const updatedSeason = await client.seasons.createEvents(season.key, 2)
18
+ const events = await client.seasons.createEvents(season.key, 2)
19
19
 
20
- expect(updatedSeason.events.length).toBe(2)
20
+ expect(events.length).toBe(2)
21
21
  })