seatsio 63.14.0 → 65.2.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/Accounts/Accounts.js +4 -4
- package/src/Charts/ChartListParams.js +14 -2
- package/src/{Reports/ChartReportItem.js → Charts/ChartObjectInfo.js} +2 -2
- package/src/Charts/Charts.js +11 -11
- package/src/Events/ChangeObjectStatusResult.js +1 -1
- package/src/{Reports/EventReportItem.js → Events/EventObjectInfo.js} +9 -3
- package/src/Events/Events.js +64 -25
- package/src/Events/StatusChangeRequest.js +5 -1
- package/src/Reports/ChartReports.js +58 -9
- package/src/Reports/EventReports.js +44 -16
- package/src/errorInterceptor.js +1 -2
- package/src/utilities/reportUtility.js +7 -7
- package/tests/chartReports/chartReport.test.js +11 -0
- package/tests/chartReports/chartReportSummary.test.js +120 -0
- package/tests/charts/listAllCharts.test.js +26 -8
- package/tests/eventReports/eventReport.test.js +44 -14
- package/tests/eventReports/eventReportDeepSummary.test.js +19 -5
- package/tests/eventReports/eventReportSummary.test.js +117 -10
- package/tests/events/bookObject.test.js +24 -24
- package/tests/events/changeBestAvailableObjectStatus.test.js +24 -24
- package/tests/events/changeObjectStatus.test.js +55 -24
- package/tests/events/changeObjectStatusForMultipleEvents.test.js +17 -17
- package/tests/events/changeObjectStatusForMultipleObjects.test.js +31 -31
- package/tests/events/changeObjectStatusInBatch.test.js +36 -2
- package/tests/events/holdObjects.test.js +13 -13
- package/tests/events/listAllStatusChanges.test.js +2 -3
- package/tests/events/releaseObjects.test.js +16 -16
- package/tests/events/retrieveEventObjectInfo.test.js +16 -0
- package/tests/events/retrieveEventObjectInfos.test.js +30 -0
- package/tests/events/updateExtraData.test.js +2 -2
- package/tests/events/updateExtraDatas.test.js +4 -4
- package/tests/exponentialBackoff.test.js +3 -3
- package/src/Events/ObjectStatus.js +0 -20
- package/tests/events/retrieveObjectStatus.test.js +0 -16
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.2.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
|
}
|
package/src/Accounts/Accounts.js
CHANGED
|
@@ -8,28 +8,28 @@ class Accounts {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* @returns {Promise<Account>}
|
|
11
|
+
* @returns {Promise<Account>}
|
|
12
12
|
*/
|
|
13
13
|
retrieveMyAccount () {
|
|
14
14
|
return this.client.get(baseUrl).then((res) => new Account(res.data))
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
* @returns {Promise<string>}
|
|
18
|
+
* @returns {Promise<string>}
|
|
19
19
|
*/
|
|
20
20
|
regenerateSecretKey () {
|
|
21
21
|
return this.client.post(baseUrl + '/secret-key/actions/regenerate').then((res) => res.data.secretKey)
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
|
-
* @returns {Promise<string>}
|
|
25
|
+
* @returns {Promise<string>}
|
|
26
26
|
*/
|
|
27
27
|
regenerateDesignerKey () {
|
|
28
28
|
return this.client.post(baseUrl + '/designer-key/actions/regenerate').then((res) => res.data.designerKey)
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
|
-
* @returns {Promise}
|
|
32
|
+
* @returns {Promise}
|
|
33
33
|
*/
|
|
34
34
|
enableDraftChartDrawings () {
|
|
35
35
|
return this.client.post(baseUrl + '/draft-chart-drawings/actions/enable')
|
|
@@ -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
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const helperFunctions = require('../utilities/helperFunctions.js')
|
|
2
2
|
const { IDs } = require('../Common/IDs')
|
|
3
3
|
|
|
4
|
-
class
|
|
4
|
+
class ChartObjectInfo {
|
|
5
5
|
/**
|
|
6
6
|
* @param {object} chartReport
|
|
7
7
|
*/
|
|
@@ -22,4 +22,4 @@ class ChartReportItem {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
module.exports =
|
|
25
|
+
module.exports = ChartObjectInfo
|
package/src/Charts/Charts.js
CHANGED
|
@@ -19,7 +19,7 @@ class Charts {
|
|
|
19
19
|
* @param {?string} name
|
|
20
20
|
* @param {?string} venueType
|
|
21
21
|
* @param {?Object[]} categories
|
|
22
|
-
* @returns {Promise<Chart>}
|
|
22
|
+
* @returns {Promise<Chart>}
|
|
23
23
|
*/
|
|
24
24
|
create (name = null, venueType = null, categories = null) {
|
|
25
25
|
const requestParameters = {}
|
|
@@ -80,7 +80,7 @@ class Charts {
|
|
|
80
80
|
|
|
81
81
|
/**
|
|
82
82
|
* @param {string} key
|
|
83
|
-
* @returns {Promise<Chart>}
|
|
83
|
+
* @returns {Promise<Chart>}
|
|
84
84
|
*/
|
|
85
85
|
retrieve (key) {
|
|
86
86
|
return this.client.get(`charts/${key}`)
|
|
@@ -89,7 +89,7 @@ class Charts {
|
|
|
89
89
|
|
|
90
90
|
/**
|
|
91
91
|
* @param {string} key
|
|
92
|
-
* @returns {Promise<Chart>}
|
|
92
|
+
* @returns {Promise<Chart>}
|
|
93
93
|
*/
|
|
94
94
|
retrieveWithEvents (key) {
|
|
95
95
|
return this.client.get(`charts/${key}?expand=events`)
|
|
@@ -98,7 +98,7 @@ class Charts {
|
|
|
98
98
|
|
|
99
99
|
/**
|
|
100
100
|
* @param {string} key
|
|
101
|
-
* @returns {Promise}
|
|
101
|
+
* @returns {Promise}
|
|
102
102
|
*/
|
|
103
103
|
retrievePublishedVersion (key) {
|
|
104
104
|
return this.client.get(`charts/${key}/version/published`)
|
|
@@ -107,7 +107,7 @@ class Charts {
|
|
|
107
107
|
|
|
108
108
|
/**
|
|
109
109
|
* @param {string} key
|
|
110
|
-
* @returns {Promise}
|
|
110
|
+
* @returns {Promise}
|
|
111
111
|
*/
|
|
112
112
|
retrieveDraftVersion (key) {
|
|
113
113
|
return this.client.get(`charts/${key}/version/draft`)
|
|
@@ -148,7 +148,7 @@ class Charts {
|
|
|
148
148
|
|
|
149
149
|
/**
|
|
150
150
|
* @param {string} key
|
|
151
|
-
* @returns {Promise<Chart>}
|
|
151
|
+
* @returns {Promise<Chart>}
|
|
152
152
|
*/
|
|
153
153
|
copy (key) {
|
|
154
154
|
return this.client.post(`charts/${key}/version/published/actions/copy`)
|
|
@@ -157,7 +157,7 @@ class Charts {
|
|
|
157
157
|
|
|
158
158
|
/**
|
|
159
159
|
* @param {string} key
|
|
160
|
-
* @returns {Promise<Chart>}
|
|
160
|
+
* @returns {Promise<Chart>}
|
|
161
161
|
*/
|
|
162
162
|
copyDraftVersion (key) {
|
|
163
163
|
return this.client.post(`charts/${key}/version/draft/actions/copy`)
|
|
@@ -166,7 +166,7 @@ class Charts {
|
|
|
166
166
|
|
|
167
167
|
/**
|
|
168
168
|
* @param {string} key
|
|
169
|
-
* @returns {Promise<Chart>}
|
|
169
|
+
* @returns {Promise<Chart>}
|
|
170
170
|
*/
|
|
171
171
|
copyToSubaccount (key, subaccountId) {
|
|
172
172
|
return this.client.post(`charts/${key}/version/published/actions/copy-to/${subaccountId}`)
|
|
@@ -176,7 +176,7 @@ class Charts {
|
|
|
176
176
|
/**
|
|
177
177
|
* @param {string} key
|
|
178
178
|
* @params {string} workspaceKey
|
|
179
|
-
* @returns {Promise<Chart>}
|
|
179
|
+
* @returns {Promise<Chart>}
|
|
180
180
|
*/
|
|
181
181
|
copyToWorkspace (key, workspaceKey) {
|
|
182
182
|
return this.client.post(`charts/${key}/version/published/actions/copy-to-workspace/${workspaceKey}`)
|
|
@@ -193,7 +193,7 @@ class Charts {
|
|
|
193
193
|
|
|
194
194
|
/**
|
|
195
195
|
* @param {string} key
|
|
196
|
-
* @returns {Promise}
|
|
196
|
+
* @returns {Promise}
|
|
197
197
|
*/
|
|
198
198
|
retrievePublishedVersionThumbnail (key) {
|
|
199
199
|
return this.client.get(`/charts/${key}/version/published/thumbnail`, { responseType: 'arraybuffer' })
|
|
@@ -202,7 +202,7 @@ class Charts {
|
|
|
202
202
|
|
|
203
203
|
/**
|
|
204
204
|
* @param {string} key
|
|
205
|
-
* @returns {Promise}
|
|
205
|
+
* @returns {Promise}
|
|
206
206
|
*/
|
|
207
207
|
retrieveDraftVersionThumbnail (key) {
|
|
208
208
|
return this.client.get(`/charts/${key}/version/draft/thumbnail`, { responseType: 'arraybuffer' })
|
|
@@ -2,7 +2,7 @@ const utilities = require('../utilities/reportUtility.js')
|
|
|
2
2
|
|
|
3
3
|
class ChangeObjectStatusResult {
|
|
4
4
|
/**
|
|
5
|
-
* @param {Object.<string, {
|
|
5
|
+
* @param {Object.<string, {ObjectInfo}>} objects
|
|
6
6
|
*/
|
|
7
7
|
constructor (objects) {
|
|
8
8
|
this.objects = utilities.createChangeObjectStatusDetails(objects)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const helperFunctions = require('../utilities/helperFunctions.js')
|
|
2
2
|
const { IDs } = require('../Common/IDs')
|
|
3
3
|
|
|
4
|
-
class
|
|
4
|
+
class EventObjectInfo {
|
|
5
5
|
/**
|
|
6
6
|
* @param {object} report
|
|
7
7
|
*/
|
|
@@ -31,11 +31,17 @@ class EventReportItem {
|
|
|
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
|
|
39
|
+
this.holds = report.holds
|
|
38
40
|
}
|
|
39
41
|
}
|
|
40
42
|
|
|
41
|
-
|
|
43
|
+
EventObjectInfo.FREE = 'free'
|
|
44
|
+
EventObjectInfo.BOOKED = 'booked'
|
|
45
|
+
EventObjectInfo.HELD = 'reservedByToken'
|
|
46
|
+
|
|
47
|
+
module.exports = EventObjectInfo
|
package/src/Events/Events.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const Page = require('../Page.js')
|
|
2
2
|
const Lister = require('../Lister.js')
|
|
3
|
-
const
|
|
3
|
+
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')
|
|
@@ -20,7 +20,7 @@ class Events {
|
|
|
20
20
|
* @param {?string} eventKey
|
|
21
21
|
* @param {?TableBookingConfig} tableBookingConfig
|
|
22
22
|
* @param {?string} socialDistancingRulesetKey
|
|
23
|
-
* @returns {Promise<Event>}
|
|
23
|
+
* @returns {Promise<Event>}
|
|
24
24
|
*/
|
|
25
25
|
create (chartKey, eventKey = null, tableBookingConfig = null, socialDistancingRulesetKey = null) {
|
|
26
26
|
const requestParameters = {}
|
|
@@ -45,7 +45,7 @@ class Events {
|
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
47
|
* @param {string} eventKey
|
|
48
|
-
* @returns {Promise<Event>}
|
|
48
|
+
* @returns {Promise<Event>}
|
|
49
49
|
*/
|
|
50
50
|
retrieve (eventKey) {
|
|
51
51
|
return this.client.get(`/events/${encodeURIComponent(eventKey)}`)
|
|
@@ -233,12 +233,32 @@ class Events {
|
|
|
233
233
|
|
|
234
234
|
/**
|
|
235
235
|
* @param {string} eventKey
|
|
236
|
-
* @param {string}
|
|
237
|
-
* @returns {Promise<
|
|
236
|
+
* @param {string} label
|
|
237
|
+
* @returns {Promise<EventObjectInfo>}
|
|
238
238
|
*/
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
239
|
+
async retrieveObjectInfo (eventKey, label) {
|
|
240
|
+
const result = await this.retrieveObjectInfos(eventKey, [label])
|
|
241
|
+
return result[label]
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* @param {string} eventKey
|
|
246
|
+
* @param {string[]} labels
|
|
247
|
+
* @returns {Promise<Map<String, EventObjectInfo>>}
|
|
248
|
+
*/
|
|
249
|
+
retrieveObjectInfos (eventKey, labels) {
|
|
250
|
+
const params = new URLSearchParams()
|
|
251
|
+
labels.forEach(label => {
|
|
252
|
+
params.append('label', label)
|
|
253
|
+
})
|
|
254
|
+
return this.client.get(`events/${encodeURIComponent(eventKey)}/objects`, { params })
|
|
255
|
+
.then((res) => {
|
|
256
|
+
const objectInfos = res.data
|
|
257
|
+
for (const key of Object.keys(objectInfos)) {
|
|
258
|
+
objectInfos[key] = new EventObjectInfo(objectInfos[key])
|
|
259
|
+
}
|
|
260
|
+
return objectInfos
|
|
261
|
+
})
|
|
242
262
|
}
|
|
243
263
|
|
|
244
264
|
/**
|
|
@@ -251,13 +271,15 @@ class Events {
|
|
|
251
271
|
* @param {?boolean} ignoreChannels
|
|
252
272
|
* @param {?string[]} channelKeys
|
|
253
273
|
* @param {?boolean} ignoreSocialDistancing
|
|
254
|
-
* @returns {Promise<ChangeObjectStatusResult>}
|
|
274
|
+
* @returns {Promise<ChangeObjectStatusResult>}
|
|
275
|
+
* @param {?string[]} allowedPreviousStatuses
|
|
276
|
+
* @param {?string[]} rejectedPreviousStatuses
|
|
255
277
|
*/
|
|
256
|
-
changeObjectStatus (eventKeyOrKeys, objectOrObjects, status, holdToken = null, orderId = null, keepExtraData = null, ignoreChannels = null, channelKeys = null, ignoreSocialDistancing = null) {
|
|
257
|
-
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)
|
|
258
280
|
request.events = Array.isArray(eventKeyOrKeys) ? eventKeyOrKeys : [eventKeyOrKeys]
|
|
259
281
|
|
|
260
|
-
return this.client.post('/
|
|
282
|
+
return this.client.post('/events/groups/actions/change-object-status?expand=objects', request)
|
|
261
283
|
.then((res) => new ChangeObjectStatusResult(res.data.objects))
|
|
262
284
|
}
|
|
263
285
|
|
|
@@ -267,7 +289,18 @@ class Events {
|
|
|
267
289
|
*/
|
|
268
290
|
changeObjectStatusInBatch (statusChangeRequests) {
|
|
269
291
|
const requests = statusChangeRequests.map(r => {
|
|
270
|
-
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
|
+
)
|
|
271
304
|
json.event = r.eventKey
|
|
272
305
|
return json
|
|
273
306
|
})
|
|
@@ -277,7 +310,7 @@ class Events {
|
|
|
277
310
|
.then((res) => res.data.results.map(r => new ChangeObjectStatusResult(r.objects)))
|
|
278
311
|
}
|
|
279
312
|
|
|
280
|
-
changeObjectStatusRequest (objectOrObjects, status, holdToken, orderId, keepExtraData, ignoreChannels, channelKeys, ignoreSocialDistancing) {
|
|
313
|
+
changeObjectStatusRequest (objectOrObjects, status, holdToken, orderId, keepExtraData, ignoreChannels, channelKeys, ignoreSocialDistancing, allowedPreviousStatuses, rejectedPreviousStatuses) {
|
|
281
314
|
const request = {}
|
|
282
315
|
request.objects = this.normalizeObjects(objectOrObjects)
|
|
283
316
|
request.status = status
|
|
@@ -299,6 +332,12 @@ class Events {
|
|
|
299
332
|
if (ignoreSocialDistancing !== null) {
|
|
300
333
|
request.ignoreSocialDistancing = ignoreSocialDistancing
|
|
301
334
|
}
|
|
335
|
+
if (allowedPreviousStatuses !== null) {
|
|
336
|
+
request.allowedPreviousStatuses = allowedPreviousStatuses
|
|
337
|
+
}
|
|
338
|
+
if (rejectedPreviousStatuses !== null) {
|
|
339
|
+
request.rejectedPreviousStatuses = rejectedPreviousStatuses
|
|
340
|
+
}
|
|
302
341
|
return request
|
|
303
342
|
}
|
|
304
343
|
|
|
@@ -311,10 +350,10 @@ class Events {
|
|
|
311
350
|
* @param {?boolean} ignoreChannels
|
|
312
351
|
* @param {?string[]} channelKeys
|
|
313
352
|
* @param {?boolean} ignoreSocialDistancing
|
|
314
|
-
* @returns {Promise<ChangeObjectStatusResult>}
|
|
353
|
+
* @returns {Promise<ChangeObjectStatusResult>}
|
|
315
354
|
*/
|
|
316
355
|
book (eventKeyOrKeys, objectOrObjects, holdToken = null, orderId = null, keepExtraData = null, ignoreChannels = null, channelKeys = null, ignoreSocialDistancing = null) {
|
|
317
|
-
return this.changeObjectStatus(eventKeyOrKeys, objectOrObjects,
|
|
356
|
+
return this.changeObjectStatus(eventKeyOrKeys, objectOrObjects, EventObjectInfo.BOOKED, holdToken, orderId, keepExtraData, ignoreChannels, channelKeys, ignoreSocialDistancing)
|
|
318
357
|
}
|
|
319
358
|
|
|
320
359
|
/**
|
|
@@ -328,10 +367,10 @@ class Events {
|
|
|
328
367
|
* @param {?boolean} keepExtraData
|
|
329
368
|
* @param {?boolean} ignoreChannels
|
|
330
369
|
* @param {?string[]} channelKeys
|
|
331
|
-
* @returns {Promise<BestAvailableObjects>}
|
|
370
|
+
* @returns {Promise<BestAvailableObjects>}
|
|
332
371
|
*/
|
|
333
372
|
bookBestAvailable (eventKey, number, categories = null, holdToken = null, extraData = null, ticketTypes = null, orderId = null, keepExtraData = null, ignoreChannels = null, channelKeys = null) {
|
|
334
|
-
return this.changeBestAvailableObjectStatus(encodeURIComponent(eventKey), number,
|
|
373
|
+
return this.changeBestAvailableObjectStatus(encodeURIComponent(eventKey), number, EventObjectInfo.BOOKED, categories, holdToken, extraData, ticketTypes, orderId, keepExtraData, ignoreChannels, channelKeys)
|
|
335
374
|
}
|
|
336
375
|
|
|
337
376
|
/**
|
|
@@ -342,10 +381,10 @@ class Events {
|
|
|
342
381
|
* @param {?boolean} keepExtraData
|
|
343
382
|
* @param {?boolean} ignoreChannels
|
|
344
383
|
* @param {?string[]} channelKeys
|
|
345
|
-
* @returns {Promise<ChangeObjectStatusResult>}
|
|
384
|
+
* @returns {Promise<ChangeObjectStatusResult>}
|
|
346
385
|
*/
|
|
347
386
|
release (eventKeyOrKeys, objectOrObjects, holdToken = null, orderId = null, keepExtraData = null, ignoreChannels = null, channelKeys = null) {
|
|
348
|
-
return this.changeObjectStatus(eventKeyOrKeys, objectOrObjects,
|
|
387
|
+
return this.changeObjectStatus(eventKeyOrKeys, objectOrObjects, EventObjectInfo.FREE, holdToken, orderId, keepExtraData, ignoreChannels, channelKeys)
|
|
349
388
|
}
|
|
350
389
|
|
|
351
390
|
/**
|
|
@@ -357,10 +396,10 @@ class Events {
|
|
|
357
396
|
* @param {?boolean} ignoreChannels
|
|
358
397
|
* @param {?string[]} channelKeys
|
|
359
398
|
* @param {?boolean} ignoreSocialDistancing
|
|
360
|
-
* @returns {Promise<ChangeObjectStatusResult>}
|
|
399
|
+
* @returns {Promise<ChangeObjectStatusResult>}
|
|
361
400
|
*/
|
|
362
401
|
hold (eventKeyOrKeys, objectOrObjects, holdToken, orderId = null, keepExtraData = null, ignoreChannels = null, channelKeys = null, ignoreSocialDistancing = null) {
|
|
363
|
-
return this.changeObjectStatus(eventKeyOrKeys, objectOrObjects,
|
|
402
|
+
return this.changeObjectStatus(eventKeyOrKeys, objectOrObjects, EventObjectInfo.HELD, holdToken, orderId, keepExtraData, ignoreChannels, channelKeys, ignoreSocialDistancing)
|
|
364
403
|
}
|
|
365
404
|
|
|
366
405
|
/**
|
|
@@ -375,10 +414,10 @@ class Events {
|
|
|
375
414
|
* @param {?boolean} ignoreChannels
|
|
376
415
|
* @param {?string[]} channelKeys
|
|
377
416
|
* @param {?string[]} ticketTypes
|
|
378
|
-
* @returns {Promise<BestAvailableObjects>}
|
|
417
|
+
* @returns {Promise<BestAvailableObjects>}
|
|
379
418
|
*/
|
|
380
419
|
holdBestAvailable (eventKey, number, holdToken, categories = null, extraData = null, ticketTypes = null, orderId = null, keepExtraData = null, ignoreChannels = null, channelKeys = null) {
|
|
381
|
-
return this.changeBestAvailableObjectStatus(encodeURIComponent(eventKey), number,
|
|
420
|
+
return this.changeBestAvailableObjectStatus(encodeURIComponent(eventKey), number, EventObjectInfo.HELD, categories, holdToken, extraData, ticketTypes, orderId, keepExtraData, ignoreChannels, channelKeys)
|
|
382
421
|
}
|
|
383
422
|
|
|
384
423
|
/**
|
|
@@ -393,7 +432,7 @@ class Events {
|
|
|
393
432
|
* @param {?boolean} keepExtraData
|
|
394
433
|
* @param {?boolean} ignoreChannels
|
|
395
434
|
* @param {?string[]} channelKeys
|
|
396
|
-
* @returns {Promise<BestAvailableObjects>}
|
|
435
|
+
* @returns {Promise<BestAvailableObjects>}
|
|
397
436
|
*/
|
|
398
437
|
changeBestAvailableObjectStatus (eventKey, number, status, categories = null, holdToken = null, extraData = null, ticketTypes = null, orderId = null, keepExtraData = null, ignoreChannels = null, channelKeys = null) {
|
|
399
438
|
const requestParameters = {}
|
|
@@ -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
|
|