seatsio 72.3.0 → 72.4.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 CHANGED
@@ -256,6 +256,18 @@ let event = await client.events.create(chart.key)
256
256
  console.log(`Created a chart with key ${chart.key} and an event with key: ${event.key}`)
257
257
  ```
258
258
 
259
+ ### Listing categories
260
+
261
+ ```js
262
+ import { SeatsioClient, Region } from 'seatsio'
263
+
264
+ let client = new SeatsioClient(Region.EU(), <COMPANY ADMIN KEY>, <WORKSPACE PUBLIC KEY>)
265
+ let categories = await client.charts.listCategories("the chart key")
266
+ for (const category of categoryList) {
267
+ console.log(category.label)
268
+ }
269
+ ```
270
+
259
271
  ## Error Handling
260
272
  When an API call results in an error, a rejected promise is returned with a value that looks like
261
273
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "seatsio",
3
- "version": "72.3.0",
3
+ "version": "72.4.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",
@@ -13,16 +13,16 @@
13
13
  "url": "https://github.com/seatsio/seatsio-js"
14
14
  },
15
15
  "dependencies": {
16
- "axios": "1.3.0"
16
+ "axios": "1.3.4"
17
17
  },
18
18
  "devDependencies": {
19
- "eslint": "8.33.0",
19
+ "eslint": "8.35.0",
20
20
  "eslint-config-standard": "17.0.0",
21
21
  "eslint-plugin-import": "2.27.5",
22
22
  "eslint-plugin-n": "15.6.1",
23
23
  "eslint-plugin-promise": "6.1.1",
24
- "jest": "29.4.1",
25
- "jest-cli": "29.4.1",
24
+ "jest": "29.4.3",
25
+ "jest-cli": "29.4.3",
26
26
  "uuid": "9.0.0"
27
27
  }
28
28
  }
@@ -68,6 +68,11 @@ class Charts {
68
68
  return this.client.delete(`/charts/${chartKey}/categories/${categoryKey}`)
69
69
  }
70
70
 
71
+ listCategories (key) {
72
+ return this.client.get(`/charts/${key}/categories`)
73
+ .then((res) => res.data.categories)
74
+ }
75
+
71
76
  /**
72
77
  * @param {string} key
73
78
  * @returns {object}
@@ -30,3 +30,15 @@ test('should remove a category', async () => {
30
30
  const retrievedChart = await client.charts.retrievePublishedVersion(chart.key)
31
31
  expect(retrievedChart.categories.list).toEqual([{ key: 1, label: 'Category 1', color: '#aaaaaa', accessible: false }])
32
32
  })
33
+
34
+ test('should retrieve the categories of a chart', async () => {
35
+ const { client } = await testUtils.createTestUserAndClient()
36
+ const categories = [
37
+ { key: 1, label: 'Category 1', color: '#aaaaaa', accessible: false },
38
+ { key: 'cat2', label: 'Category 2', color: '#bbbbbb', accessible: true }
39
+ ]
40
+ const chart = await client.charts.create('aChart', null, categories)
41
+
42
+ const categoryList = await client.charts.listCategories(chart.key)
43
+ expect(categoryList).toEqual(categories)
44
+ })
@@ -21,13 +21,13 @@ test('should filter subaccounts ', async () => {
21
21
  test('should filter subaccounts with special characters', async () => {
22
22
  const { client } = await testUtils.createTestUserAndClient()
23
23
  let i = 0
24
- await testUtils.createArray(20, () => client.subaccounts.create('test-/@/' + i++))
24
+ await testUtils.createArray(10, () => client.subaccounts.create('test-/@/' + i++))
25
25
  const retrievedSubaccountKeys = []
26
26
  for await (const subaccount of client.subaccounts.listAll('test-/@/1')) {
27
27
  retrievedSubaccountKeys.push(subaccount.secretKey)
28
28
  }
29
29
 
30
- expect(retrievedSubaccountKeys.length).toEqual(11)
30
+ expect(retrievedSubaccountKeys.length).toEqual(1)
31
31
  })
32
32
 
33
33
  test('should filter with no results ', async () => {
@@ -81,14 +81,14 @@ module.exports = {
81
81
  return uuidv4() + '@mailinator.com'
82
82
  },
83
83
 
84
- createArray (length, fn) {
84
+ async createArray (length, fn) {
85
85
  const array = []
86
86
 
87
87
  for (let i = 0; i < length; ++i) {
88
- array.push(fn())
88
+ array.push(await fn())
89
89
  }
90
90
 
91
- return Promise.all(array)
91
+ return array
92
92
  },
93
93
 
94
94
  deferred () {