seatsio 64.0.0 → 65.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/README.md +38 -4
- package/package.json +6 -6
- package/src/Charts/ChartListParams.js +14 -2
- package/src/Events/Events.js +1 -1
- package/src/Reports/EventReports.js +6 -6
- package/src/errorInterceptor.js +1 -2
- package/tests/charts/listAllCharts.test.js +30 -8
- package/tests/eventReports/eventReport.test.js +7 -7
- package/tests/eventReports/eventReportDeepSummary.test.js +5 -5
- package/tests/eventReports/eventReportSummary.test.js +21 -4
- package/tests/exponentialBackoff.test.js +9 -9
package/README.md
CHANGED
|
@@ -154,6 +154,23 @@ A combination of filter, sorting order and sorting option is also possible.
|
|
|
154
154
|
let parameter = new StatusChangesParams().withFilter('testFilter').sortByStatus().sortAscending()
|
|
155
155
|
```
|
|
156
156
|
|
|
157
|
+
### Retrieving object category and status (and other information)
|
|
158
|
+
|
|
159
|
+
```js
|
|
160
|
+
import { SeatsioClient, Region } from 'seatsio'
|
|
161
|
+
|
|
162
|
+
let client = new SeatsioClient(Region.EU(), <WORKSPACE SECRET KEY>)
|
|
163
|
+
let objectInfos = await client.events.retrieveObjectInfos(event.key, ['A-1', 'A-2'])
|
|
164
|
+
|
|
165
|
+
console.log(objectInfos['A-1'].categoryKey)
|
|
166
|
+
console.log(objectInfos['A-1'].categoryLabel)
|
|
167
|
+
console.log(objectInfos['A-1'].status)
|
|
168
|
+
|
|
169
|
+
console.log(objectInfos['A-2'].categoryKey)
|
|
170
|
+
console.log(objectInfos['A-2'].categoryLabel)
|
|
171
|
+
console.log(objectInfos['A-2'].status)
|
|
172
|
+
```
|
|
173
|
+
|
|
157
174
|
### Event reports
|
|
158
175
|
|
|
159
176
|
Want to know which seats of an event are booked, and which ones are free? That’s where reporting comes in handy.
|
|
@@ -224,12 +241,29 @@ let client = new SeatsioClient(Region.EU(), <COMPANY ADMIN KEY>)
|
|
|
224
241
|
await client.workspaces.create('a workspace');
|
|
225
242
|
```
|
|
226
243
|
|
|
244
|
+
### Creating a chart and an event with the company admin key
|
|
245
|
+
|
|
246
|
+
```js
|
|
247
|
+
import { SeatsioClient, Region } from 'seatsio'
|
|
248
|
+
|
|
249
|
+
let client = new SeatsioClient(Region.EU(), <COMPANY ADMIN KEY>, <WORKSPACE PUBLIC KEY>)
|
|
250
|
+
let chart = await client.charts.create()
|
|
251
|
+
let event = await client.events.create(chart.key)
|
|
252
|
+
console.log(`Created a chart with key ${chart.key} and an event with key: ${event.key}`)
|
|
253
|
+
```
|
|
254
|
+
|
|
227
255
|
## Error Handling
|
|
228
|
-
When an API call results in an error, a rejected promise is returned with
|
|
256
|
+
When an API call results in an error, a rejected promise is returned with a value that looks like
|
|
257
|
+
|
|
258
|
+
```json
|
|
259
|
+
{
|
|
260
|
+
errors: [{ code: 'RATE_LIMIT_EXCEEDED', message: 'Rate limit exceeded' }],
|
|
261
|
+
messages: ['Rate limit exceeded'],
|
|
262
|
+
requestId: '123456',
|
|
263
|
+
status: 429
|
|
264
|
+
}
|
|
265
|
+
```
|
|
229
266
|
|
|
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
267
|
## Rate limiting - exponential backoff
|
|
234
268
|
|
|
235
269
|
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.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,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": "5.
|
|
25
|
+
"eslint-plugin-promise": "5.2.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.3",
|
|
34
|
+
"jest-cli": "27.4.3",
|
|
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
|
}
|
package/src/Events/Events.js
CHANGED
|
@@ -277,7 +277,7 @@ class Events {
|
|
|
277
277
|
const request = this.changeObjectStatusRequest(objectOrObjects, status, holdToken, orderId, keepExtraData, ignoreChannels, channelKeys, ignoreSocialDistancing)
|
|
278
278
|
request.events = Array.isArray(eventKeyOrKeys) ? eventKeyOrKeys : [eventKeyOrKeys]
|
|
279
279
|
|
|
280
|
-
return this.client.post('/
|
|
280
|
+
return this.client.post('/events/groups/actions/change-object-status?expand=objects', request)
|
|
281
281
|
.then((res) => new ChangeObjectStatusResult(res.data.objects))
|
|
282
282
|
}
|
|
283
283
|
|
|
@@ -170,8 +170,8 @@ class EventReports {
|
|
|
170
170
|
* @param {?string} selectability
|
|
171
171
|
* @returns {Object.<string, ObjectInfo[]>}
|
|
172
172
|
*/
|
|
173
|
-
|
|
174
|
-
return this.client.get(EventReports.reportUrl('
|
|
173
|
+
byAvailability (eventKey, selectability = null) {
|
|
174
|
+
return this.client.get(EventReports.reportUrl('byAvailability', eventKey, selectability))
|
|
175
175
|
.then((res) => utilities.createEventReport(res.data))
|
|
176
176
|
}
|
|
177
177
|
|
|
@@ -179,8 +179,8 @@ class EventReports {
|
|
|
179
179
|
* @param {string} eventKey
|
|
180
180
|
* @returns {Object} JSON response from the server
|
|
181
181
|
*/
|
|
182
|
-
|
|
183
|
-
return this.client.get(EventReports.summaryReportUrl('
|
|
182
|
+
summaryByAvailability (eventKey) {
|
|
183
|
+
return this.client.get(EventReports.summaryReportUrl('byAvailability', eventKey))
|
|
184
184
|
.then((res) => res.data)
|
|
185
185
|
}
|
|
186
186
|
|
|
@@ -188,8 +188,8 @@ class EventReports {
|
|
|
188
188
|
* @param {string} eventKey
|
|
189
189
|
* @returns {Object} JSON response from the server
|
|
190
190
|
*/
|
|
191
|
-
|
|
192
|
-
return this.client.get(EventReports.deepSummaryReportUrl('
|
|
191
|
+
deepSummaryByAvailability (eventKey) {
|
|
192
|
+
return this.client.get(EventReports.deepSummaryReportUrl('byAvailability', eventKey))
|
|
193
193
|
.then((res) => res.data)
|
|
194
194
|
}
|
|
195
195
|
|
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
|
})
|
|
@@ -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,30 @@ 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 promises = [
|
|
107
|
+
client.events.create(chart1.key),
|
|
108
|
+
client.events.create(chart1.key),
|
|
109
|
+
client.events.create(chart1.key)
|
|
110
|
+
]
|
|
111
|
+
const events = await Promise.all(promises)
|
|
112
|
+
const expectedEventKeys = [events[0].key, events[1].key]
|
|
113
|
+
const retrievedKeys = []
|
|
114
|
+
const params = new ChartListParams().withExpandEvents(true).withEventsLimit(2)
|
|
115
|
+
|
|
116
|
+
for await (const chart of client.charts.listAll(params)) {
|
|
117
|
+
for (const event of chart.events) {
|
|
118
|
+
retrievedKeys.push(event.key)
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
expect(retrievedKeys.sort()).toEqual(expectedEventKeys.sort())
|
|
123
|
+
})
|
|
124
|
+
|
|
103
125
|
test('list all charts with validation', async () => {
|
|
104
|
-
const { client
|
|
126
|
+
const { client } = await testUtils.createTestUserAndClient()
|
|
105
127
|
await testUtils.createArray(3, () => client.charts.create())
|
|
106
128
|
const params = new ChartListParams(...Array(3), true)
|
|
107
129
|
|
|
@@ -111,7 +133,7 @@ test('list all charts with validation', async () => {
|
|
|
111
133
|
})
|
|
112
134
|
|
|
113
135
|
test('list all charts without validation', async () => {
|
|
114
|
-
const { client
|
|
136
|
+
const { client } = await testUtils.createTestUserAndClient()
|
|
115
137
|
await testUtils.createArray(3, () => client.charts.create())
|
|
116
138
|
const params = new ChartListParams()
|
|
117
139
|
|
|
@@ -252,7 +252,7 @@ test('report by object type', async () => {
|
|
|
252
252
|
expect(report.booth.length).toBe(0)
|
|
253
253
|
})
|
|
254
254
|
|
|
255
|
-
test('report by
|
|
255
|
+
test('report by availability', async () => {
|
|
256
256
|
const { client, user } = await testUtils.createTestUserAndClient()
|
|
257
257
|
const chartKey = testUtils.getChartKey()
|
|
258
258
|
await testUtils.createTestChart(chartKey, user.secretKey)
|
|
@@ -261,13 +261,13 @@ test('report by selectability', async () => {
|
|
|
261
261
|
await client.events.book(event.key, 'A-2', null, 'order1')
|
|
262
262
|
await client.events.book(event.key, 'A-3', null, 'order2')
|
|
263
263
|
|
|
264
|
-
const report = await client.eventReports.
|
|
264
|
+
const report = await client.eventReports.byAvailability(event.key)
|
|
265
265
|
|
|
266
|
-
expect(report.
|
|
267
|
-
expect(report.
|
|
266
|
+
expect(report.available.length).toBe(31)
|
|
267
|
+
expect(report.not_available.length).toBe(3)
|
|
268
268
|
})
|
|
269
269
|
|
|
270
|
-
test('report by specific
|
|
270
|
+
test('report by specific availability', async () => {
|
|
271
271
|
const { client, user } = await testUtils.createTestUserAndClient()
|
|
272
272
|
const chartKey = testUtils.getChartKey()
|
|
273
273
|
await testUtils.createTestChart(chartKey, user.secretKey)
|
|
@@ -276,9 +276,9 @@ test('report by specific selectability', async () => {
|
|
|
276
276
|
await client.events.book(event.key, 'A-2', null, 'order1')
|
|
277
277
|
await client.events.book(event.key, 'A-3', null, 'order2')
|
|
278
278
|
|
|
279
|
-
const report = await client.eventReports.
|
|
279
|
+
const report = await client.eventReports.byAvailability(event.key, 'available')
|
|
280
280
|
|
|
281
|
-
expect(report.
|
|
281
|
+
expect(report.available.length).toBe(31)
|
|
282
282
|
})
|
|
283
283
|
|
|
284
284
|
test('report by channel', async () => {
|
|
@@ -70,18 +70,18 @@ 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
85
|
})
|
|
86
86
|
|
|
87
87
|
test('deepSummaryByChannel', async () => {
|
|
@@ -17,6 +17,7 @@ test('summaryByStatus', async () => {
|
|
|
17
17
|
count: 1,
|
|
18
18
|
byCategoryKey: { 9: 1 },
|
|
19
19
|
bySelectability: { not_selectable: 1 },
|
|
20
|
+
byAvailability: { not_available: 1 },
|
|
20
21
|
byCategoryLabel: { Cat1: 1 },
|
|
21
22
|
byChannel: { NO_CHANNEL: 1 }
|
|
22
23
|
},
|
|
@@ -26,6 +27,7 @@ test('summaryByStatus', async () => {
|
|
|
26
27
|
count: 231,
|
|
27
28
|
byCategoryKey: { 9: 115, 10: 116 },
|
|
28
29
|
bySelectability: { selectable: 231 },
|
|
30
|
+
byAvailability: { available: 231 },
|
|
29
31
|
byCategoryLabel: { Cat2: 116, Cat1: 115 },
|
|
30
32
|
byChannel: { NO_CHANNEL: 231 }
|
|
31
33
|
}
|
|
@@ -47,6 +49,7 @@ test('summaryByObjectType', async () => {
|
|
|
47
49
|
count: 32,
|
|
48
50
|
byCategoryKey: { 9: 16, 10: 16 },
|
|
49
51
|
bySelectability: { selectable: 32 },
|
|
52
|
+
byAvailability: { available: 32 },
|
|
50
53
|
byCategoryLabel: { Cat1: 16, Cat2: 16 },
|
|
51
54
|
byChannel: { NO_CHANNEL: 32 }
|
|
52
55
|
},
|
|
@@ -56,6 +59,7 @@ test('summaryByObjectType', async () => {
|
|
|
56
59
|
byStatus: { free: 200 },
|
|
57
60
|
byCategoryKey: { 9: 100, 10: 100 },
|
|
58
61
|
bySelectability: { selectable: 200 },
|
|
62
|
+
byAvailability: { available: 200 },
|
|
59
63
|
byCategoryLabel: { Cat2: 100, Cat1: 100 },
|
|
60
64
|
byChannel: { NO_CHANNEL: 200 }
|
|
61
65
|
},
|
|
@@ -65,6 +69,7 @@ test('summaryByObjectType', async () => {
|
|
|
65
69
|
byStatus: {},
|
|
66
70
|
byCategoryKey: {},
|
|
67
71
|
bySelectability: { },
|
|
72
|
+
byAvailability: { },
|
|
68
73
|
byCategoryLabel: {},
|
|
69
74
|
byChannel: { }
|
|
70
75
|
},
|
|
@@ -74,6 +79,7 @@ test('summaryByObjectType', async () => {
|
|
|
74
79
|
byStatus: {},
|
|
75
80
|
byCategoryKey: {},
|
|
76
81
|
bySelectability: { },
|
|
82
|
+
byAvailability: { },
|
|
77
83
|
byCategoryLabel: {},
|
|
78
84
|
byChannel: { }
|
|
79
85
|
}
|
|
@@ -94,6 +100,7 @@ test('summaryByCategoryKey', async () => {
|
|
|
94
100
|
count: 116,
|
|
95
101
|
bySection: { NO_SECTION: 116 },
|
|
96
102
|
bySelectability: { selectable: 115, not_selectable: 1 },
|
|
103
|
+
byAvailability: { available: 115, not_available: 1 },
|
|
97
104
|
byStatus: { booked: 1, free: 115 },
|
|
98
105
|
byChannel: { NO_CHANNEL: 116 },
|
|
99
106
|
byObjectType: {
|
|
@@ -105,6 +112,7 @@ test('summaryByCategoryKey', async () => {
|
|
|
105
112
|
count: 116,
|
|
106
113
|
bySection: { NO_SECTION: 116 },
|
|
107
114
|
bySelectability: { selectable: 116 },
|
|
115
|
+
byAvailability: { available: 116 },
|
|
108
116
|
byStatus: { free: 116 },
|
|
109
117
|
byChannel: { NO_CHANNEL: 116 },
|
|
110
118
|
byObjectType: {
|
|
@@ -116,6 +124,7 @@ test('summaryByCategoryKey', async () => {
|
|
|
116
124
|
count: 0,
|
|
117
125
|
bySection: {},
|
|
118
126
|
bySelectability: {},
|
|
127
|
+
byAvailability: { },
|
|
119
128
|
byStatus: {},
|
|
120
129
|
byChannel: {},
|
|
121
130
|
byObjectType: {}
|
|
@@ -137,6 +146,7 @@ test('summaryByCategoryLabel', async () => {
|
|
|
137
146
|
count: 116,
|
|
138
147
|
bySection: { NO_SECTION: 116 },
|
|
139
148
|
bySelectability: { selectable: 116 },
|
|
149
|
+
byAvailability: { available: 116 },
|
|
140
150
|
byStatus: { free: 116 },
|
|
141
151
|
byChannel: { NO_CHANNEL: 116 },
|
|
142
152
|
byObjectType: {
|
|
@@ -148,6 +158,7 @@ test('summaryByCategoryLabel', async () => {
|
|
|
148
158
|
count: 116,
|
|
149
159
|
bySection: { NO_SECTION: 116 },
|
|
150
160
|
bySelectability: { selectable: 115, not_selectable: 1 },
|
|
161
|
+
byAvailability: { available: 115, not_available: 1 },
|
|
151
162
|
byStatus: { booked: 1, free: 115 },
|
|
152
163
|
byChannel: { NO_CHANNEL: 116 },
|
|
153
164
|
byObjectType: {
|
|
@@ -159,6 +170,7 @@ test('summaryByCategoryLabel', async () => {
|
|
|
159
170
|
count: 0,
|
|
160
171
|
bySection: {},
|
|
161
172
|
bySelectability: {},
|
|
173
|
+
byAvailability: {},
|
|
162
174
|
byStatus: {},
|
|
163
175
|
byChannel: {},
|
|
164
176
|
byObjectType: {}
|
|
@@ -179,6 +191,7 @@ test('summaryBySection', async () => {
|
|
|
179
191
|
count: 232,
|
|
180
192
|
byCategoryKey: { 9: 116, 10: 116 },
|
|
181
193
|
bySelectability: { selectable: 231, not_selectable: 1 },
|
|
194
|
+
byAvailability: { available: 231, not_available: 1 },
|
|
182
195
|
byStatus: { booked: 1, free: 231 },
|
|
183
196
|
byCategoryLabel: { Cat2: 116, Cat1: 116 },
|
|
184
197
|
byChannel: { NO_CHANNEL: 232 },
|
|
@@ -190,20 +203,21 @@ test('summaryBySection', async () => {
|
|
|
190
203
|
})
|
|
191
204
|
})
|
|
192
205
|
|
|
193
|
-
test('
|
|
206
|
+
test('summaryByAvailability', async () => {
|
|
194
207
|
const { client, user } = await testUtils.createTestUserAndClient()
|
|
195
208
|
const chartKey = testUtils.getChartKey()
|
|
196
209
|
await testUtils.createTestChart(chartKey, user.secretKey)
|
|
197
210
|
const event = await client.events.create(chartKey)
|
|
198
211
|
await client.events.book(event.key, (new ObjectProperties('A-1')))
|
|
199
212
|
|
|
200
|
-
const report = await client.eventReports.
|
|
213
|
+
const report = await client.eventReports.summaryByAvailability(event.key)
|
|
201
214
|
|
|
202
215
|
expect(report).toEqual({
|
|
203
|
-
|
|
216
|
+
available: {
|
|
204
217
|
bySection: { NO_SECTION: 231 },
|
|
205
218
|
count: 231,
|
|
206
219
|
byCategoryKey: { 9: 115, 10: 116 },
|
|
220
|
+
bySelectability: { selectable: 231 },
|
|
207
221
|
byStatus: { free: 231 },
|
|
208
222
|
byCategoryLabel: { Cat2: 116, Cat1: 115 },
|
|
209
223
|
byChannel: { NO_CHANNEL: 231 },
|
|
@@ -212,10 +226,11 @@ test('summaryBySelectability', async () => {
|
|
|
212
226
|
seat: 31
|
|
213
227
|
}
|
|
214
228
|
},
|
|
215
|
-
|
|
229
|
+
not_available: {
|
|
216
230
|
bySection: { NO_SECTION: 1 },
|
|
217
231
|
count: 1,
|
|
218
232
|
byCategoryKey: { 9: 1 },
|
|
233
|
+
bySelectability: { not_selectable: 1 },
|
|
219
234
|
byStatus: { booked: 1 },
|
|
220
235
|
byCategoryLabel: { Cat1: 1 },
|
|
221
236
|
byChannel: { NO_CHANNEL: 1 },
|
|
@@ -246,6 +261,7 @@ test('summaryByChannel', async () => {
|
|
|
246
261
|
byStatus: { free: 230 },
|
|
247
262
|
byCategoryLabel: { Cat2: 116, Cat1: 114 },
|
|
248
263
|
bySelectability: { selectable: 230 },
|
|
264
|
+
byAvailability: { available: 230 },
|
|
249
265
|
byObjectType: {
|
|
250
266
|
generalAdmission: 200,
|
|
251
267
|
seat: 30
|
|
@@ -258,6 +274,7 @@ test('summaryByChannel', async () => {
|
|
|
258
274
|
byStatus: { free: 2 },
|
|
259
275
|
byCategoryLabel: { Cat1: 2 },
|
|
260
276
|
bySelectability: { selectable: 2 },
|
|
277
|
+
byAvailability: { available: 2 },
|
|
261
278
|
byObjectType: {
|
|
262
279
|
seat: 2
|
|
263
280
|
}
|
|
@@ -2,13 +2,13 @@ const Region = require('../src/Region')
|
|
|
2
2
|
const { SeatsioClient } = require('../index.js')
|
|
3
3
|
|
|
4
4
|
test('aborts eventually if server keeps returning 429', async () => {
|
|
5
|
-
const client = new SeatsioClient(new Region('https://
|
|
5
|
+
const client = new SeatsioClient(new Region('https://mockbin.org'))
|
|
6
6
|
const start = new Date()
|
|
7
7
|
try {
|
|
8
|
-
await client.client.get('/
|
|
8
|
+
await client.client.get('/bin/0381d6f4-0155-4b8c-937b-73d3d88b2a3f')
|
|
9
9
|
throw new Error('Should have failed')
|
|
10
10
|
} catch (e) {
|
|
11
|
-
expect(e).
|
|
11
|
+
expect(e).toEqual({ errors: [{ code: 'RATE_LIMIT_EXCEEDED', message: 'Rate limit exceeded' }], messages: [], requestId: '123456', status: 429 })
|
|
12
12
|
const waitTime = new Date().getTime() - start.getTime()
|
|
13
13
|
expect(waitTime).toBeGreaterThan(10000)
|
|
14
14
|
expect(waitTime).toBeLessThan(20000)
|
|
@@ -16,26 +16,26 @@ test('aborts eventually if server keeps returning 429', async () => {
|
|
|
16
16
|
})
|
|
17
17
|
|
|
18
18
|
test('aborts directly if server returns error other than 429', async () => {
|
|
19
|
-
const client = new SeatsioClient(new Region('https://
|
|
19
|
+
const client = new SeatsioClient(new Region('https://mockbin.org'))
|
|
20
20
|
const start = new Date()
|
|
21
21
|
try {
|
|
22
|
-
await client.client.get('/
|
|
22
|
+
await client.client.get('/bin/1eea3aab-2bb2-4f92-99c2-50d942fb6294')
|
|
23
23
|
throw new Error('Should have failed')
|
|
24
24
|
} catch (e) {
|
|
25
|
-
expect(e).toBe('get /
|
|
25
|
+
expect(e).toBe('get /bin/1eea3aab-2bb2-4f92-99c2-50d942fb6294 resulted in 400 Bad Request error')
|
|
26
26
|
const waitTime = new Date().getTime() - start.getTime()
|
|
27
27
|
expect(waitTime).toBeLessThan(2000)
|
|
28
28
|
}
|
|
29
29
|
})
|
|
30
30
|
|
|
31
31
|
test('aborts directly if server returns 429 but max retries 0', async () => {
|
|
32
|
-
const client = new SeatsioClient(new Region('https://
|
|
32
|
+
const client = new SeatsioClient(new Region('https://mockbin.org')).setMaxRetries(0)
|
|
33
33
|
const start = new Date()
|
|
34
34
|
try {
|
|
35
|
-
await client.client.get('/
|
|
35
|
+
await client.client.get('/bin/0381d6f4-0155-4b8c-937b-73d3d88b2a3f')
|
|
36
36
|
throw new Error('Should have failed')
|
|
37
37
|
} catch (e) {
|
|
38
|
-
expect(e).
|
|
38
|
+
expect(e).toEqual({ errors: [{ code: 'RATE_LIMIT_EXCEEDED', message: 'Rate limit exceeded' }], messages: [], requestId: '123456', status: 429 })
|
|
39
39
|
const waitTime = new Date().getTime() - start.getTime()
|
|
40
40
|
expect(waitTime).toBeLessThan(2000)
|
|
41
41
|
}
|