seatsio 65.3.0 → 66.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.
- package/package.json +5 -5
- package/src/AsyncIterator.js +14 -0
- package/src/Events/StatusChange.js +2 -0
- package/src/Seasons/Season.js +16 -0
- package/src/Seasons/SeasonParams.js +28 -0
- package/src/Seasons/Seasons.js +194 -0
- package/src/SeatsioClient.js +2 -0
- package/tests/events/listAllStatusChanges.test.js +2 -0
- package/tests/seasons/addEventsToPartialSeason.test.js +13 -0
- package/tests/seasons/createEventsInSeason.test.js +21 -0
- package/tests/seasons/createPartialSeason.test.js +22 -0
- package/tests/seasons/createSeason.test.js +76 -0
- package/tests/seasons/deletePartialSeason.test.js +18 -0
- package/tests/seasons/deleteSeason.test.js +17 -0
- package/tests/seasons/listAllSeasons.test.js +16 -0
- package/tests/seasons/removeEventsFromPartialSeason.test.js +13 -0
- package/tests/seasons/retrievePartialSeason.test.js +25 -0
- package/tests/seasons/retrieveSeason.test.js +29 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "seatsio",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "66.0.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,13 +14,13 @@
|
|
|
14
14
|
"url": "https://github.com/seatsio/seatsio-js"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"axios": "0.
|
|
17
|
+
"axios": "0.25.0"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"browserify": "latest",
|
|
21
21
|
"eslint": "7.32.0",
|
|
22
22
|
"eslint-config-standard": "16.0.3",
|
|
23
|
-
"eslint-plugin-import": "2.25.
|
|
23
|
+
"eslint-plugin-import": "2.25.4",
|
|
24
24
|
"eslint-plugin-node": "11.1.0",
|
|
25
25
|
"eslint-plugin-promise": "6.0.0",
|
|
26
26
|
"eslint-plugin-standard": "5.0.0",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"gulp-tap": "latest",
|
|
31
31
|
"gulp-uglify": "latest",
|
|
32
32
|
"gulp-uglify-es": "latest",
|
|
33
|
-
"jest": "27.4.
|
|
34
|
-
"jest-cli": "27.4.
|
|
33
|
+
"jest": "27.4.7",
|
|
34
|
+
"jest-cli": "27.4.7",
|
|
35
35
|
"uuid": "8.3.2"
|
|
36
36
|
}
|
|
37
37
|
}
|
package/src/AsyncIterator.js
CHANGED
|
@@ -5,6 +5,7 @@ const Event = require('./Events/Event.js')
|
|
|
5
5
|
const User = require('./Users/User.js')
|
|
6
6
|
const Subaccount = require('./Subaccounts/Subaccount.js')
|
|
7
7
|
const Workspace = require('./Workspaces/Workspace.js')
|
|
8
|
+
const Season = require('./Seasons/Season')
|
|
8
9
|
|
|
9
10
|
class AsyncIterator {
|
|
10
11
|
/**
|
|
@@ -45,6 +46,16 @@ class AsyncIterator {
|
|
|
45
46
|
this.pages.push(new Page(events, data.next_page_starts_after, data.previous_page_ends_before))
|
|
46
47
|
}
|
|
47
48
|
|
|
49
|
+
seasons (data) {
|
|
50
|
+
const seasons = []
|
|
51
|
+
data.items.forEach(seasonData => {
|
|
52
|
+
const season = new Season(seasonData)
|
|
53
|
+
this.items.push(season)
|
|
54
|
+
seasons.push(season)
|
|
55
|
+
})
|
|
56
|
+
this.pages.push(new Page(seasons, data.next_page_starts_after, data.previous_page_ends_before))
|
|
57
|
+
}
|
|
58
|
+
|
|
48
59
|
statusChanges (data) {
|
|
49
60
|
const statusChanges = []
|
|
50
61
|
data.items.forEach((statusData) => {
|
|
@@ -102,6 +113,9 @@ class AsyncIterator {
|
|
|
102
113
|
case 'events':
|
|
103
114
|
this.events(res.data)
|
|
104
115
|
break
|
|
116
|
+
case 'seasons':
|
|
117
|
+
this.seasons(res.data)
|
|
118
|
+
break
|
|
105
119
|
case 'statusChanges':
|
|
106
120
|
this.statusChanges(res.data)
|
|
107
121
|
break
|
|
@@ -13,6 +13,8 @@ class StatusChange {
|
|
|
13
13
|
this.extraData = statusChange.extraData ? statusChange.extraData : null
|
|
14
14
|
this.holdToken = statusChange.holdToken ? statusChange.holdToken : null
|
|
15
15
|
this.origin = statusChange.origin
|
|
16
|
+
this.isPresentOnChart = statusChange.isPresentOnChart
|
|
17
|
+
this.displayedLabel = statusChange.displayedLabel ? statusChange.displayedLabel : null
|
|
16
18
|
}
|
|
17
19
|
}
|
|
18
20
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const Event = require('../Events/Event.js')
|
|
2
|
+
|
|
3
|
+
class Season {
|
|
4
|
+
/**
|
|
5
|
+
* @param {object} season
|
|
6
|
+
*/
|
|
7
|
+
constructor (season) {
|
|
8
|
+
this.id = season.id
|
|
9
|
+
this.key = season.key
|
|
10
|
+
this.seasonEvent = new Event(season.seasonEvent)
|
|
11
|
+
this.partialSeasonKeys = season.partialSeasonKeys
|
|
12
|
+
this.events = season.events.map(e => new Event(e))
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
module.exports = Season
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
class SeasonParams {
|
|
2
|
+
key (key) {
|
|
3
|
+
this._key = key
|
|
4
|
+
return this
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
numberOfEvents (numberOfEvents) {
|
|
8
|
+
this._numberOfEvents = numberOfEvents
|
|
9
|
+
return this
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
eventKeys (eventKeys) {
|
|
13
|
+
this._eventKeys = eventKeys
|
|
14
|
+
return this
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
tableBookingConfig (tableBookingConfig) {
|
|
18
|
+
this._tableBookingConfig = tableBookingConfig
|
|
19
|
+
return this
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
socialDistancingRulesetKey (socialDistancingRulesetKey) {
|
|
23
|
+
this._socialDistancingRulesetKey = socialDistancingRulesetKey
|
|
24
|
+
return this
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
module.exports = SeasonParams
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
const Page = require('../Page.js')
|
|
2
|
+
const Lister = require('../Lister.js')
|
|
3
|
+
const Season = require('./Season')
|
|
4
|
+
|
|
5
|
+
class Seasons {
|
|
6
|
+
/**
|
|
7
|
+
* @param {SeatsioClient} client
|
|
8
|
+
*/
|
|
9
|
+
constructor (client) {
|
|
10
|
+
this.client = client
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @param {string} chartKey
|
|
15
|
+
* @param {?seasonParams} SeasonParams
|
|
16
|
+
* @returns {Promise<Season>}
|
|
17
|
+
*/
|
|
18
|
+
create (chartKey, seasonParams = null) {
|
|
19
|
+
const requestParameters = {}
|
|
20
|
+
|
|
21
|
+
requestParameters.chartKey = chartKey
|
|
22
|
+
|
|
23
|
+
if (seasonParams !== null) {
|
|
24
|
+
if (seasonParams._key !== null) {
|
|
25
|
+
requestParameters.key = seasonParams._key
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (seasonParams._numberOfEvents !== null) {
|
|
29
|
+
requestParameters.numberOfEvents = seasonParams._numberOfEvents
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (seasonParams._eventKeys !== null) {
|
|
33
|
+
requestParameters.eventKeys = seasonParams._eventKeys
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (seasonParams._tableBookingConfig !== null) {
|
|
37
|
+
requestParameters.tableBookingConfig = seasonParams._tableBookingConfig
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (seasonParams._socialDistancingRulesetKey !== null) {
|
|
41
|
+
requestParameters.socialDistancingRulesetKey = seasonParams._socialDistancingRulesetKey
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return this.client.post('/seasons', requestParameters)
|
|
46
|
+
.then((res) => new Season(res.data))
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @param {string} topLevelSeasonKey
|
|
51
|
+
* @param {?string} partialSeasonKey
|
|
52
|
+
* @param {?string[]} eventKeys
|
|
53
|
+
* @returns {Promise<Season>}
|
|
54
|
+
*/
|
|
55
|
+
createPartialSeason (topLevelSeasonKey, partialSeasonKey = null, eventKeys = null) {
|
|
56
|
+
const requestParameters = {}
|
|
57
|
+
|
|
58
|
+
if (partialSeasonKey !== null) {
|
|
59
|
+
requestParameters.key = partialSeasonKey
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (eventKeys !== null) {
|
|
63
|
+
requestParameters.eventKeys = eventKeys
|
|
64
|
+
}
|
|
65
|
+
return this.client.post(`/seasons/${encodeURIComponent(topLevelSeasonKey)}/partial-seasons`, requestParameters)
|
|
66
|
+
.then((res) => new Season(res.data))
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* @param {string} key
|
|
71
|
+
* @returns {Promise<Season>}
|
|
72
|
+
*/
|
|
73
|
+
retrieve (key) {
|
|
74
|
+
return this.client.get(`/seasons/${encodeURIComponent(key)}`)
|
|
75
|
+
.then((res) => new Season(res.data))
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @param {string} topLevelSeasonKey
|
|
80
|
+
* @param {?string} partialSeasonKey
|
|
81
|
+
* @returns {Promise<Season>}
|
|
82
|
+
*/
|
|
83
|
+
retrievePartialSeason (topLevelSeasonKey, partialSeasonKey) {
|
|
84
|
+
return this.client.get(`/seasons/${encodeURIComponent(topLevelSeasonKey)}/partial-seasons/${encodeURIComponent(partialSeasonKey)}`)
|
|
85
|
+
.then((res) => new Season(res.data))
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* @param {string} key
|
|
90
|
+
* @param {?number} numberOfEvents
|
|
91
|
+
* @param {?string[]} eventKeys
|
|
92
|
+
* @returns {Promise<Season>}
|
|
93
|
+
*/
|
|
94
|
+
createEvents (key, numberOfEvents = null, eventKeys = null) {
|
|
95
|
+
const requestParameters = { }
|
|
96
|
+
|
|
97
|
+
if (numberOfEvents !== null) {
|
|
98
|
+
requestParameters.numberOfEvents = numberOfEvents
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (eventKeys !== null) {
|
|
102
|
+
requestParameters.eventKeys = eventKeys
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return this.client.post(`/seasons/${encodeURIComponent(key)}/actions/create-events`, requestParameters)
|
|
106
|
+
.then((res) => new Season(res.data))
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* @param {string} topLevelSeasonKey
|
|
111
|
+
* @param {string} partialSeasonKey
|
|
112
|
+
* @param {string[]} eventKeys
|
|
113
|
+
* @returns {Promise<Season>}
|
|
114
|
+
*/
|
|
115
|
+
addEventsToPartialSeason (topLevelSeasonKey, partialSeasonKey, eventKeys) {
|
|
116
|
+
const requestParameters = { eventKeys }
|
|
117
|
+
return this.client.post(`/seasons/${encodeURIComponent(topLevelSeasonKey)}/partial-seasons/${encodeURIComponent(partialSeasonKey)}/actions/add-events`, requestParameters)
|
|
118
|
+
.then((res) => new Season(res.data))
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* @param {string} key
|
|
123
|
+
* @returns {Promise}
|
|
124
|
+
*/
|
|
125
|
+
delete (key) {
|
|
126
|
+
return this.client.delete(`/seasons/${encodeURIComponent(key)}`)
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* @param {string} topLevelSeasonKey
|
|
131
|
+
* @param {string} partialSeasonKey
|
|
132
|
+
* @returns {Promise<void>}
|
|
133
|
+
*/
|
|
134
|
+
deletePartialSeason (topLevelSeasonKey, partialSeasonKey) {
|
|
135
|
+
return this.client.delete(`/seasons/${encodeURIComponent(topLevelSeasonKey)}/partial-seasons/${encodeURIComponent(partialSeasonKey)}`)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* @param {string} topLevelSeasonKey
|
|
140
|
+
* @param {string} partialSeasonKey
|
|
141
|
+
* @param {string} eventKey
|
|
142
|
+
* @returns {Promise<Season>}
|
|
143
|
+
*/
|
|
144
|
+
async removeEventFromPartialSeason (topLevelSeasonKey, partialSeasonKey, eventKey) {
|
|
145
|
+
return this.client.delete(`/seasons/${encodeURIComponent(topLevelSeasonKey)}/partial-seasons/${encodeURIComponent(partialSeasonKey)}/events/${encodeURIComponent(eventKey)}`)
|
|
146
|
+
.then((res) => new Season(res.data))
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* @param {?object} requestParameters
|
|
151
|
+
* @returns {AsyncIterator<Season>}
|
|
152
|
+
*/
|
|
153
|
+
listAll (requestParameters = {}) {
|
|
154
|
+
return this.iterator().all(requestParameters)
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* @param {?number} pageSize
|
|
159
|
+
* @returns {Page<Season>}
|
|
160
|
+
*/
|
|
161
|
+
listFirstPage (pageSize = null) {
|
|
162
|
+
return this.iterator().firstPage(null, pageSize)
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* @param {?string} afterId
|
|
167
|
+
* @param {?number} pageSize
|
|
168
|
+
* @returns {Page<Season>}
|
|
169
|
+
*/
|
|
170
|
+
listPageAfter (afterId, pageSize = null) {
|
|
171
|
+
return this.iterator().pageAfter(afterId, null, pageSize)
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* @param {?string} beforeId
|
|
176
|
+
* @param {?number} pageSize
|
|
177
|
+
* @returns {Page<Season>}
|
|
178
|
+
*/
|
|
179
|
+
listPageBefore (beforeId, pageSize = null) {
|
|
180
|
+
return this.iterator().pageBefore(beforeId, null, pageSize)
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* @returns {Lister}
|
|
185
|
+
*/
|
|
186
|
+
iterator () {
|
|
187
|
+
return new Lister('/seasons', this.client, 'seasons', (data) => {
|
|
188
|
+
const seasons = data.items.map(seasonData => new Season(seasonData))
|
|
189
|
+
return new Page(seasons, data.next_page_starts_after, data.previous_page_ends_before)
|
|
190
|
+
})
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
module.exports = Seasons
|
package/src/SeatsioClient.js
CHANGED
|
@@ -11,6 +11,7 @@ const EventReports = require('./Reports/EventReports.js')
|
|
|
11
11
|
const UsageReports = require('./Reports/UsageReports.js')
|
|
12
12
|
const errorResponseHandler = require('./errorInterceptor.js')
|
|
13
13
|
const Axios = require('axios')
|
|
14
|
+
const Seasons = require('./Seasons/Seasons')
|
|
14
15
|
|
|
15
16
|
class SeatsioClient {
|
|
16
17
|
constructor (region, secretKey, workspaceKey = null, extraHeaders = {}) {
|
|
@@ -32,6 +33,7 @@ class SeatsioClient {
|
|
|
32
33
|
this.chartReports = new ChartReports(this.client)
|
|
33
34
|
this.eventReports = new EventReports(this.client)
|
|
34
35
|
this.usageReports = new UsageReports(this.client)
|
|
36
|
+
this.seasons = new Seasons(this.client)
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
_axiosConfig (baseUrl, secretKey, workspaceKey, extraHeaders) {
|
|
@@ -174,6 +174,8 @@ test('properties of status changes', async () => {
|
|
|
174
174
|
expect(statusChange.value.eventId).toBe(event.id)
|
|
175
175
|
expect(statusChange.value.extraData).toEqual({ foo: 'bar' })
|
|
176
176
|
expect(statusChange.value.origin.type).toBe('API_CALL')
|
|
177
|
+
expect(statusChange.value.displayedLabel).toBe('A-1')
|
|
178
|
+
expect(statusChange.value.isPresentOnChart).toBe(true)
|
|
177
179
|
})
|
|
178
180
|
|
|
179
181
|
test('should list status changes with hold token', async () => {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const testUtils = require('../testUtils.js')
|
|
2
|
+
const SeasonParams = require('../../src/Seasons/SeasonParams')
|
|
3
|
+
|
|
4
|
+
test('add events to partial season', async () => {
|
|
5
|
+
const { client } = await testUtils.createTestUserAndClient()
|
|
6
|
+
const chart = await client.charts.create()
|
|
7
|
+
const season = await client.seasons.create(chart.key, new SeasonParams().eventKeys(['event1', 'event2']))
|
|
8
|
+
const partialSeason = await client.seasons.createPartialSeason(season.key)
|
|
9
|
+
|
|
10
|
+
const updatedPartialSeason = await client.seasons.addEventsToPartialSeason(season.key, partialSeason.key, ['event1', 'event2'])
|
|
11
|
+
|
|
12
|
+
expect(updatedPartialSeason.events.map(e => e.key)).toEqual(['event1', 'event2'])
|
|
13
|
+
})
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const testUtils = require('../testUtils.js')
|
|
2
|
+
|
|
3
|
+
test('create events in season by event keys', async () => {
|
|
4
|
+
const { client } = await testUtils.createTestUserAndClient()
|
|
5
|
+
const chart = await client.charts.create()
|
|
6
|
+
const season = await client.seasons.create(chart.key)
|
|
7
|
+
|
|
8
|
+
const updatedSeason = await client.seasons.createEvents(season.key, null, ['event1', 'event2'])
|
|
9
|
+
|
|
10
|
+
expect(updatedSeason.events.map(e => e.key)).toEqual(['event1', 'event2'])
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
test('create events in season by number of events', async () => {
|
|
14
|
+
const { client } = await testUtils.createTestUserAndClient()
|
|
15
|
+
const chart = await client.charts.create()
|
|
16
|
+
const season = await client.seasons.create(chart.key)
|
|
17
|
+
|
|
18
|
+
const updatedSeason = await client.seasons.createEvents(season.key, 2)
|
|
19
|
+
|
|
20
|
+
expect(updatedSeason.events.length).toBe(2)
|
|
21
|
+
})
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const testUtils = require('../testUtils.js')
|
|
2
|
+
const SeasonParams = require('../../src/Seasons/SeasonParams')
|
|
3
|
+
|
|
4
|
+
test('key can be passed in', async () => {
|
|
5
|
+
const { client } = await testUtils.createTestUserAndClient()
|
|
6
|
+
const chart = await client.charts.create()
|
|
7
|
+
const season = await client.seasons.create(chart.key)
|
|
8
|
+
|
|
9
|
+
const partialSeason = await client.seasons.createPartialSeason(season.key, 'aPartialSeason')
|
|
10
|
+
|
|
11
|
+
expect(partialSeason.key).toBe('aPartialSeason')
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
test('event keys can be passed in', async () => {
|
|
15
|
+
const { client } = await testUtils.createTestUserAndClient()
|
|
16
|
+
const chart = await client.charts.create()
|
|
17
|
+
const season = await client.seasons.create(chart.key, new SeasonParams().eventKeys(['event1', 'event2']))
|
|
18
|
+
|
|
19
|
+
const partialSeason = await client.seasons.createPartialSeason(season.key, null, ['event1', 'event2'])
|
|
20
|
+
|
|
21
|
+
expect(partialSeason.events.map(event => event.key)).toEqual(['event1', 'event2'])
|
|
22
|
+
})
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
const testUtils = require('../testUtils.js')
|
|
2
|
+
const SocialDistancingRuleset = require('../../src/Charts/SocialDistancingRuleset.js')
|
|
3
|
+
const TableBookingConfig = require('../../src/Events/TableBookingConfig')
|
|
4
|
+
const SeasonParams = require('../../src/Seasons/SeasonParams')
|
|
5
|
+
|
|
6
|
+
test('chart key is required', async () => {
|
|
7
|
+
const { client, user } = await testUtils.createTestUserAndClient()
|
|
8
|
+
const chartKey = testUtils.getChartKey()
|
|
9
|
+
await testUtils.createTestChart(chartKey, user.secretKey)
|
|
10
|
+
|
|
11
|
+
const season = await client.seasons.create(chartKey)
|
|
12
|
+
|
|
13
|
+
expect(season.key).toBeTruthy()
|
|
14
|
+
expect(season.id).toBeTruthy()
|
|
15
|
+
expect(season.partialSeasonKeys.length).toBe(0)
|
|
16
|
+
expect(season.events.length).toBe(0)
|
|
17
|
+
|
|
18
|
+
const seasonEvent = season.seasonEvent
|
|
19
|
+
expect(seasonEvent.id).toBeTruthy()
|
|
20
|
+
expect(seasonEvent.key).toBe(season.key)
|
|
21
|
+
expect(seasonEvent.chartKey).toBe(chartKey)
|
|
22
|
+
expect(seasonEvent.tableBookingConfig).toEqual(TableBookingConfig.inherit())
|
|
23
|
+
expect(seasonEvent.supportsBestAvailable).toBe(true)
|
|
24
|
+
expect(seasonEvent.createdOn).toBeInstanceOf(Date)
|
|
25
|
+
expect(seasonEvent.forSaleConfig).toBeFalsy()
|
|
26
|
+
expect(seasonEvent.updatedOn).toBeFalsy()
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
test('key can be passed in', async () => {
|
|
30
|
+
const { client } = await testUtils.createTestUserAndClient()
|
|
31
|
+
const chart = await client.charts.create()
|
|
32
|
+
|
|
33
|
+
const season = await client.seasons.create(chart.key, new SeasonParams().key('aSeason'))
|
|
34
|
+
|
|
35
|
+
expect(season.key).toBe('aSeason')
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
test('number of events can be passed in', async () => {
|
|
39
|
+
const { client } = await testUtils.createTestUserAndClient()
|
|
40
|
+
const chart = await client.charts.create()
|
|
41
|
+
|
|
42
|
+
const season = await client.seasons.create(chart.key, new SeasonParams().numberOfEvents(2))
|
|
43
|
+
|
|
44
|
+
expect(season.events.length).toBe(2)
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
test('event keys can be passed in', async () => {
|
|
48
|
+
const { client } = await testUtils.createTestUserAndClient()
|
|
49
|
+
const chart = await client.charts.create()
|
|
50
|
+
|
|
51
|
+
const season = await client.seasons.create(chart.key, new SeasonParams().eventKeys(['event1', 'event2']))
|
|
52
|
+
|
|
53
|
+
expect(season.events.map(event => event.key)).toEqual(['event1', 'event2'])
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
test('table booking config can be passed in', async () => {
|
|
57
|
+
const { client, user } = await testUtils.createTestUserAndClient()
|
|
58
|
+
const chartKey = testUtils.getChartKey()
|
|
59
|
+
await testUtils.createTestChartWithTables(chartKey, user.secretKey)
|
|
60
|
+
const tableBookingConfig = TableBookingConfig.custom({ T1: 'BY_TABLE', T2: 'BY_SEAT' })
|
|
61
|
+
|
|
62
|
+
const season = await client.seasons.create(chartKey, new SeasonParams().tableBookingConfig(tableBookingConfig))
|
|
63
|
+
|
|
64
|
+
expect(season.seasonEvent.tableBookingConfig).toEqual(tableBookingConfig)
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
test('social distancing ruleset key can be passed in', async () => {
|
|
68
|
+
const { client } = await testUtils.createTestUserAndClient()
|
|
69
|
+
const chart = await client.charts.create()
|
|
70
|
+
const rulesets = { ruleset1: SocialDistancingRuleset.ruleBased('My ruleset').build() }
|
|
71
|
+
await client.charts.saveSocialDistancingRulesets(chart.key, rulesets)
|
|
72
|
+
|
|
73
|
+
const season = await client.seasons.create(chart.key, new SeasonParams().socialDistancingRulesetKey('ruleset1'))
|
|
74
|
+
|
|
75
|
+
expect(season.seasonEvent.socialDistancingRulesetKey).toBe('ruleset1')
|
|
76
|
+
})
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const testUtils = require('../testUtils.js')
|
|
2
|
+
|
|
3
|
+
test('delete partial season', async () => {
|
|
4
|
+
const { client, user } = await testUtils.createTestUserAndClient()
|
|
5
|
+
const chartKey = testUtils.getChartKey()
|
|
6
|
+
await testUtils.createTestChart(chartKey, user.secretKey)
|
|
7
|
+
const season = await client.seasons.create(chartKey)
|
|
8
|
+
const partialSeason = await client.seasons.createPartialSeason(season.key)
|
|
9
|
+
|
|
10
|
+
await client.seasons.deletePartialSeason(season.key, partialSeason.key)
|
|
11
|
+
|
|
12
|
+
try {
|
|
13
|
+
await client.seasons.retrievePartialSeason(season.key, partialSeason.key)
|
|
14
|
+
throw new Error('Should have failed')
|
|
15
|
+
} catch (e) {
|
|
16
|
+
expect(e.errors[0].code).toBe('SEASON_NOT_FOUND')
|
|
17
|
+
}
|
|
18
|
+
})
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const testUtils = require('../testUtils.js')
|
|
2
|
+
|
|
3
|
+
test('delete season', async () => {
|
|
4
|
+
const { client, user } = await testUtils.createTestUserAndClient()
|
|
5
|
+
const chartKey = testUtils.getChartKey()
|
|
6
|
+
await testUtils.createTestChart(chartKey, user.secretKey)
|
|
7
|
+
const season = await client.seasons.create(chartKey)
|
|
8
|
+
|
|
9
|
+
await client.seasons.delete(season.key)
|
|
10
|
+
|
|
11
|
+
try {
|
|
12
|
+
await client.seasons.retrieve(season.key)
|
|
13
|
+
throw new Error('Should have failed')
|
|
14
|
+
} catch (e) {
|
|
15
|
+
expect(e.errors[0].code).toBe('SEASON_NOT_FOUND')
|
|
16
|
+
}
|
|
17
|
+
})
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const testUtils = require('../testUtils.js')
|
|
2
|
+
|
|
3
|
+
test('list all seasons', async () => {
|
|
4
|
+
const { client } = await testUtils.createTestUserAndClient()
|
|
5
|
+
const chart = await client.charts.create()
|
|
6
|
+
const season1 = await client.seasons.create(chart.key)
|
|
7
|
+
const season2 = await client.seasons.create(chart.key)
|
|
8
|
+
const season3 = await client.seasons.create(chart.key)
|
|
9
|
+
|
|
10
|
+
const retrievedSeasonKeys = []
|
|
11
|
+
for await (const season of client.seasons.listAll()) {
|
|
12
|
+
retrievedSeasonKeys.push(season.key)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
expect(retrievedSeasonKeys).toEqual([season3.key, season2.key, season1.key])
|
|
16
|
+
})
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const testUtils = require('../testUtils.js')
|
|
2
|
+
const SeasonParams = require('../../src/Seasons/SeasonParams')
|
|
3
|
+
|
|
4
|
+
test('add events to partial season', async () => {
|
|
5
|
+
const { client } = await testUtils.createTestUserAndClient()
|
|
6
|
+
const chart = await client.charts.create()
|
|
7
|
+
const season = await client.seasons.create(chart.key, new SeasonParams().eventKeys(['event1', 'event2']))
|
|
8
|
+
const partialSeason = await client.seasons.createPartialSeason(season.key, null, ['event1', 'event2'])
|
|
9
|
+
|
|
10
|
+
const updatedPartialSeason = await client.seasons.removeEventFromPartialSeason(season.key, partialSeason.key, 'event2')
|
|
11
|
+
|
|
12
|
+
expect(updatedPartialSeason.events.map(e => e.key)).toEqual(['event1'])
|
|
13
|
+
})
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const testUtils = require('../testUtils.js')
|
|
2
|
+
const TableBookingConfig = require('../../src/Events/TableBookingConfig')
|
|
3
|
+
|
|
4
|
+
test('retrieve partial season', async () => {
|
|
5
|
+
const { client, user } = await testUtils.createTestUserAndClient()
|
|
6
|
+
const chartKey = testUtils.getChartKey()
|
|
7
|
+
await testUtils.createTestChart(chartKey, user.secretKey)
|
|
8
|
+
const season = await client.seasons.create(chartKey)
|
|
9
|
+
const partialSeason = await client.seasons.createPartialSeason(season.key)
|
|
10
|
+
|
|
11
|
+
const retrievedPartialSeason = await client.seasons.retrievePartialSeason(season.key, partialSeason.key)
|
|
12
|
+
|
|
13
|
+
expect(retrievedPartialSeason.key).toBe(partialSeason.key)
|
|
14
|
+
expect(retrievedPartialSeason.id).toBeTruthy()
|
|
15
|
+
|
|
16
|
+
const seasonEvent = retrievedPartialSeason.seasonEvent
|
|
17
|
+
expect(seasonEvent.id).toBeTruthy()
|
|
18
|
+
expect(seasonEvent.key).toBe(retrievedPartialSeason.key)
|
|
19
|
+
expect(seasonEvent.chartKey).toBe(chartKey)
|
|
20
|
+
expect(seasonEvent.tableBookingConfig).toEqual(TableBookingConfig.inherit())
|
|
21
|
+
expect(seasonEvent.supportsBestAvailable).toBe(true)
|
|
22
|
+
expect(seasonEvent.createdOn).toBeInstanceOf(Date)
|
|
23
|
+
expect(seasonEvent.forSaleConfig).toBeFalsy()
|
|
24
|
+
expect(seasonEvent.updatedOn).toBeFalsy()
|
|
25
|
+
})
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const testUtils = require('../testUtils.js')
|
|
2
|
+
const TableBookingConfig = require('../../src/Events/TableBookingConfig')
|
|
3
|
+
const SeasonParams = require('../../src/Seasons/SeasonParams')
|
|
4
|
+
|
|
5
|
+
test('retrieve season', async () => {
|
|
6
|
+
const { client, user } = await testUtils.createTestUserAndClient()
|
|
7
|
+
const chartKey = testUtils.getChartKey()
|
|
8
|
+
await testUtils.createTestChart(chartKey, user.secretKey)
|
|
9
|
+
const season = await client.seasons.create(chartKey, new SeasonParams().eventKeys(['event1', 'event2']))
|
|
10
|
+
const partialSeason1 = await client.seasons.createPartialSeason(season.key)
|
|
11
|
+
const partialSeason2 = await client.seasons.createPartialSeason(season.key)
|
|
12
|
+
|
|
13
|
+
const retrievedSeason = await client.seasons.retrieve(season.key)
|
|
14
|
+
|
|
15
|
+
expect(retrievedSeason.key).toBeTruthy()
|
|
16
|
+
expect(retrievedSeason.id).toBeTruthy()
|
|
17
|
+
expect(retrievedSeason.partialSeasonKeys).toEqual([partialSeason1.key, partialSeason2.key])
|
|
18
|
+
expect(retrievedSeason.events.map(e => e.key)).toEqual(['event1', 'event2'])
|
|
19
|
+
|
|
20
|
+
const seasonEvent = retrievedSeason.seasonEvent
|
|
21
|
+
expect(seasonEvent.id).toBeTruthy()
|
|
22
|
+
expect(seasonEvent.key).toBe(retrievedSeason.key)
|
|
23
|
+
expect(seasonEvent.chartKey).toBe(chartKey)
|
|
24
|
+
expect(seasonEvent.tableBookingConfig).toEqual(TableBookingConfig.inherit())
|
|
25
|
+
expect(seasonEvent.supportsBestAvailable).toBe(true)
|
|
26
|
+
expect(seasonEvent.createdOn).toBeInstanceOf(Date)
|
|
27
|
+
expect(seasonEvent.forSaleConfig).toBeFalsy()
|
|
28
|
+
expect(seasonEvent.updatedOn).toBeFalsy()
|
|
29
|
+
})
|