seatsio 67.1.0 → 67.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "seatsio",
3
- "version": "67.1.0",
3
+ "version": "67.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",
@@ -16,11 +16,20 @@ class Event {
16
16
  this.updatedOn = event.updatedOn ? new Date(event.updatedOn) : null
17
17
  this.channels = event.channels ? event.channels.map(c => new Channel(c)) : null
18
18
  this.socialDistancingRulesetKey = event.socialDistancingRulesetKey
19
+ this.seasonKey = event.season ? event.season.key : null
19
20
  }
20
21
 
21
22
  isSeason () {
22
23
  return false
23
24
  }
25
+
26
+ isTopLevelSeason () {
27
+ return false
28
+ }
29
+
30
+ isPartialSeason () {
31
+ return false
32
+ }
24
33
  }
25
34
 
26
35
  module.exports = Event
@@ -8,11 +8,22 @@ class Season extends Event {
8
8
  super(season)
9
9
  this.partialSeasonKeys = season.partialSeasonKeys
10
10
  this.events = season.events ? season.events.map(e => new Event(e)) : undefined
11
+ if (this.isTopLevelSeason()) {
12
+ this.seasonKey = undefined
13
+ }
11
14
  }
12
15
 
13
16
  isSeason () {
14
17
  return true
15
18
  }
19
+
20
+ isTopLevelSeason () {
21
+ return this.partialSeasonKeys !== undefined
22
+ }
23
+
24
+ isPartialSeason () {
25
+ return !this.isTopLevelSeason()
26
+ }
16
27
  }
17
28
 
18
29
  module.exports = Season
@@ -1,6 +1,6 @@
1
1
  const testUtils = require('../testUtils.js')
2
2
  const TableBookingConfig = require('../../src/Events/TableBookingConfig')
3
- const SeasonParams = require("../../src/Seasons/SeasonParams");
3
+ const SeasonParams = require('../../src/Seasons/SeasonParams')
4
4
 
5
5
  test('should retrieve event', async () => {
6
6
  const { client, user } = await testUtils.createTestUserAndClient()
@@ -20,6 +20,7 @@ test('should retrieve event', async () => {
20
20
  expect(retrievedEvent.createdOn.getTime()).toBeLessThanOrEqual(now.getTime() + 5000)
21
21
  expect(retrievedEvent.forSaleConfig).toBeFalsy()
22
22
  expect(retrievedEvent.updatedOn).toBeNull()
23
+ expect(retrievedEvent.seasonKey).toBeNull()
23
24
  })
24
25
 
25
26
  test('retrieve season', async () => {
@@ -32,6 +33,8 @@ test('retrieve season', async () => {
32
33
 
33
34
  const retrievedSeason = await client.events.retrieve(season.key)
34
35
 
36
+ expect(retrievedSeason.isSeason()).toBe(true)
37
+ expect(retrievedSeason.isTopLevelSeason()).toBe(true)
35
38
  expect(retrievedSeason.key).toBeTruthy()
36
39
  expect(retrievedSeason.id).toBeTruthy()
37
40
  expect(retrievedSeason.partialSeasonKeys).toEqual([partialSeason1.key, partialSeason2.key])
@@ -42,4 +45,42 @@ test('retrieve season', async () => {
42
45
  expect(retrievedSeason.createdOn).toBeInstanceOf(Date)
43
46
  expect(retrievedSeason.forSaleConfig).toBeFalsy()
44
47
  expect(retrievedSeason.updatedOn).toBeFalsy()
48
+ expect(retrievedSeason.seasonKey).toBe(undefined)
49
+ })
50
+
51
+ test('retrieve partial season', async () => {
52
+ const { client, user } = await testUtils.createTestUserAndClient()
53
+ const chartKey = testUtils.getChartKey()
54
+ await testUtils.createTestChart(chartKey, user.secretKey)
55
+ const season = await client.seasons.create(chartKey, new SeasonParams().eventKeys(['event1', 'event2']))
56
+ const partialSeason1 = await client.seasons.createPartialSeason(season.key, null, ['event1', 'event2'])
57
+ const partialSeason2 = await client.seasons.createPartialSeason(season.key)
58
+
59
+ const retrievedSeason = await client.events.retrieve(partialSeason1.key)
60
+
61
+ expect(retrievedSeason.isSeason()).toBe(true)
62
+ expect(retrievedSeason.isPartialSeason()).toBe(true)
63
+ expect(retrievedSeason.key).toBeTruthy()
64
+ expect(retrievedSeason.id).toBeTruthy()
65
+ expect(retrievedSeason.partialSeasonKeys).toBe(undefined)
66
+ expect(retrievedSeason.events.map(e => e.key)).toEqual(['event1', 'event2'])
67
+ expect(retrievedSeason.chartKey).toBe(chartKey)
68
+ expect(retrievedSeason.tableBookingConfig).toEqual(TableBookingConfig.inherit())
69
+ expect(retrievedSeason.supportsBestAvailable).toBe(true)
70
+ expect(retrievedSeason.createdOn).toBeInstanceOf(Date)
71
+ expect(retrievedSeason.forSaleConfig).toBeFalsy()
72
+ expect(retrievedSeason.updatedOn).toBeFalsy()
73
+ expect(retrievedSeason.seasonKey).toBe(season.key)
74
+ })
75
+
76
+ test('retrieve event in season', async () => {
77
+ const { client, user } = await testUtils.createTestUserAndClient()
78
+ const chartKey = testUtils.getChartKey()
79
+ await testUtils.createTestChart(chartKey, user.secretKey)
80
+ const season = await client.seasons.create(chartKey, new SeasonParams().eventKeys(['event1', 'event2']))
81
+
82
+ const retrievedEvent = await client.events.retrieve('event1')
83
+
84
+ expect(retrievedEvent.isSeason()).toBe(false)
85
+ expect(retrievedEvent.seasonKey).toBe(season.key)
45
86
  })