seatsio 64.0.0 → 65.3.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/README.md +61 -6
- package/package.json +6 -6
- package/src/Charts/ChartListParams.js +14 -2
- package/src/Events/EventObjectInfo.js +2 -1
- package/src/Events/Events.js +24 -5
- package/src/Events/StatusChangeRequest.js +5 -1
- package/src/Reports/ChartReports.js +55 -5
- package/src/Reports/EventReports.js +35 -7
- package/src/errorInterceptor.js +1 -2
- package/tests/chartReports/chartReport.test.js +11 -0
- package/tests/chartReports/chartReportSummary.test.js +155 -0
- package/tests/charts/listAllCharts.test.js +26 -8
- package/tests/eventReports/eventReport.test.js +38 -8
- package/tests/eventReports/eventReportDeepSummary.test.js +19 -5
- package/tests/eventReports/eventReportSummary.test.js +117 -10
- package/tests/events/changeObjectStatus.test.js +32 -1
- package/tests/events/changeObjectStatusInBatch.test.js +34 -0
- package/tests/exponentialBackoff.test.js +3 -3
package/README.md
CHANGED
|
@@ -38,10 +38,31 @@ seatsio-js follows semver since v54.4.0.
|
|
|
38
38
|
|
|
39
39
|
Please note that any version below v2 is not production ready.
|
|
40
40
|
|
|
41
|
-
##
|
|
41
|
+
## Usage
|
|
42
|
+
|
|
43
|
+
### General instructions
|
|
44
|
+
|
|
45
|
+
To use this library, you'll need to create a `SeatsioClient`:
|
|
46
|
+
|
|
47
|
+
```js
|
|
48
|
+
import { SeatsioClient, Region } from 'seatsio'
|
|
49
|
+
|
|
50
|
+
let client = new SeatsioClient(Region.EU(), <WORKSPACE SECRET KEY>)
|
|
51
|
+
...
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
You can find your _workspace secret key_ in the [settings section of the workspace](https://app.seats.io/workspace-settings). It is important that you keep your _secret key_ private and not expose it in-browser calls unless it is password protected.
|
|
55
|
+
|
|
56
|
+
The region should correspond to the region of your account:
|
|
57
|
+
|
|
58
|
+
- `Region.EU()`: Europe
|
|
59
|
+
- `Region.NA()`: North-America
|
|
60
|
+
- `Region.SA()`: South-America
|
|
61
|
+
- `Region.OC()`: Oceania
|
|
62
|
+
|
|
63
|
+
If you're unsure about your region, have a look at your [company settings page](https://app.seats.io/company-settings).
|
|
42
64
|
|
|
43
65
|
### Creating a chart and an event
|
|
44
|
-
Once you create a new `SeatsioClient` using your _secret key_, you can create _charts_ and then _events_. You can find your _secret key_ in the Settings section of your workspace: https://app.seats.io/workspace-settings. It is important that you keep your _secret key_ private and not expose it in-browser calls unless it is password protected.
|
|
45
66
|
|
|
46
67
|
```js
|
|
47
68
|
import { SeatsioClient, Region } from 'seatsio'
|
|
@@ -154,6 +175,23 @@ A combination of filter, sorting order and sorting option is also possible.
|
|
|
154
175
|
let parameter = new StatusChangesParams().withFilter('testFilter').sortByStatus().sortAscending()
|
|
155
176
|
```
|
|
156
177
|
|
|
178
|
+
### Retrieving object category and status (and other information)
|
|
179
|
+
|
|
180
|
+
```js
|
|
181
|
+
import { SeatsioClient, Region } from 'seatsio'
|
|
182
|
+
|
|
183
|
+
let client = new SeatsioClient(Region.EU(), <WORKSPACE SECRET KEY>)
|
|
184
|
+
let objectInfos = await client.events.retrieveObjectInfos(event.key, ['A-1', 'A-2'])
|
|
185
|
+
|
|
186
|
+
console.log(objectInfos['A-1'].categoryKey)
|
|
187
|
+
console.log(objectInfos['A-1'].categoryLabel)
|
|
188
|
+
console.log(objectInfos['A-1'].status)
|
|
189
|
+
|
|
190
|
+
console.log(objectInfos['A-2'].categoryKey)
|
|
191
|
+
console.log(objectInfos['A-2'].categoryLabel)
|
|
192
|
+
console.log(objectInfos['A-2'].status)
|
|
193
|
+
```
|
|
194
|
+
|
|
157
195
|
### Event reports
|
|
158
196
|
|
|
159
197
|
Want to know which seats of an event are booked, and which ones are free? That’s where reporting comes in handy.
|
|
@@ -224,12 +262,29 @@ let client = new SeatsioClient(Region.EU(), <COMPANY ADMIN KEY>)
|
|
|
224
262
|
await client.workspaces.create('a workspace');
|
|
225
263
|
```
|
|
226
264
|
|
|
265
|
+
### Creating a chart and an event with the company admin key
|
|
266
|
+
|
|
267
|
+
```js
|
|
268
|
+
import { SeatsioClient, Region } from 'seatsio'
|
|
269
|
+
|
|
270
|
+
let client = new SeatsioClient(Region.EU(), <COMPANY ADMIN KEY>, <WORKSPACE PUBLIC KEY>)
|
|
271
|
+
let chart = await client.charts.create()
|
|
272
|
+
let event = await client.events.create(chart.key)
|
|
273
|
+
console.log(`Created a chart with key ${chart.key} and an event with key: ${event.key}`)
|
|
274
|
+
```
|
|
275
|
+
|
|
227
276
|
## Error Handling
|
|
228
|
-
When an API call results in an error, a rejected promise is returned with
|
|
277
|
+
When an API call results in an error, a rejected promise is returned with a value that looks like
|
|
278
|
+
|
|
279
|
+
```json
|
|
280
|
+
{
|
|
281
|
+
"errors": [{ "code": "RATE_LIMIT_EXCEEDED", "message": "Rate limit exceeded" }],
|
|
282
|
+
"messages": ["Rate limit exceeded"],
|
|
283
|
+
"requestId": "123456",
|
|
284
|
+
"status": 429
|
|
285
|
+
}
|
|
286
|
+
```
|
|
229
287
|
|
|
230
|
-
- `messages`: an array of error messages that the server returned. In most cases, this array will contain only one element.
|
|
231
|
-
- `requestId`: the identifier of the request you made. Please mention this to us when you have questions, as it will make debugging easier.
|
|
232
|
-
-
|
|
233
288
|
## Rate limiting - exponential backoff
|
|
234
289
|
|
|
235
290
|
This library supports [exponential backoff](https://en.wikipedia.org/wiki/Exponential_backoff).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "seatsio",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "65.3.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,15 +14,15 @@
|
|
|
14
14
|
"url": "https://github.com/seatsio/seatsio-js"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"axios": "0.
|
|
17
|
+
"axios": "0.24.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.
|
|
23
|
+
"eslint-plugin-import": "2.25.3",
|
|
24
24
|
"eslint-plugin-node": "11.1.0",
|
|
25
|
-
"eslint-plugin-promise": "
|
|
25
|
+
"eslint-plugin-promise": "6.0.0",
|
|
26
26
|
"eslint-plugin-standard": "5.0.0",
|
|
27
27
|
"gulp": "latest",
|
|
28
28
|
"gulp-buffer": "latest",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"gulp-tap": "latest",
|
|
31
31
|
"gulp-uglify": "latest",
|
|
32
32
|
"gulp-uglify-es": "latest",
|
|
33
|
-
"jest": "27.
|
|
34
|
-
"jest-cli": "27.
|
|
33
|
+
"jest": "27.4.5",
|
|
34
|
+
"jest-cli": "27.4.5",
|
|
35
35
|
"uuid": "8.3.2"
|
|
36
36
|
}
|
|
37
37
|
}
|
|
@@ -4,11 +4,13 @@ class ChartListParams {
|
|
|
4
4
|
* @param {?string} tag
|
|
5
5
|
* @param {?boolean} expandEvents
|
|
6
6
|
* @param {?boolean} withValidation
|
|
7
|
+
* @param {?number} eventsLimit
|
|
7
8
|
*/
|
|
8
|
-
constructor (filter = null, tag = null, expandEvents = null, withValidation = false) {
|
|
9
|
+
constructor (filter = null, tag = null, expandEvents = null, withValidation = false, eventsLimit = null) {
|
|
9
10
|
this.filter = filter
|
|
10
11
|
this.tag = tag
|
|
11
12
|
this.validation = withValidation
|
|
13
|
+
this.eventsLimit = eventsLimit
|
|
12
14
|
if (expandEvents === true) {
|
|
13
15
|
this.expand = 'events'
|
|
14
16
|
}
|
|
@@ -43,6 +45,15 @@ class ChartListParams {
|
|
|
43
45
|
return this
|
|
44
46
|
}
|
|
45
47
|
|
|
48
|
+
/**
|
|
49
|
+
* @param {number} eventsLimit
|
|
50
|
+
* @returns {ChartListParams}
|
|
51
|
+
*/
|
|
52
|
+
withEventsLimit (eventsLimit) {
|
|
53
|
+
this.eventsLimit = eventsLimit
|
|
54
|
+
return this
|
|
55
|
+
}
|
|
56
|
+
|
|
46
57
|
/**
|
|
47
58
|
*
|
|
48
59
|
* @param {boolean} validation
|
|
@@ -58,7 +69,8 @@ class ChartListParams {
|
|
|
58
69
|
tag: this.tag,
|
|
59
70
|
expand: this.expand,
|
|
60
71
|
filter: this.filter,
|
|
61
|
-
validation: this.validation
|
|
72
|
+
validation: this.validation,
|
|
73
|
+
eventsLimit: this.eventsLimit
|
|
62
74
|
}
|
|
63
75
|
}
|
|
64
76
|
}
|
|
@@ -31,7 +31,8 @@ class EventObjectInfo {
|
|
|
31
31
|
this.displayedObjectType = report.displayedObjectType
|
|
32
32
|
this.leftNeighbour = report.leftNeighbour
|
|
33
33
|
this.rightNeighbour = report.rightNeighbour
|
|
34
|
-
this.
|
|
34
|
+
this.isAvailable = report.isAvailable
|
|
35
|
+
this.availabilityReason = report.availabilityReason
|
|
35
36
|
this.isDisabledBySocialDistancing = report.isDisabledBySocialDistancing
|
|
36
37
|
this.channel = report.channel
|
|
37
38
|
this.distanceToFocalPoint = report.distanceToFocalPoint
|
package/src/Events/Events.js
CHANGED
|
@@ -272,12 +272,14 @@ class Events {
|
|
|
272
272
|
* @param {?string[]} channelKeys
|
|
273
273
|
* @param {?boolean} ignoreSocialDistancing
|
|
274
274
|
* @returns {Promise<ChangeObjectStatusResult>}
|
|
275
|
+
* @param {?string[]} allowedPreviousStatuses
|
|
276
|
+
* @param {?string[]} rejectedPreviousStatuses
|
|
275
277
|
*/
|
|
276
|
-
changeObjectStatus (eventKeyOrKeys, objectOrObjects, status, holdToken = null, orderId = null, keepExtraData = null, ignoreChannels = null, channelKeys = null, ignoreSocialDistancing = null) {
|
|
277
|
-
const request = this.changeObjectStatusRequest(objectOrObjects, status, holdToken, orderId, keepExtraData, ignoreChannels, channelKeys, ignoreSocialDistancing)
|
|
278
|
+
changeObjectStatus (eventKeyOrKeys, objectOrObjects, status, holdToken = null, orderId = null, keepExtraData = null, ignoreChannels = null, channelKeys = null, ignoreSocialDistancing = null, allowedPreviousStatuses = null, rejectedPreviousStatuses = null) {
|
|
279
|
+
const request = this.changeObjectStatusRequest(objectOrObjects, status, holdToken, orderId, keepExtraData, ignoreChannels, channelKeys, ignoreSocialDistancing, allowedPreviousStatuses, rejectedPreviousStatuses)
|
|
278
280
|
request.events = Array.isArray(eventKeyOrKeys) ? eventKeyOrKeys : [eventKeyOrKeys]
|
|
279
281
|
|
|
280
|
-
return this.client.post('/
|
|
282
|
+
return this.client.post('/events/groups/actions/change-object-status?expand=objects', request)
|
|
281
283
|
.then((res) => new ChangeObjectStatusResult(res.data.objects))
|
|
282
284
|
}
|
|
283
285
|
|
|
@@ -287,7 +289,18 @@ class Events {
|
|
|
287
289
|
*/
|
|
288
290
|
changeObjectStatusInBatch (statusChangeRequests) {
|
|
289
291
|
const requests = statusChangeRequests.map(r => {
|
|
290
|
-
const json = this.changeObjectStatusRequest(
|
|
292
|
+
const json = this.changeObjectStatusRequest(
|
|
293
|
+
r.objectOrObjects,
|
|
294
|
+
r.status,
|
|
295
|
+
r.holdToken,
|
|
296
|
+
r.orderId,
|
|
297
|
+
r.keepExtraData,
|
|
298
|
+
r.ignoreChannels,
|
|
299
|
+
r.channelKeys,
|
|
300
|
+
null,
|
|
301
|
+
r.allowedPreviousStatuses,
|
|
302
|
+
r.rejectedPreviousStatuses
|
|
303
|
+
)
|
|
291
304
|
json.event = r.eventKey
|
|
292
305
|
return json
|
|
293
306
|
})
|
|
@@ -297,7 +310,7 @@ class Events {
|
|
|
297
310
|
.then((res) => res.data.results.map(r => new ChangeObjectStatusResult(r.objects)))
|
|
298
311
|
}
|
|
299
312
|
|
|
300
|
-
changeObjectStatusRequest (objectOrObjects, status, holdToken, orderId, keepExtraData, ignoreChannels, channelKeys, ignoreSocialDistancing) {
|
|
313
|
+
changeObjectStatusRequest (objectOrObjects, status, holdToken, orderId, keepExtraData, ignoreChannels, channelKeys, ignoreSocialDistancing, allowedPreviousStatuses, rejectedPreviousStatuses) {
|
|
301
314
|
const request = {}
|
|
302
315
|
request.objects = this.normalizeObjects(objectOrObjects)
|
|
303
316
|
request.status = status
|
|
@@ -319,6 +332,12 @@ class Events {
|
|
|
319
332
|
if (ignoreSocialDistancing !== null) {
|
|
320
333
|
request.ignoreSocialDistancing = ignoreSocialDistancing
|
|
321
334
|
}
|
|
335
|
+
if (allowedPreviousStatuses !== null) {
|
|
336
|
+
request.allowedPreviousStatuses = allowedPreviousStatuses
|
|
337
|
+
}
|
|
338
|
+
if (rejectedPreviousStatuses !== null) {
|
|
339
|
+
request.rejectedPreviousStatuses = rejectedPreviousStatuses
|
|
340
|
+
}
|
|
322
341
|
return request
|
|
323
342
|
}
|
|
324
343
|
|
|
@@ -8,8 +8,10 @@ class StatusChangeRequest {
|
|
|
8
8
|
* @param {?boolean} keepExtraData
|
|
9
9
|
* @param {?boolean} ignoreChannels
|
|
10
10
|
* @param {?string[]} channelKeys
|
|
11
|
+
* @param {?string[]} allowedPreviousStatuses
|
|
12
|
+
* @param {?string[]} rejectedPreviousStatuses
|
|
11
13
|
*/
|
|
12
|
-
constructor (eventKey, objectOrObjects, status, holdToken, orderId, keepExtraData, ignoreChannels, channelKeys) {
|
|
14
|
+
constructor (eventKey, objectOrObjects, status, holdToken, orderId, keepExtraData, ignoreChannels, channelKeys, allowedPreviousStatuses, rejectedPreviousStatuses) {
|
|
13
15
|
this.eventKey = eventKey
|
|
14
16
|
this.objectOrObjects = objectOrObjects
|
|
15
17
|
this.status = status
|
|
@@ -18,6 +20,8 @@ class StatusChangeRequest {
|
|
|
18
20
|
this.keepExtraData = keepExtraData
|
|
19
21
|
this.ignoreChannels = ignoreChannels
|
|
20
22
|
this.channelKeys = channelKeys
|
|
23
|
+
this.allowedPreviousStatuses = allowedPreviousStatuses
|
|
24
|
+
this.rejectedPreviousStatuses = rejectedPreviousStatuses
|
|
21
25
|
}
|
|
22
26
|
}
|
|
23
27
|
|
|
@@ -5,11 +5,6 @@ class ChartReports {
|
|
|
5
5
|
this.client = client
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
fetchReport (reportType, eventKey, bookWholeTables) {
|
|
9
|
-
return this.client.get(`/reports/charts/${encodeURIComponent(eventKey)}/${reportType}`, { params: { bookWholeTables } })
|
|
10
|
-
.then((res) => utilities.createChartReport(res.data))
|
|
11
|
-
}
|
|
12
|
-
|
|
13
8
|
/**
|
|
14
9
|
* @param {string} chartKey
|
|
15
10
|
* @param {string} bookWholeTables
|
|
@@ -28,6 +23,15 @@ class ChartReports {
|
|
|
28
23
|
return this.fetchReport('byObjectType', chartKey, bookWholeTables)
|
|
29
24
|
}
|
|
30
25
|
|
|
26
|
+
/**
|
|
27
|
+
* @param {string} chartKey
|
|
28
|
+
* @param {string} bookWholeTables
|
|
29
|
+
* @returns {Object} JSON response from the server
|
|
30
|
+
*/
|
|
31
|
+
summaryByObjectType (chartKey, bookWholeTables = undefined) {
|
|
32
|
+
return this.fetchSummaryReport('byObjectType', chartKey, bookWholeTables)
|
|
33
|
+
}
|
|
34
|
+
|
|
31
35
|
/**
|
|
32
36
|
* @param {string} chartKey
|
|
33
37
|
* @param {string} bookWholeTables
|
|
@@ -37,6 +41,15 @@ class ChartReports {
|
|
|
37
41
|
return this.fetchReport('byCategoryLabel', chartKey, bookWholeTables)
|
|
38
42
|
}
|
|
39
43
|
|
|
44
|
+
/**
|
|
45
|
+
* @param {string} chartKey
|
|
46
|
+
* @param {string} bookWholeTables
|
|
47
|
+
* @returns {Object} JSON response from the server
|
|
48
|
+
*/
|
|
49
|
+
summaryByCategoryLabel (chartKey, bookWholeTables = undefined) {
|
|
50
|
+
return this.fetchSummaryReport('byCategoryLabel', chartKey, bookWholeTables)
|
|
51
|
+
}
|
|
52
|
+
|
|
40
53
|
/**
|
|
41
54
|
* @param {string} chartKey
|
|
42
55
|
* @param {string} bookWholeTables
|
|
@@ -45,6 +58,43 @@ class ChartReports {
|
|
|
45
58
|
byCategoryKey (chartKey, bookWholeTables = undefined) {
|
|
46
59
|
return this.fetchReport('byCategoryKey', chartKey, bookWholeTables)
|
|
47
60
|
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* @param {string} chartKey
|
|
64
|
+
* @param {string} bookWholeTables
|
|
65
|
+
* @returns {Object} JSON response from the server
|
|
66
|
+
*/
|
|
67
|
+
summaryByCategoryKey (chartKey, bookWholeTables = undefined) {
|
|
68
|
+
return this.fetchSummaryReport('byCategoryKey', chartKey, bookWholeTables)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @param {string} chartKey
|
|
73
|
+
* @param {string} bookWholeTables
|
|
74
|
+
* @returns {Object.<string, ChartObjectInfo[]>}
|
|
75
|
+
*/
|
|
76
|
+
bySection (chartKey, bookWholeTables = undefined) {
|
|
77
|
+
return this.fetchReport('bySection', chartKey, bookWholeTables)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* @param {string} chartKey
|
|
82
|
+
* @param {string} bookWholeTables
|
|
83
|
+
* @returns {Object} JSON response from the server
|
|
84
|
+
*/
|
|
85
|
+
summaryBySection (chartKey, bookWholeTables = undefined) {
|
|
86
|
+
return this.fetchSummaryReport('bySection', chartKey, bookWholeTables)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
fetchReport (reportType, chartKey, bookWholeTables) {
|
|
90
|
+
return this.client.get(`/reports/charts/${encodeURIComponent(chartKey)}/${reportType}`, { params: { bookWholeTables } })
|
|
91
|
+
.then((res) => utilities.createChartReport(res.data))
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
fetchSummaryReport (reportType, chartKey, bookWholeTables) {
|
|
95
|
+
return this.client.get(`/reports/charts/${encodeURIComponent(chartKey)}/${reportType}/summary`, { params: { bookWholeTables } })
|
|
96
|
+
.then((res) => res.data)
|
|
97
|
+
}
|
|
48
98
|
}
|
|
49
99
|
|
|
50
100
|
module.exports = ChartReports
|
|
@@ -167,20 +167,48 @@ class EventReports {
|
|
|
167
167
|
|
|
168
168
|
/**
|
|
169
169
|
* @param {string} eventKey
|
|
170
|
-
* @param {?string}
|
|
170
|
+
* @param {?string} availability
|
|
171
171
|
* @returns {Object.<string, ObjectInfo[]>}
|
|
172
172
|
*/
|
|
173
|
-
|
|
174
|
-
return this.client.get(EventReports.reportUrl('
|
|
173
|
+
byAvailability (eventKey, availability = null) {
|
|
174
|
+
return this.client.get(EventReports.reportUrl('byAvailability', eventKey, availability))
|
|
175
175
|
.then((res) => utilities.createEventReport(res.data))
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
+
/**
|
|
179
|
+
* @param {string} eventKey
|
|
180
|
+
* @param {?string} availabilityReason
|
|
181
|
+
* @returns {Object.<string, ObjectInfo[]>}
|
|
182
|
+
*/
|
|
183
|
+
byAvailabilityReason (eventKey, availabilityReason = null) {
|
|
184
|
+
return this.client.get(EventReports.reportUrl('byAvailabilityReason', eventKey, availabilityReason))
|
|
185
|
+
.then((res) => utilities.createEventReport(res.data))
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* @param {string} eventKey
|
|
190
|
+
* @returns {Object} JSON response from the server
|
|
191
|
+
*/
|
|
192
|
+
summaryByAvailability (eventKey) {
|
|
193
|
+
return this.client.get(EventReports.summaryReportUrl('byAvailability', eventKey))
|
|
194
|
+
.then((res) => res.data)
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* @param {string} eventKey
|
|
199
|
+
* @returns {Object} JSON response from the server
|
|
200
|
+
*/
|
|
201
|
+
summaryByAvailabilityReason (eventKey) {
|
|
202
|
+
return this.client.get(EventReports.summaryReportUrl('byAvailabilityReason', eventKey))
|
|
203
|
+
.then((res) => res.data)
|
|
204
|
+
}
|
|
205
|
+
|
|
178
206
|
/**
|
|
179
207
|
* @param {string} eventKey
|
|
180
208
|
* @returns {Object} JSON response from the server
|
|
181
209
|
*/
|
|
182
|
-
|
|
183
|
-
return this.client.get(EventReports.
|
|
210
|
+
deepSummaryByAvailability (eventKey) {
|
|
211
|
+
return this.client.get(EventReports.deepSummaryReportUrl('byAvailability', eventKey))
|
|
184
212
|
.then((res) => res.data)
|
|
185
213
|
}
|
|
186
214
|
|
|
@@ -188,8 +216,8 @@ class EventReports {
|
|
|
188
216
|
* @param {string} eventKey
|
|
189
217
|
* @returns {Object} JSON response from the server
|
|
190
218
|
*/
|
|
191
|
-
|
|
192
|
-
return this.client.get(EventReports.deepSummaryReportUrl('
|
|
219
|
+
deepSummaryByAvailabilityReason (eventKey) {
|
|
220
|
+
return this.client.get(EventReports.deepSummaryReportUrl('byAvailabilityReason', eventKey))
|
|
193
221
|
.then((res) => res.data)
|
|
194
222
|
}
|
|
195
223
|
|
package/src/errorInterceptor.js
CHANGED
|
@@ -4,10 +4,9 @@ function errorResponseHandler (error) {
|
|
|
4
4
|
if (typeof error.response.data !== 'undefined' && error.response.data) {
|
|
5
5
|
reject(error.response.data)
|
|
6
6
|
} else if (typeof error.response.statusText !== 'undefined' && error.response.statusText) {
|
|
7
|
-
reject(`${error.config.method} ${error.config.url} resulted in ${error.response.status}
|
|
7
|
+
reject(`${error.config.method} ${error.config.url} resulted in ${error.response.status} ${error.response.statusText} error`) // eslint-disable-line
|
|
8
8
|
}
|
|
9
9
|
} else {
|
|
10
|
-
console.log(error)
|
|
11
10
|
reject(error)
|
|
12
11
|
}
|
|
13
12
|
})
|
|
@@ -119,3 +119,14 @@ test('get report byCategoryLabel', async () => {
|
|
|
119
119
|
expect(report.Cat1.length).toBe(17)
|
|
120
120
|
expect(report.Cat2.length).toBe(17)
|
|
121
121
|
})
|
|
122
|
+
|
|
123
|
+
test('get report bySection', async () => {
|
|
124
|
+
const { client, user } = await testUtils.createTestUserAndClient()
|
|
125
|
+
const chartKey = testUtils.getChartKey()
|
|
126
|
+
await testUtils.createTestChartWithSections(chartKey, user.secretKey)
|
|
127
|
+
|
|
128
|
+
const report = await client.chartReports.bySection(chartKey)
|
|
129
|
+
|
|
130
|
+
expect(report['Section A'].length).toBe(36)
|
|
131
|
+
expect(report['Section B'].length).toBe(35)
|
|
132
|
+
})
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
const testUtils = require('../testUtils.js')
|
|
2
|
+
|
|
3
|
+
test('summaryByObjectType', async () => {
|
|
4
|
+
const { client, user } = await testUtils.createTestUserAndClient()
|
|
5
|
+
const chartKey = testUtils.getChartKey()
|
|
6
|
+
await testUtils.createTestChart(chartKey, user.secretKey)
|
|
7
|
+
|
|
8
|
+
const report = await client.chartReports.summaryByObjectType(chartKey)
|
|
9
|
+
|
|
10
|
+
expect(report).toEqual({
|
|
11
|
+
seat: {
|
|
12
|
+
count: 32,
|
|
13
|
+
bySection: { NO_SECTION: 32 },
|
|
14
|
+
byCategoryKey: { 9: 16, 10: 16 },
|
|
15
|
+
byCategoryLabel: { Cat1: 16, Cat2: 16 }
|
|
16
|
+
},
|
|
17
|
+
generalAdmission: {
|
|
18
|
+
count: 200,
|
|
19
|
+
bySection: { NO_SECTION: 200 },
|
|
20
|
+
byCategoryKey: { 9: 100, 10: 100 },
|
|
21
|
+
byCategoryLabel: { Cat2: 100, Cat1: 100 }
|
|
22
|
+
},
|
|
23
|
+
table: {
|
|
24
|
+
count: 0,
|
|
25
|
+
bySection: {},
|
|
26
|
+
byCategoryKey: {},
|
|
27
|
+
byCategoryLabel: {}
|
|
28
|
+
},
|
|
29
|
+
booth: {
|
|
30
|
+
count: 0,
|
|
31
|
+
bySection: {},
|
|
32
|
+
byCategoryKey: {},
|
|
33
|
+
byCategoryLabel: {}
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
})
|
|
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
|
+
|
|
73
|
+
test('summaryByCategoryKey', async () => {
|
|
74
|
+
const { client, user } = await testUtils.createTestUserAndClient()
|
|
75
|
+
const chartKey = testUtils.getChartKey()
|
|
76
|
+
await testUtils.createTestChart(chartKey, user.secretKey)
|
|
77
|
+
|
|
78
|
+
const report = await client.chartReports.summaryByCategoryKey(chartKey)
|
|
79
|
+
|
|
80
|
+
expect(report).toEqual({
|
|
81
|
+
9: {
|
|
82
|
+
count: 116,
|
|
83
|
+
bySection: { NO_SECTION: 116 },
|
|
84
|
+
byObjectType: {
|
|
85
|
+
generalAdmission: 100,
|
|
86
|
+
seat: 16
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
10: {
|
|
90
|
+
count: 116,
|
|
91
|
+
bySection: { NO_SECTION: 116 },
|
|
92
|
+
byObjectType: {
|
|
93
|
+
generalAdmission: 100,
|
|
94
|
+
seat: 16
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
NO_CATEGORY: {
|
|
98
|
+
count: 0,
|
|
99
|
+
bySection: {},
|
|
100
|
+
byObjectType: {}
|
|
101
|
+
}
|
|
102
|
+
})
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
test('summaryByCategoryLabel', async () => {
|
|
106
|
+
const { client, user } = await testUtils.createTestUserAndClient()
|
|
107
|
+
const chartKey = testUtils.getChartKey()
|
|
108
|
+
await testUtils.createTestChart(chartKey, user.secretKey)
|
|
109
|
+
|
|
110
|
+
const report = await client.chartReports.summaryByCategoryLabel(chartKey)
|
|
111
|
+
|
|
112
|
+
expect(report).toEqual({
|
|
113
|
+
Cat2: {
|
|
114
|
+
count: 116,
|
|
115
|
+
bySection: { NO_SECTION: 116 },
|
|
116
|
+
byObjectType: {
|
|
117
|
+
generalAdmission: 100,
|
|
118
|
+
seat: 16
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
Cat1: {
|
|
122
|
+
count: 116,
|
|
123
|
+
bySection: { NO_SECTION: 116 },
|
|
124
|
+
byObjectType: {
|
|
125
|
+
generalAdmission: 100,
|
|
126
|
+
seat: 16
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
NO_CATEGORY: {
|
|
130
|
+
count: 0,
|
|
131
|
+
bySection: {},
|
|
132
|
+
byObjectType: {}
|
|
133
|
+
}
|
|
134
|
+
})
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
test('summaryBySection', async () => {
|
|
138
|
+
const { client, user } = await testUtils.createTestUserAndClient()
|
|
139
|
+
const chartKey = testUtils.getChartKey()
|
|
140
|
+
await testUtils.createTestChart(chartKey, user.secretKey)
|
|
141
|
+
|
|
142
|
+
const report = await client.chartReports.summaryBySection(chartKey)
|
|
143
|
+
|
|
144
|
+
expect(report).toEqual({
|
|
145
|
+
NO_SECTION: {
|
|
146
|
+
count: 232,
|
|
147
|
+
byCategoryKey: { 9: 116, 10: 116 },
|
|
148
|
+
byCategoryLabel: { Cat2: 116, Cat1: 116 },
|
|
149
|
+
byObjectType: {
|
|
150
|
+
generalAdmission: 200,
|
|
151
|
+
seat: 32
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
})
|
|
155
|
+
})
|
|
@@ -2,7 +2,7 @@ const ChartListParams = require('../../src/Charts/ChartListParams.js')
|
|
|
2
2
|
const testUtils = require('../testUtils.js')
|
|
3
3
|
|
|
4
4
|
test('listAll when there are many charts', async () => {
|
|
5
|
-
const { client
|
|
5
|
+
const { client } = await testUtils.createTestUserAndClient()
|
|
6
6
|
const charts = await testUtils.createArray(15, () => client.charts.create())
|
|
7
7
|
|
|
8
8
|
const retrievedKeys = []
|
|
@@ -14,7 +14,7 @@ test('listAll when there are many charts', async () => {
|
|
|
14
14
|
})
|
|
15
15
|
|
|
16
16
|
test('listAll when there are no charts', async () => {
|
|
17
|
-
const { client
|
|
17
|
+
const { client } = await testUtils.createTestUserAndClient()
|
|
18
18
|
const retrievedKeys = []
|
|
19
19
|
|
|
20
20
|
for await (const chart of client.charts.listAll()) {
|
|
@@ -25,7 +25,7 @@ test('listAll when there are no charts', async () => {
|
|
|
25
25
|
})
|
|
26
26
|
|
|
27
27
|
test('listAll Charts with filter', async () => {
|
|
28
|
-
const { client
|
|
28
|
+
const { client } = await testUtils.createTestUserAndClient()
|
|
29
29
|
const fooCharts = await testUtils.createArray(3, () => client.charts.create('foo'))
|
|
30
30
|
await client.charts.create('bar')
|
|
31
31
|
const params = new ChartListParams().withFilter('foo')
|
|
@@ -39,7 +39,7 @@ test('listAll Charts with filter', async () => {
|
|
|
39
39
|
})
|
|
40
40
|
|
|
41
41
|
test('listAll Charts with tag', async () => {
|
|
42
|
-
const { client
|
|
42
|
+
const { client } = await testUtils.createTestUserAndClient()
|
|
43
43
|
const fooCharts = await testUtils.createArray(3, async () => {
|
|
44
44
|
const chart = await client.charts.create()
|
|
45
45
|
await client.charts.addTag(chart.key, 'foo')
|
|
@@ -58,7 +58,7 @@ test('listAll Charts with tag', async () => {
|
|
|
58
58
|
})
|
|
59
59
|
|
|
60
60
|
test('listAll Charts with tag and filter parameters', async () => {
|
|
61
|
-
const { client
|
|
61
|
+
const { client } = await testUtils.createTestUserAndClient()
|
|
62
62
|
const chart1 = await client.charts.create('bar')
|
|
63
63
|
const chart2 = await client.charts.create()
|
|
64
64
|
const chart3 = await client.charts.create('bar')
|
|
@@ -77,7 +77,7 @@ test('listAll Charts with tag and filter parameters', async () => {
|
|
|
77
77
|
})
|
|
78
78
|
|
|
79
79
|
test('listAll Charts with expandEvents parameters', async () => {
|
|
80
|
-
const { client
|
|
80
|
+
const { client } = await testUtils.createTestUserAndClient()
|
|
81
81
|
const chart1 = await client.charts.create()
|
|
82
82
|
const chart2 = await client.charts.create()
|
|
83
83
|
const promises = [
|
|
@@ -100,8 +100,26 @@ test('listAll Charts with expandEvents parameters', async () => {
|
|
|
100
100
|
expect(retrievedKeys.sort()).toEqual(generatedEventKeys.sort())
|
|
101
101
|
})
|
|
102
102
|
|
|
103
|
+
test('listAll Charts with expandEvents parameters and eventsLimit', async () => {
|
|
104
|
+
const { client } = await testUtils.createTestUserAndClient()
|
|
105
|
+
const chart1 = await client.charts.create()
|
|
106
|
+
const event1 = await client.events.create(chart1.key)
|
|
107
|
+
const event2 = await client.events.create(chart1.key)
|
|
108
|
+
const event3 = await client.events.create(chart1.key)
|
|
109
|
+
const retrievedKeys = []
|
|
110
|
+
const params = new ChartListParams().withExpandEvents(true).withEventsLimit(2)
|
|
111
|
+
|
|
112
|
+
for await (const chart of client.charts.listAll(params)) {
|
|
113
|
+
for (const event of chart.events) {
|
|
114
|
+
retrievedKeys.push(event.key)
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
expect(retrievedKeys).toEqual([event3.key, event2.key])
|
|
119
|
+
})
|
|
120
|
+
|
|
103
121
|
test('list all charts with validation', async () => {
|
|
104
|
-
const { client
|
|
122
|
+
const { client } = await testUtils.createTestUserAndClient()
|
|
105
123
|
await testUtils.createArray(3, () => client.charts.create())
|
|
106
124
|
const params = new ChartListParams(...Array(3), true)
|
|
107
125
|
|
|
@@ -111,7 +129,7 @@ test('list all charts with validation', async () => {
|
|
|
111
129
|
})
|
|
112
130
|
|
|
113
131
|
test('list all charts without validation', async () => {
|
|
114
|
-
const { client
|
|
132
|
+
const { client } = await testUtils.createTestUserAndClient()
|
|
115
133
|
await testUtils.createArray(3, () => client.charts.create())
|
|
116
134
|
const params = new ChartListParams()
|
|
117
135
|
|
|
@@ -37,7 +37,8 @@ test('report properties', async () => {
|
|
|
37
37
|
expect(reportItem.displayedObjectType).toBe(undefined)
|
|
38
38
|
expect(reportItem.leftNeighbour).toBe(undefined)
|
|
39
39
|
expect(reportItem.rightNeighbour).toBe('A-2')
|
|
40
|
-
expect(reportItem.
|
|
40
|
+
expect(reportItem.isAvailable).toBe(false)
|
|
41
|
+
expect(reportItem.availabilityReason).toBe('booked')
|
|
41
42
|
expect(reportItem.isDisabledBySocialDistancing).toBe(false)
|
|
42
43
|
expect(reportItem.bookAsAWhole).toBe(undefined)
|
|
43
44
|
expect(reportItem.distanceToFocalPoint).toBeTruthy()
|
|
@@ -252,7 +253,7 @@ test('report by object type', async () => {
|
|
|
252
253
|
expect(report.booth.length).toBe(0)
|
|
253
254
|
})
|
|
254
255
|
|
|
255
|
-
test('report by
|
|
256
|
+
test('report by availability', async () => {
|
|
256
257
|
const { client, user } = await testUtils.createTestUserAndClient()
|
|
257
258
|
const chartKey = testUtils.getChartKey()
|
|
258
259
|
await testUtils.createTestChart(chartKey, user.secretKey)
|
|
@@ -261,13 +262,13 @@ test('report by selectability', async () => {
|
|
|
261
262
|
await client.events.book(event.key, 'A-2', null, 'order1')
|
|
262
263
|
await client.events.book(event.key, 'A-3', null, 'order2')
|
|
263
264
|
|
|
264
|
-
const report = await client.eventReports.
|
|
265
|
+
const report = await client.eventReports.byAvailability(event.key)
|
|
265
266
|
|
|
266
|
-
expect(report.
|
|
267
|
-
expect(report.
|
|
267
|
+
expect(report.available.length).toBe(31)
|
|
268
|
+
expect(report.not_available.length).toBe(3)
|
|
268
269
|
})
|
|
269
270
|
|
|
270
|
-
test('report by specific
|
|
271
|
+
test('report by specific availability', async () => {
|
|
271
272
|
const { client, user } = await testUtils.createTestUserAndClient()
|
|
272
273
|
const chartKey = testUtils.getChartKey()
|
|
273
274
|
await testUtils.createTestChart(chartKey, user.secretKey)
|
|
@@ -276,9 +277,38 @@ test('report by specific selectability', async () => {
|
|
|
276
277
|
await client.events.book(event.key, 'A-2', null, 'order1')
|
|
277
278
|
await client.events.book(event.key, 'A-3', null, 'order2')
|
|
278
279
|
|
|
279
|
-
const report = await client.eventReports.
|
|
280
|
+
const report = await client.eventReports.byAvailability(event.key, 'available')
|
|
280
281
|
|
|
281
|
-
expect(report.
|
|
282
|
+
expect(report.available.length).toBe(31)
|
|
283
|
+
})
|
|
284
|
+
|
|
285
|
+
test('report by availability reason', async () => {
|
|
286
|
+
const { client, user } = await testUtils.createTestUserAndClient()
|
|
287
|
+
const chartKey = testUtils.getChartKey()
|
|
288
|
+
await testUtils.createTestChart(chartKey, user.secretKey)
|
|
289
|
+
const event = await client.events.create(chartKey)
|
|
290
|
+
await client.events.book(event.key, 'A-1', null, 'order1')
|
|
291
|
+
await client.events.book(event.key, 'A-2', null, 'order1')
|
|
292
|
+
await client.events.book(event.key, 'A-3', null, 'order2')
|
|
293
|
+
|
|
294
|
+
const report = await client.eventReports.byAvailabilityReason(event.key)
|
|
295
|
+
|
|
296
|
+
expect(report.available.length).toBe(31)
|
|
297
|
+
expect(report.booked.length).toBe(3)
|
|
298
|
+
})
|
|
299
|
+
|
|
300
|
+
test('report by specific availability reason', async () => {
|
|
301
|
+
const { client, user } = await testUtils.createTestUserAndClient()
|
|
302
|
+
const chartKey = testUtils.getChartKey()
|
|
303
|
+
await testUtils.createTestChart(chartKey, user.secretKey)
|
|
304
|
+
const event = await client.events.create(chartKey)
|
|
305
|
+
await client.events.book(event.key, 'A-1', null, 'order1')
|
|
306
|
+
await client.events.book(event.key, 'A-2', null, 'order1')
|
|
307
|
+
await client.events.book(event.key, 'A-3', null, 'order2')
|
|
308
|
+
|
|
309
|
+
const report = await client.eventReports.byAvailabilityReason(event.key, 'booked')
|
|
310
|
+
|
|
311
|
+
expect(report.booked.length).toBe(3)
|
|
282
312
|
})
|
|
283
313
|
|
|
284
314
|
test('report by channel', async () => {
|
|
@@ -70,18 +70,32 @@ test('deepSummaryBySection', async () => {
|
|
|
70
70
|
expect(report.NO_SECTION.byCategoryLabel.Cat1.bySelectability.not_selectable).toEqual(1)
|
|
71
71
|
})
|
|
72
72
|
|
|
73
|
-
test('
|
|
73
|
+
test('deepSummaryByAvailability', async () => {
|
|
74
74
|
const { client, user } = await testUtils.createTestUserAndClient()
|
|
75
75
|
const chartKey = testUtils.getChartKey()
|
|
76
76
|
await testUtils.createTestChart(chartKey, user.secretKey)
|
|
77
77
|
const event = await client.events.create(chartKey)
|
|
78
78
|
await client.events.book(event.key, (new ObjectProperties('A-1')))
|
|
79
79
|
|
|
80
|
-
const report = await client.eventReports.
|
|
80
|
+
const report = await client.eventReports.deepSummaryByAvailability(event.key)
|
|
81
81
|
|
|
82
|
-
expect(report.
|
|
83
|
-
expect(report.
|
|
84
|
-
expect(report.
|
|
82
|
+
expect(report.not_available.count).toEqual(1)
|
|
83
|
+
expect(report.not_available.byCategoryLabel.Cat1.count).toEqual(1)
|
|
84
|
+
expect(report.not_available.byCategoryLabel.Cat1.bySection.NO_SECTION).toEqual(1)
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
test('deepSummaryByAvailabilityReason', async () => {
|
|
88
|
+
const { client, user } = await testUtils.createTestUserAndClient()
|
|
89
|
+
const chartKey = testUtils.getChartKey()
|
|
90
|
+
await testUtils.createTestChart(chartKey, user.secretKey)
|
|
91
|
+
const event = await client.events.create(chartKey)
|
|
92
|
+
await client.events.book(event.key, (new ObjectProperties('A-1')))
|
|
93
|
+
|
|
94
|
+
const report = await client.eventReports.deepSummaryByAvailabilityReason(event.key)
|
|
95
|
+
|
|
96
|
+
expect(report.booked.count).toEqual(1)
|
|
97
|
+
expect(report.booked.byCategoryLabel.Cat1.count).toEqual(1)
|
|
98
|
+
expect(report.booked.byCategoryLabel.Cat1.bySection.NO_SECTION).toEqual(1)
|
|
85
99
|
})
|
|
86
100
|
|
|
87
101
|
test('deepSummaryByChannel', async () => {
|
|
@@ -17,6 +17,8 @@ test('summaryByStatus', async () => {
|
|
|
17
17
|
count: 1,
|
|
18
18
|
byCategoryKey: { 9: 1 },
|
|
19
19
|
bySelectability: { not_selectable: 1 },
|
|
20
|
+
byAvailability: { not_available: 1 },
|
|
21
|
+
byAvailabilityReason: { booked: 1 },
|
|
20
22
|
byCategoryLabel: { Cat1: 1 },
|
|
21
23
|
byChannel: { NO_CHANNEL: 1 }
|
|
22
24
|
},
|
|
@@ -26,6 +28,8 @@ test('summaryByStatus', async () => {
|
|
|
26
28
|
count: 231,
|
|
27
29
|
byCategoryKey: { 9: 115, 10: 116 },
|
|
28
30
|
bySelectability: { selectable: 231 },
|
|
31
|
+
byAvailability: { available: 231 },
|
|
32
|
+
byAvailabilityReason: { available: 231 },
|
|
29
33
|
byCategoryLabel: { Cat2: 116, Cat1: 115 },
|
|
30
34
|
byChannel: { NO_CHANNEL: 231 }
|
|
31
35
|
}
|
|
@@ -47,6 +51,8 @@ test('summaryByObjectType', async () => {
|
|
|
47
51
|
count: 32,
|
|
48
52
|
byCategoryKey: { 9: 16, 10: 16 },
|
|
49
53
|
bySelectability: { selectable: 32 },
|
|
54
|
+
byAvailability: { available: 32 },
|
|
55
|
+
byAvailabilityReason: { available: 32 },
|
|
50
56
|
byCategoryLabel: { Cat1: 16, Cat2: 16 },
|
|
51
57
|
byChannel: { NO_CHANNEL: 32 }
|
|
52
58
|
},
|
|
@@ -56,26 +62,32 @@ test('summaryByObjectType', async () => {
|
|
|
56
62
|
byStatus: { free: 200 },
|
|
57
63
|
byCategoryKey: { 9: 100, 10: 100 },
|
|
58
64
|
bySelectability: { selectable: 200 },
|
|
65
|
+
byAvailability: { available: 200 },
|
|
66
|
+
byAvailabilityReason: { available: 200 },
|
|
59
67
|
byCategoryLabel: { Cat2: 100, Cat1: 100 },
|
|
60
68
|
byChannel: { NO_CHANNEL: 200 }
|
|
61
69
|
},
|
|
62
70
|
table: {
|
|
63
71
|
count: 0,
|
|
64
|
-
bySection: {
|
|
72
|
+
bySection: {},
|
|
65
73
|
byStatus: {},
|
|
66
74
|
byCategoryKey: {},
|
|
67
|
-
bySelectability: {
|
|
75
|
+
bySelectability: {},
|
|
76
|
+
byAvailability: {},
|
|
77
|
+
byAvailabilityReason: {},
|
|
68
78
|
byCategoryLabel: {},
|
|
69
|
-
byChannel: {
|
|
79
|
+
byChannel: {}
|
|
70
80
|
},
|
|
71
81
|
booth: {
|
|
72
82
|
count: 0,
|
|
73
|
-
bySection: {
|
|
83
|
+
bySection: {},
|
|
74
84
|
byStatus: {},
|
|
75
85
|
byCategoryKey: {},
|
|
76
|
-
bySelectability: {
|
|
86
|
+
bySelectability: {},
|
|
87
|
+
byAvailability: {},
|
|
88
|
+
byAvailabilityReason: {},
|
|
77
89
|
byCategoryLabel: {},
|
|
78
|
-
byChannel: {
|
|
90
|
+
byChannel: {}
|
|
79
91
|
}
|
|
80
92
|
})
|
|
81
93
|
})
|
|
@@ -94,6 +106,8 @@ test('summaryByCategoryKey', async () => {
|
|
|
94
106
|
count: 116,
|
|
95
107
|
bySection: { NO_SECTION: 116 },
|
|
96
108
|
bySelectability: { selectable: 115, not_selectable: 1 },
|
|
109
|
+
byAvailability: { available: 115, not_available: 1 },
|
|
110
|
+
byAvailabilityReason: { available: 115, booked: 1 },
|
|
97
111
|
byStatus: { booked: 1, free: 115 },
|
|
98
112
|
byChannel: { NO_CHANNEL: 116 },
|
|
99
113
|
byObjectType: {
|
|
@@ -105,6 +119,8 @@ test('summaryByCategoryKey', async () => {
|
|
|
105
119
|
count: 116,
|
|
106
120
|
bySection: { NO_SECTION: 116 },
|
|
107
121
|
bySelectability: { selectable: 116 },
|
|
122
|
+
byAvailability: { available: 116 },
|
|
123
|
+
byAvailabilityReason: { available: 116 },
|
|
108
124
|
byStatus: { free: 116 },
|
|
109
125
|
byChannel: { NO_CHANNEL: 116 },
|
|
110
126
|
byObjectType: {
|
|
@@ -116,6 +132,8 @@ test('summaryByCategoryKey', async () => {
|
|
|
116
132
|
count: 0,
|
|
117
133
|
bySection: {},
|
|
118
134
|
bySelectability: {},
|
|
135
|
+
byAvailability: {},
|
|
136
|
+
byAvailabilityReason: { },
|
|
119
137
|
byStatus: {},
|
|
120
138
|
byChannel: {},
|
|
121
139
|
byObjectType: {}
|
|
@@ -137,6 +155,8 @@ test('summaryByCategoryLabel', async () => {
|
|
|
137
155
|
count: 116,
|
|
138
156
|
bySection: { NO_SECTION: 116 },
|
|
139
157
|
bySelectability: { selectable: 116 },
|
|
158
|
+
byAvailability: { available: 116 },
|
|
159
|
+
byAvailabilityReason: { available: 116 },
|
|
140
160
|
byStatus: { free: 116 },
|
|
141
161
|
byChannel: { NO_CHANNEL: 116 },
|
|
142
162
|
byObjectType: {
|
|
@@ -148,6 +168,8 @@ test('summaryByCategoryLabel', async () => {
|
|
|
148
168
|
count: 116,
|
|
149
169
|
bySection: { NO_SECTION: 116 },
|
|
150
170
|
bySelectability: { selectable: 115, not_selectable: 1 },
|
|
171
|
+
byAvailability: { available: 115, not_available: 1 },
|
|
172
|
+
byAvailabilityReason: { available: 115, booked: 1 },
|
|
151
173
|
byStatus: { booked: 1, free: 115 },
|
|
152
174
|
byChannel: { NO_CHANNEL: 116 },
|
|
153
175
|
byObjectType: {
|
|
@@ -159,6 +181,8 @@ test('summaryByCategoryLabel', async () => {
|
|
|
159
181
|
count: 0,
|
|
160
182
|
bySection: {},
|
|
161
183
|
bySelectability: {},
|
|
184
|
+
byAvailability: {},
|
|
185
|
+
byAvailabilityReason: { },
|
|
162
186
|
byStatus: {},
|
|
163
187
|
byChannel: {},
|
|
164
188
|
byObjectType: {}
|
|
@@ -179,6 +203,8 @@ test('summaryBySection', async () => {
|
|
|
179
203
|
count: 232,
|
|
180
204
|
byCategoryKey: { 9: 116, 10: 116 },
|
|
181
205
|
bySelectability: { selectable: 231, not_selectable: 1 },
|
|
206
|
+
byAvailability: { available: 231, not_available: 1 },
|
|
207
|
+
byAvailabilityReason: { available: 231, booked: 1 },
|
|
182
208
|
byStatus: { booked: 1, free: 231 },
|
|
183
209
|
byCategoryLabel: { Cat2: 116, Cat1: 116 },
|
|
184
210
|
byChannel: { NO_CHANNEL: 232 },
|
|
@@ -190,20 +216,62 @@ test('summaryBySection', async () => {
|
|
|
190
216
|
})
|
|
191
217
|
})
|
|
192
218
|
|
|
193
|
-
test('
|
|
219
|
+
test('summaryByAvailability', async () => {
|
|
220
|
+
const { client, user } = await testUtils.createTestUserAndClient()
|
|
221
|
+
const chartKey = testUtils.getChartKey()
|
|
222
|
+
await testUtils.createTestChart(chartKey, user.secretKey)
|
|
223
|
+
const event = await client.events.create(chartKey)
|
|
224
|
+
await client.events.book(event.key, (new ObjectProperties('A-1')))
|
|
225
|
+
|
|
226
|
+
const report = await client.eventReports.summaryByAvailability(event.key)
|
|
227
|
+
|
|
228
|
+
expect(report).toEqual({
|
|
229
|
+
available: {
|
|
230
|
+
bySection: { NO_SECTION: 231 },
|
|
231
|
+
count: 231,
|
|
232
|
+
byCategoryKey: { 9: 115, 10: 116 },
|
|
233
|
+
bySelectability: { selectable: 231 },
|
|
234
|
+
byAvailabilityReason: { available: 231 },
|
|
235
|
+
byStatus: { free: 231 },
|
|
236
|
+
byCategoryLabel: { Cat2: 116, Cat1: 115 },
|
|
237
|
+
byChannel: { NO_CHANNEL: 231 },
|
|
238
|
+
byObjectType: {
|
|
239
|
+
generalAdmission: 200,
|
|
240
|
+
seat: 31
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
not_available: {
|
|
244
|
+
bySection: { NO_SECTION: 1 },
|
|
245
|
+
count: 1,
|
|
246
|
+
byCategoryKey: { 9: 1 },
|
|
247
|
+
bySelectability: { not_selectable: 1 },
|
|
248
|
+
byAvailabilityReason: { booked: 1 },
|
|
249
|
+
byStatus: { booked: 1 },
|
|
250
|
+
byCategoryLabel: { Cat1: 1 },
|
|
251
|
+
byChannel: { NO_CHANNEL: 1 },
|
|
252
|
+
byObjectType: {
|
|
253
|
+
seat: 1
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
})
|
|
257
|
+
})
|
|
258
|
+
|
|
259
|
+
test('summaryByAvailabilityReason', async () => {
|
|
194
260
|
const { client, user } = await testUtils.createTestUserAndClient()
|
|
195
261
|
const chartKey = testUtils.getChartKey()
|
|
196
262
|
await testUtils.createTestChart(chartKey, user.secretKey)
|
|
197
263
|
const event = await client.events.create(chartKey)
|
|
198
264
|
await client.events.book(event.key, (new ObjectProperties('A-1')))
|
|
199
265
|
|
|
200
|
-
const report = await client.eventReports.
|
|
266
|
+
const report = await client.eventReports.summaryByAvailabilityReason(event.key)
|
|
201
267
|
|
|
202
268
|
expect(report).toEqual({
|
|
203
|
-
|
|
269
|
+
available: {
|
|
204
270
|
bySection: { NO_SECTION: 231 },
|
|
205
271
|
count: 231,
|
|
206
272
|
byCategoryKey: { 9: 115, 10: 116 },
|
|
273
|
+
bySelectability: { selectable: 231 },
|
|
274
|
+
byAvailability: { available: 231 },
|
|
207
275
|
byStatus: { free: 231 },
|
|
208
276
|
byCategoryLabel: { Cat2: 116, Cat1: 115 },
|
|
209
277
|
byChannel: { NO_CHANNEL: 231 },
|
|
@@ -212,16 +280,51 @@ test('summaryBySelectability', async () => {
|
|
|
212
280
|
seat: 31
|
|
213
281
|
}
|
|
214
282
|
},
|
|
215
|
-
|
|
283
|
+
booked: {
|
|
216
284
|
bySection: { NO_SECTION: 1 },
|
|
217
285
|
count: 1,
|
|
218
286
|
byCategoryKey: { 9: 1 },
|
|
287
|
+
bySelectability: { not_selectable: 1 },
|
|
288
|
+
byAvailability: { not_available: 1 },
|
|
219
289
|
byStatus: { booked: 1 },
|
|
220
290
|
byCategoryLabel: { Cat1: 1 },
|
|
221
291
|
byChannel: { NO_CHANNEL: 1 },
|
|
222
292
|
byObjectType: {
|
|
223
293
|
seat: 1
|
|
224
294
|
}
|
|
295
|
+
},
|
|
296
|
+
disabled_by_social_distancing: {
|
|
297
|
+
count: 0,
|
|
298
|
+
bySection: { },
|
|
299
|
+
byCategoryKey: { },
|
|
300
|
+
bySelectability: { },
|
|
301
|
+
byAvailability: { },
|
|
302
|
+
byStatus: { },
|
|
303
|
+
byCategoryLabel: { },
|
|
304
|
+
byChannel: { },
|
|
305
|
+
byObjectType: {}
|
|
306
|
+
},
|
|
307
|
+
not_for_sale: {
|
|
308
|
+
count: 0,
|
|
309
|
+
bySection: { },
|
|
310
|
+
byCategoryKey: { },
|
|
311
|
+
bySelectability: { },
|
|
312
|
+
byAvailability: { },
|
|
313
|
+
byStatus: { },
|
|
314
|
+
byCategoryLabel: { },
|
|
315
|
+
byChannel: { },
|
|
316
|
+
byObjectType: {}
|
|
317
|
+
},
|
|
318
|
+
reservedByToken: {
|
|
319
|
+
count: 0,
|
|
320
|
+
bySection: { },
|
|
321
|
+
byCategoryKey: { },
|
|
322
|
+
bySelectability: { },
|
|
323
|
+
byAvailability: { },
|
|
324
|
+
byStatus: { },
|
|
325
|
+
byCategoryLabel: { },
|
|
326
|
+
byChannel: { },
|
|
327
|
+
byObjectType: {}
|
|
225
328
|
}
|
|
226
329
|
})
|
|
227
330
|
})
|
|
@@ -246,6 +349,8 @@ test('summaryByChannel', async () => {
|
|
|
246
349
|
byStatus: { free: 230 },
|
|
247
350
|
byCategoryLabel: { Cat2: 116, Cat1: 114 },
|
|
248
351
|
bySelectability: { selectable: 230 },
|
|
352
|
+
byAvailabilityReason: { available: 230 },
|
|
353
|
+
byAvailability: { available: 230 },
|
|
249
354
|
byObjectType: {
|
|
250
355
|
generalAdmission: 200,
|
|
251
356
|
seat: 30
|
|
@@ -258,6 +363,8 @@ test('summaryByChannel', async () => {
|
|
|
258
363
|
byStatus: { free: 2 },
|
|
259
364
|
byCategoryLabel: { Cat1: 2 },
|
|
260
365
|
bySelectability: { selectable: 2 },
|
|
366
|
+
byAvailability: { available: 2 },
|
|
367
|
+
byAvailabilityReason: { available: 2 },
|
|
261
368
|
byObjectType: {
|
|
262
369
|
seat: 2
|
|
263
370
|
}
|
|
@@ -26,7 +26,8 @@ test('should change object status', async () => {
|
|
|
26
26
|
hasRestrictedView: false,
|
|
27
27
|
isCompanionSeat: false,
|
|
28
28
|
rightNeighbour: 'A-2',
|
|
29
|
-
|
|
29
|
+
isAvailable: false,
|
|
30
|
+
availabilityReason: 'lolzor',
|
|
30
31
|
isDisabledBySocialDistancing: false,
|
|
31
32
|
distanceToFocalPoint: 79.43847425150014
|
|
32
33
|
}
|
|
@@ -228,3 +229,33 @@ test('should accept ignoreSocialDistancing', async () => {
|
|
|
228
229
|
const objectInfo = await client.events.retrieveObjectInfo(event.key, 'A-1')
|
|
229
230
|
expect(objectInfo.status).toBe(EventObjectInfo.BOOKED)
|
|
230
231
|
})
|
|
232
|
+
|
|
233
|
+
test('should accept allowedPreviousStatuses', async () => {
|
|
234
|
+
const { client, user } = await testUtils.createTestUserAndClient()
|
|
235
|
+
const chartKey = testUtils.getChartKey()
|
|
236
|
+
await testUtils.createTestChart(chartKey, user.secretKey)
|
|
237
|
+
const event = await client.events.create(chartKey)
|
|
238
|
+
|
|
239
|
+
try {
|
|
240
|
+
await client.events.changeObjectStatus(event.key, ['A-1'], EventObjectInfo.BOOKED, null, null, null, null, null, true, ['MustBeThisStatus'], null)
|
|
241
|
+
throw new Error('Should have failed')
|
|
242
|
+
} catch (e) {
|
|
243
|
+
expect(e.errors.length).toEqual(1)
|
|
244
|
+
expect(e.errors[0].code).toBe('ILLEGAL_STATUS_CHANGE')
|
|
245
|
+
}
|
|
246
|
+
})
|
|
247
|
+
|
|
248
|
+
test('should accept rejectedPreviousStatuses', async () => {
|
|
249
|
+
const { client, user } = await testUtils.createTestUserAndClient()
|
|
250
|
+
const chartKey = testUtils.getChartKey()
|
|
251
|
+
await testUtils.createTestChart(chartKey, user.secretKey)
|
|
252
|
+
const event = await client.events.create(chartKey)
|
|
253
|
+
|
|
254
|
+
try {
|
|
255
|
+
await client.events.changeObjectStatus(event.key, ['A-1'], EventObjectInfo.BOOKED, null, null, null, null, null, true, null, ['free'])
|
|
256
|
+
throw new Error('Should have failed')
|
|
257
|
+
} catch (e) {
|
|
258
|
+
expect(e.errors.length).toEqual(1)
|
|
259
|
+
expect(e.errors[0].code).toBe('ILLEGAL_STATUS_CHANGE')
|
|
260
|
+
}
|
|
261
|
+
})
|
|
@@ -71,3 +71,37 @@ test('should accept ignoreChannels', async () => {
|
|
|
71
71
|
|
|
72
72
|
expect(result[0].objects['A-1'].status).toBe('lolzor')
|
|
73
73
|
})
|
|
74
|
+
|
|
75
|
+
test('should accept allowedPreviousStatuses', async () => {
|
|
76
|
+
const { client, user } = await testUtils.createTestUserAndClient()
|
|
77
|
+
const chartKey = testUtils.getChartKey()
|
|
78
|
+
await testUtils.createTestChart(chartKey, user.secretKey)
|
|
79
|
+
const event = await client.events.create(chartKey)
|
|
80
|
+
|
|
81
|
+
try {
|
|
82
|
+
await client.events.changeObjectStatusInBatch([
|
|
83
|
+
new StatusChangeRequest(event.key, ['A-1'], 'lolzor', null, null, null, null, null, ['MustBeThisStatus'], null)
|
|
84
|
+
])
|
|
85
|
+
throw new Error('Should have failed')
|
|
86
|
+
} catch (e) {
|
|
87
|
+
expect(e.errors.length).toEqual(1)
|
|
88
|
+
expect(e.errors[0].code).toBe('ILLEGAL_STATUS_CHANGE')
|
|
89
|
+
}
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
test('should accept rejectedPreviousStatuses', async () => {
|
|
93
|
+
const { client, user } = await testUtils.createTestUserAndClient()
|
|
94
|
+
const chartKey = testUtils.getChartKey()
|
|
95
|
+
await testUtils.createTestChart(chartKey, user.secretKey)
|
|
96
|
+
const event = await client.events.create(chartKey)
|
|
97
|
+
|
|
98
|
+
try {
|
|
99
|
+
await client.events.changeObjectStatusInBatch([
|
|
100
|
+
new StatusChangeRequest(event.key, ['A-1'], 'lolzor', null, null, null, true, null, null, ['free'])
|
|
101
|
+
])
|
|
102
|
+
throw new Error('Should have failed')
|
|
103
|
+
} catch (e) {
|
|
104
|
+
expect(e.errors.length).toEqual(1)
|
|
105
|
+
expect(e.errors[0].code).toBe('ILLEGAL_STATUS_CHANGE')
|
|
106
|
+
}
|
|
107
|
+
})
|
|
@@ -8,7 +8,7 @@ test('aborts eventually if server keeps returning 429', async () => {
|
|
|
8
8
|
await client.client.get('/status/429')
|
|
9
9
|
throw new Error('Should have failed')
|
|
10
10
|
} catch (e) {
|
|
11
|
-
expect(e).toBe('get /status/429 resulted in 429
|
|
11
|
+
expect(e).toBe('get /status/429 resulted in 429 TOO MANY REQUESTS error')
|
|
12
12
|
const waitTime = new Date().getTime() - start.getTime()
|
|
13
13
|
expect(waitTime).toBeGreaterThan(10000)
|
|
14
14
|
expect(waitTime).toBeLessThan(20000)
|
|
@@ -22,7 +22,7 @@ test('aborts directly if server returns error other than 429', async () => {
|
|
|
22
22
|
await client.client.get('/status/400')
|
|
23
23
|
throw new Error('Should have failed')
|
|
24
24
|
} catch (e) {
|
|
25
|
-
expect(e).toBe('get /status/400 resulted in 400
|
|
25
|
+
expect(e).toBe('get /status/400 resulted in 400 BAD REQUEST error')
|
|
26
26
|
const waitTime = new Date().getTime() - start.getTime()
|
|
27
27
|
expect(waitTime).toBeLessThan(2000)
|
|
28
28
|
}
|
|
@@ -35,7 +35,7 @@ test('aborts directly if server returns 429 but max retries 0', async () => {
|
|
|
35
35
|
await client.client.get('/status/429')
|
|
36
36
|
throw new Error('Should have failed')
|
|
37
37
|
} catch (e) {
|
|
38
|
-
expect(e).toBe('get /status/429 resulted in 429
|
|
38
|
+
expect(e).toBe('get /status/429 resulted in 429 TOO MANY REQUESTS error')
|
|
39
39
|
const waitTime = new Date().getTime() - start.getTime()
|
|
40
40
|
expect(waitTime).toBeLessThan(2000)
|
|
41
41
|
}
|