seatsio 65.2.0 → 67.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "seatsio",
3
- "version": "65.2.0",
3
+ "version": "67.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.24.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.3",
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.5",
34
- "jest-cli": "27.4.5",
33
+ "jest": "27.4.7",
34
+ "jest-cli": "27.4.7",
35
35
  "uuid": "8.3.2"
36
36
  }
37
37
  }
@@ -1,15 +1,16 @@
1
1
  const Page = require('./Page.js')
2
2
  const StatusChange = require('./Events/StatusChange.js')
3
3
  const Chart = require('./Charts/Chart.js')
4
- const Event = require('./Events/Event.js')
5
4
  const User = require('./Users/User.js')
6
5
  const Subaccount = require('./Subaccounts/Subaccount.js')
7
6
  const Workspace = require('./Workspaces/Workspace.js')
7
+ const Season = require('./Seasons/Season')
8
+ const EventDeserializer = require('./Events/EventDeserializer')
8
9
 
9
10
  class AsyncIterator {
10
11
  /**
11
12
  * @param {string} url
12
- * @param {SeatsioClient} client
13
+ * @param {Axios} client
13
14
  * @param {string} objType
14
15
  * @param {object} params
15
16
  */
@@ -38,13 +39,23 @@ class AsyncIterator {
38
39
  events (data) {
39
40
  const events = []
40
41
  data.items.forEach(eventData => {
41
- const event = new Event(eventData)
42
+ const event = new EventDeserializer().fromJson(eventData)
42
43
  this.items.push(event)
43
44
  events.push(event)
44
45
  })
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
@@ -1,6 +1,6 @@
1
- const Event = require('../Events/Event.js')
2
1
  const ChartValidation = require('./ChartValidation')
3
2
  const SocialDistancingRuleset = require('./SocialDistancingRuleset')
3
+ const EventDeserializer = require('../Events/EventDeserializer')
4
4
 
5
5
  class Chart {
6
6
  /**
@@ -14,7 +14,7 @@ class Chart {
14
14
  this.tags = chart.tags
15
15
  this.publishedVersionThumbnailUrl = chart.publishedVersionThumbnailUrl
16
16
  this.draftVersionThumbnailUrl = chart.draftVersionThumbnailUrl || null
17
- this.events = chart.events ? chart.events.map(event => new Event(event)) : []
17
+ this.events = chart.events ? chart.events.map(event => new EventDeserializer().fromJson(event)) : []
18
18
  this.archived = chart.archived
19
19
  if (chart.validation) this.validation = new ChartValidation(chart.validation)
20
20
  this.socialDistancingRulesets = Chart.socialDistancingRulesetsFromJson(chart.socialDistancingRulesets)
@@ -4,7 +4,7 @@ const Chart = require('./Chart.js')
4
4
 
5
5
  class Charts {
6
6
  /**
7
- * @param {SeatsioClient} client
7
+ * @param {Axios} client
8
8
  */
9
9
  constructor (client) {
10
10
  this.client = client
@@ -17,6 +17,10 @@ class Event {
17
17
  this.channels = event.channels ? event.channels.map(c => new Channel(c)) : null
18
18
  this.socialDistancingRulesetKey = event.socialDistancingRulesetKey
19
19
  }
20
+
21
+ isSeason () {
22
+ return false
23
+ }
20
24
  }
21
25
 
22
26
  module.exports = Event
@@ -0,0 +1,13 @@
1
+ const Season = require('../Seasons/Season')
2
+ const Event = require('./Event.js')
3
+
4
+ class EventDeserializer {
5
+ fromJson (event) {
6
+ if (event.isSeason) {
7
+ return new Season(event)
8
+ }
9
+ return new Event(event)
10
+ }
11
+ }
12
+
13
+ module.exports = EventDeserializer
@@ -4,11 +4,11 @@ const EventObjectInfo = require('./EventObjectInfo.js')
4
4
  const StatusChange = require('./StatusChange.js')
5
5
  const BestAvailableObjects = require('./BestAvailableObjects.js')
6
6
  const ChangeObjectStatusResult = require('./ChangeObjectStatusResult.js')
7
- const Event = require('./Event.js')
7
+ const EventDeserializer = require('./EventDeserializer')
8
8
 
9
9
  class Events {
10
10
  /**
11
- * @param {SeatsioClient} client
11
+ * @param {Axios} client
12
12
  */
13
13
  constructor (client) {
14
14
  this.client = client
@@ -40,7 +40,7 @@ class Events {
40
40
  }
41
41
 
42
42
  return this.client.post('/events', requestParameters)
43
- .then((res) => new Event(res.data))
43
+ .then((res) => new EventDeserializer().fromJson(res.data))
44
44
  }
45
45
 
46
46
  /**
@@ -49,7 +49,7 @@ class Events {
49
49
  */
50
50
  retrieve (eventKey) {
51
51
  return this.client.get(`/events/${encodeURIComponent(eventKey)}`)
52
- .then((res) => new Event(res.data))
52
+ .then((res) => new EventDeserializer().fromJson(res.data))
53
53
  }
54
54
 
55
55
  updateChannels (eventKey, channels) {
@@ -137,7 +137,7 @@ class Events {
137
137
  */
138
138
  iterator () {
139
139
  return new Lister('/events', this.client, 'events', (data) => {
140
- const events = data.items.map(eventData => new Event(eventData))
140
+ const events = data.items.map(eventData => new EventDeserializer().fromJson(eventData))
141
141
  return new Page(events, data.next_page_starts_after, data.previous_page_ends_before)
142
142
  })
143
143
  }
@@ -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
 
@@ -2,7 +2,7 @@ const Invitation = require('./Invitation.js')
2
2
 
3
3
  class Invitations {
4
4
  /**
5
- * @param {SeatsioClient} client
5
+ * @param {Axios} client
6
6
  */
7
7
  constructor (client) {
8
8
  this.client = client
@@ -25,11 +25,11 @@ class ChartReports {
25
25
 
26
26
  /**
27
27
  * @param {string} chartKey
28
+ * @param {string} bookWholeTables
28
29
  * @returns {Object} JSON response from the server
29
30
  */
30
- summaryByObjectType (chartKey) {
31
- return this.client.get(ChartReports.summaryReportUrl('byObjectType', chartKey))
32
- .then((res) => res.data)
31
+ summaryByObjectType (chartKey, bookWholeTables = undefined) {
32
+ return this.fetchSummaryReport('byObjectType', chartKey, bookWholeTables)
33
33
  }
34
34
 
35
35
  /**
@@ -43,11 +43,11 @@ class ChartReports {
43
43
 
44
44
  /**
45
45
  * @param {string} chartKey
46
+ * @param {string} bookWholeTables
46
47
  * @returns {Object} JSON response from the server
47
48
  */
48
- summaryByCategoryLabel (chartKey) {
49
- return this.client.get(ChartReports.summaryReportUrl('byCategoryLabel', chartKey))
50
- .then((res) => res.data)
49
+ summaryByCategoryLabel (chartKey, bookWholeTables = undefined) {
50
+ return this.fetchSummaryReport('byCategoryLabel', chartKey, bookWholeTables)
51
51
  }
52
52
 
53
53
  /**
@@ -61,11 +61,11 @@ class ChartReports {
61
61
 
62
62
  /**
63
63
  * @param {string} chartKey
64
+ * @param {string} bookWholeTables
64
65
  * @returns {Object} JSON response from the server
65
66
  */
66
- summaryByCategoryKey (chartKey) {
67
- return this.client.get(ChartReports.summaryReportUrl('byCategoryKey', chartKey))
68
- .then((res) => res.data)
67
+ summaryByCategoryKey (chartKey, bookWholeTables = undefined) {
68
+ return this.fetchSummaryReport('byCategoryKey', chartKey, bookWholeTables)
69
69
  }
70
70
 
71
71
  /**
@@ -79,20 +79,21 @@ class ChartReports {
79
79
 
80
80
  /**
81
81
  * @param {string} chartKey
82
+ * @param {string} bookWholeTables
82
83
  * @returns {Object} JSON response from the server
83
84
  */
84
- summaryBySection (chartKey) {
85
- return this.client.get(ChartReports.summaryReportUrl('bySection', chartKey))
86
- .then((res) => res.data)
85
+ summaryBySection (chartKey, bookWholeTables = undefined) {
86
+ return this.fetchSummaryReport('bySection', chartKey, bookWholeTables)
87
87
  }
88
88
 
89
- fetchReport (reportType, eventKey, bookWholeTables) {
90
- return this.client.get(`/reports/charts/${encodeURIComponent(eventKey)}/${reportType}`, { params: { bookWholeTables } })
89
+ fetchReport (reportType, chartKey, bookWholeTables) {
90
+ return this.client.get(`/reports/charts/${encodeURIComponent(chartKey)}/${reportType}`, { params: { bookWholeTables } })
91
91
  .then((res) => utilities.createChartReport(res.data))
92
92
  }
93
93
 
94
- static summaryReportUrl (reportType, eventKey) {
95
- return `/reports/charts/${encodeURIComponent(eventKey)}/${reportType}/summary`
94
+ fetchSummaryReport (reportType, chartKey, bookWholeTables) {
95
+ return this.client.get(`/reports/charts/${encodeURIComponent(chartKey)}/${reportType}/summary`, { params: { bookWholeTables } })
96
+ .then((res) => res.data)
96
97
  }
97
98
  }
98
99
 
@@ -0,0 +1,18 @@
1
+ const Event = require('../Events/Event.js')
2
+
3
+ class Season extends Event {
4
+ /**
5
+ * @param {object} season
6
+ */
7
+ constructor (season) {
8
+ super(season)
9
+ this.partialSeasonKeys = season.partialSeasonKeys
10
+ this.events = season.events ? season.events.map(e => new Event(e)) : undefined
11
+ }
12
+
13
+ isSeason () {
14
+ return true
15
+ }
16
+ }
17
+
18
+ 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,122 @@
1
+ const Season = require('./Season')
2
+
3
+ class Seasons {
4
+ /**
5
+ * @param {Axios} client
6
+ * @param {SeatsioClient} seatsioClient
7
+ */
8
+ constructor (client, seatsioClient) {
9
+ this.client = client
10
+ this.seatsioClient = seatsioClient
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
+ * @param {?number} numberOfEvents
72
+ * @param {?string[]} eventKeys
73
+ * @returns {Promise<Season>}
74
+ */
75
+ createEvents (key, numberOfEvents = null, eventKeys = null) {
76
+ const requestParameters = { }
77
+
78
+ if (numberOfEvents !== null) {
79
+ requestParameters.numberOfEvents = numberOfEvents
80
+ }
81
+
82
+ if (eventKeys !== null) {
83
+ requestParameters.eventKeys = eventKeys
84
+ }
85
+
86
+ return this.client.post(`/seasons/${encodeURIComponent(key)}/actions/create-events`, requestParameters)
87
+ .then((res) => new Season(res.data))
88
+ }
89
+
90
+ /**
91
+ * @param {string} topLevelSeasonKey
92
+ * @param {string} partialSeasonKey
93
+ * @param {string[]} eventKeys
94
+ * @returns {Promise<Season>}
95
+ */
96
+ addEventsToPartialSeason (topLevelSeasonKey, partialSeasonKey, eventKeys) {
97
+ const requestParameters = { eventKeys }
98
+ return this.client.post(`/seasons/${encodeURIComponent(topLevelSeasonKey)}/partial-seasons/${encodeURIComponent(partialSeasonKey)}/actions/add-events`, requestParameters)
99
+ .then((res) => new Season(res.data))
100
+ }
101
+
102
+ /**
103
+ * @param {string} topLevelSeasonKey
104
+ * @param {string} partialSeasonKey
105
+ * @param {string} eventKey
106
+ * @returns {Promise<Season>}
107
+ */
108
+ async removeEventFromPartialSeason (topLevelSeasonKey, partialSeasonKey, eventKey) {
109
+ return this.client.delete(`/seasons/${encodeURIComponent(topLevelSeasonKey)}/partial-seasons/${encodeURIComponent(partialSeasonKey)}/events/${encodeURIComponent(eventKey)}`)
110
+ .then((res) => new Season(res.data))
111
+ }
112
+
113
+ /**
114
+ * @param {string} key
115
+ * @returns {Promise<Season>}
116
+ */
117
+ retrieve (key) {
118
+ return this.seatsioClient.events.retrieve(key)
119
+ }
120
+ }
121
+
122
+ module.exports = Seasons
@@ -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 = {}) {
@@ -22,7 +23,7 @@ class SeatsioClient {
22
23
  this.errInterceptor = this.client.interceptors.response.use(response => response, errorResponseHandler)
23
24
 
24
25
  this.charts = new Charts(this.client)
25
- this.events = new Events(this.client)
26
+ this.events = new Events(this.client, this)
26
27
  this.subaccounts = new Subaccounts(this.client)
27
28
  this.workspaces = new Workspaces(this.client)
28
29
  this.users = new Users(this.client)
@@ -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, this)
35
37
  }
36
38
 
37
39
  _axiosConfig (baseUrl, secretKey, workspaceKey, extraHeaders) {
@@ -5,7 +5,7 @@ const Chart = require('../Charts/Chart.js')
5
5
 
6
6
  class Subaccounts {
7
7
  /**
8
- * @param {SeatsioClient} client
8
+ * @param {Axios} client
9
9
  */
10
10
  constructor (client) {
11
11
  this.client = client
@@ -4,7 +4,7 @@ const User = require('./User.js')
4
4
 
5
5
  class Users {
6
6
  /**
7
- * @param {SeatsioClient} client
7
+ * @param {Axios} client
8
8
  */
9
9
  constructor (client) {
10
10
  this.client = client
@@ -4,7 +4,7 @@ const Workspace = require('./Workspace.js')
4
4
 
5
5
  class Workspaces {
6
6
  /**
7
- * @param {SeatsioClient} client
7
+ * @param {Axios} client
8
8
  */
9
9
  constructor (client) {
10
10
  this.client = client
@@ -35,6 +35,41 @@ test('summaryByObjectType', async () => {
35
35
  })
36
36
  })
37
37
 
38
+ test('summaryByObjectType_bookWholeTablesTrue', async () => {
39
+ const { client, user } = await testUtils.createTestUserAndClient()
40
+ const chartKey = testUtils.getChartKey()
41
+ await testUtils.createTestChartWithTables(chartKey, user.secretKey)
42
+
43
+ const report = await client.chartReports.summaryByObjectType(chartKey, 'true')
44
+
45
+ expect(report).toEqual({
46
+ seat: {
47
+ count: 0,
48
+ bySection: {},
49
+ byCategoryKey: {},
50
+ byCategoryLabel: {}
51
+ },
52
+ generalAdmission: {
53
+ count: 0,
54
+ bySection: {},
55
+ byCategoryKey: {},
56
+ byCategoryLabel: {}
57
+ },
58
+ table: {
59
+ count: 2,
60
+ bySection: { NO_SECTION: 2 },
61
+ byCategoryKey: { 9: 2 },
62
+ byCategoryLabel: { Cat1: 2 }
63
+ },
64
+ booth: {
65
+ count: 0,
66
+ bySection: {},
67
+ byCategoryKey: {},
68
+ byCategoryLabel: {}
69
+ }
70
+ })
71
+ })
72
+
38
73
  test('summaryByCategoryKey', async () => {
39
74
  const { client, user } = await testUtils.createTestUserAndClient()
40
75
  const chartKey = testUtils.getChartKey()
@@ -1,7 +1,7 @@
1
1
  const testUtils = require('../testUtils.js')
2
2
 
3
3
  test('listAll events when there are more than 10 events)', async () => {
4
- const { client, user } = await testUtils.createTestUserAndClient()
4
+ const { client } = await testUtils.createTestUserAndClient()
5
5
  const chart = await client.charts.create()
6
6
 
7
7
  const events = await testUtils.createArray(15, () => client.events.create(chart.key))
@@ -13,3 +13,18 @@ test('listAll events when there are more than 10 events)', async () => {
13
13
 
14
14
  expect(retrievedEventKeys.sort()).toEqual(events.map(e => e.key).sort())
15
15
  })
16
+
17
+ test('list seasons', async () => {
18
+ const { client } = await testUtils.createTestUserAndClient()
19
+ const chart = await client.charts.create()
20
+ await client.seasons.create(chart.key)
21
+ await client.seasons.create(chart.key)
22
+ await client.seasons.create(chart.key)
23
+
24
+ const areSeasons = []
25
+ for await (const season of client.events.listAll()) {
26
+ areSeasons.push(season.isSeason())
27
+ }
28
+
29
+ expect(areSeasons).toEqual([true, true, true])
30
+ })
@@ -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 () => {
@@ -1,5 +1,6 @@
1
1
  const testUtils = require('../testUtils.js')
2
2
  const TableBookingConfig = require('../../src/Events/TableBookingConfig')
3
+ const SeasonParams = require("../../src/Seasons/SeasonParams");
3
4
 
4
5
  test('should retrieve event', async () => {
5
6
  const { client, user } = await testUtils.createTestUserAndClient()
@@ -20,3 +21,25 @@ test('should retrieve event', async () => {
20
21
  expect(retrievedEvent.forSaleConfig).toBeFalsy()
21
22
  expect(retrievedEvent.updatedOn).toBeNull()
22
23
  })
24
+
25
+ test('retrieve season', async () => {
26
+ const { client, user } = await testUtils.createTestUserAndClient()
27
+ const chartKey = testUtils.getChartKey()
28
+ await testUtils.createTestChart(chartKey, user.secretKey)
29
+ const season = await client.seasons.create(chartKey, new SeasonParams().eventKeys(['event1', 'event2']))
30
+ const partialSeason1 = await client.seasons.createPartialSeason(season.key)
31
+ const partialSeason2 = await client.seasons.createPartialSeason(season.key)
32
+
33
+ const retrievedSeason = await client.events.retrieve(season.key)
34
+
35
+ expect(retrievedSeason.key).toBeTruthy()
36
+ expect(retrievedSeason.id).toBeTruthy()
37
+ expect(retrievedSeason.partialSeasonKeys).toEqual([partialSeason1.key, partialSeason2.key])
38
+ expect(retrievedSeason.events.map(e => e.key)).toEqual(['event1', 'event2'])
39
+ expect(retrievedSeason.chartKey).toBe(chartKey)
40
+ expect(retrievedSeason.tableBookingConfig).toEqual(TableBookingConfig.inherit())
41
+ expect(retrievedSeason.supportsBestAvailable).toBe(true)
42
+ expect(retrievedSeason.createdOn).toBeInstanceOf(Date)
43
+ expect(retrievedSeason.forSaleConfig).toBeFalsy()
44
+ expect(retrievedSeason.updatedOn).toBeFalsy()
45
+ })
@@ -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,72 @@
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.partialSeasonKeys.length).toBe(0)
14
+ expect(season.events.length).toBe(0)
15
+ expect(season.id).toBeTruthy()
16
+ expect(season.key).toBe(season.key)
17
+ expect(season.chartKey).toBe(chartKey)
18
+ expect(season.tableBookingConfig).toEqual(TableBookingConfig.inherit())
19
+ expect(season.supportsBestAvailable).toBe(true)
20
+ expect(season.createdOn).toBeInstanceOf(Date)
21
+ expect(season.forSaleConfig).toBeFalsy()
22
+ expect(season.updatedOn).toBeFalsy()
23
+ })
24
+
25
+ test('key can be passed in', async () => {
26
+ const { client } = await testUtils.createTestUserAndClient()
27
+ const chart = await client.charts.create()
28
+
29
+ const season = await client.seasons.create(chart.key, new SeasonParams().key('aSeason'))
30
+
31
+ expect(season.key).toBe('aSeason')
32
+ })
33
+
34
+ test('number of events can be passed in', async () => {
35
+ const { client } = await testUtils.createTestUserAndClient()
36
+ const chart = await client.charts.create()
37
+
38
+ const season = await client.seasons.create(chart.key, new SeasonParams().numberOfEvents(2))
39
+
40
+ expect(season.events.length).toBe(2)
41
+ })
42
+
43
+ test('event keys can be passed in', async () => {
44
+ const { client } = await testUtils.createTestUserAndClient()
45
+ const chart = await client.charts.create()
46
+
47
+ const season = await client.seasons.create(chart.key, new SeasonParams().eventKeys(['event1', 'event2']))
48
+
49
+ expect(season.events.map(event => event.key)).toEqual(['event1', 'event2'])
50
+ })
51
+
52
+ test('table booking config can be passed in', async () => {
53
+ const { client, user } = await testUtils.createTestUserAndClient()
54
+ const chartKey = testUtils.getChartKey()
55
+ await testUtils.createTestChartWithTables(chartKey, user.secretKey)
56
+ const tableBookingConfig = TableBookingConfig.custom({ T1: 'BY_TABLE', T2: 'BY_SEAT' })
57
+
58
+ const season = await client.seasons.create(chartKey, new SeasonParams().tableBookingConfig(tableBookingConfig))
59
+
60
+ expect(season.tableBookingConfig).toEqual(tableBookingConfig)
61
+ })
62
+
63
+ test('social distancing ruleset key can be passed in', async () => {
64
+ const { client } = await testUtils.createTestUserAndClient()
65
+ const chart = await client.charts.create()
66
+ const rulesets = { ruleset1: SocialDistancingRuleset.ruleBased('My ruleset').build() }
67
+ await client.charts.saveSocialDistancingRulesets(chart.key, rulesets)
68
+
69
+ const season = await client.seasons.create(chart.key, new SeasonParams().socialDistancingRulesetKey('ruleset1'))
70
+
71
+ expect(season.socialDistancingRulesetKey).toBe('ruleset1')
72
+ })
@@ -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
+ 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
+ expect(retrievedSeason.chartKey).toBe(chartKey)
20
+ expect(retrievedSeason.tableBookingConfig).toEqual(TableBookingConfig.inherit())
21
+ expect(retrievedSeason.supportsBestAvailable).toBe(true)
22
+ expect(retrievedSeason.createdOn).toBeInstanceOf(Date)
23
+ expect(retrievedSeason.forSaleConfig).toBeFalsy()
24
+ expect(retrievedSeason.updatedOn).toBeFalsy()
25
+ })