seatsio 67.7.0 → 67.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "seatsio",
3
- "version": "67.7.0",
3
+ "version": "67.8.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",
@@ -60,6 +60,14 @@ class Charts {
60
60
  return this.client.post(`/charts/${key}`, requestParameters)
61
61
  }
62
62
 
63
+ addCategory (key, category) {
64
+ return this.client.post(`/charts/${key}/categories`, category)
65
+ }
66
+
67
+ removeCategory (chartKey, categoryKey) {
68
+ return this.client.delete(`/charts/${chartKey}/categories/${categoryKey}`)
69
+ }
70
+
63
71
  /**
64
72
  * @param {string} key
65
73
  * @returns {object}
@@ -0,0 +1,32 @@
1
+ const testUtils = require('../testUtils.js')
2
+
3
+ test('should add a category', async () => {
4
+ const { client } = await testUtils.createTestUserAndClient()
5
+ const categories = [
6
+ { key: 1, label: 'Category 1', color: '#aaaaaa', accessible: false }
7
+ ]
8
+ const chart = await client.charts.create(null, null, categories)
9
+
10
+ await client.charts.addCategory(chart.key, { key: 2, label: 'Category 2', color: '#bbbbbb', accessible: true })
11
+
12
+ const expectedCategories = [
13
+ { key: 1, label: 'Category 1', color: '#aaaaaa', accessible: false },
14
+ { key: 2, label: 'Category 2', color: '#bbbbbb', accessible: true }
15
+ ]
16
+ const retrievedChart = await client.charts.retrievePublishedVersion(chart.key)
17
+ expect(retrievedChart.categories.list).toEqual(expectedCategories)
18
+ })
19
+
20
+ test('should remove a category', async () => {
21
+ const { client } = await testUtils.createTestUserAndClient()
22
+ const categories = [
23
+ { key: 1, label: 'Category 1', color: '#aaaaaa', accessible: false },
24
+ { key: 'cat2', label: 'Category 2', color: '#bbbbbb', accessible: true }
25
+ ]
26
+ const chart = await client.charts.create('aChart', null, categories)
27
+
28
+ await client.charts.removeCategory(chart.key, 'cat2')
29
+
30
+ const retrievedChart = await client.charts.retrievePublishedVersion(chart.key)
31
+ expect(retrievedChart.categories.list).toEqual([{ key: 1, label: 'Category 1', color: '#aaaaaa', accessible: false }])
32
+ })