lib/seatsio/domain.rb in seatsio-35.3.0 vs lib/seatsio/domain.rb in seatsio-36.0.0
- old
+ new
@@ -20,23 +20,23 @@
@events = Event.create_list(data['events']) if data['events']
@tags = data['tags']
@archived = data['archived']
@validation = data['validation']
@social_distancing_rulesets = data['socialDistancingRulesets'].map {
- |key, r| [key, SocialDistancingRuleset.new(r['name'],
- number_of_disabled_seats_to_the_sides: r['numberOfDisabledSeatsToTheSides'],
- disable_seats_in_front_and_behind: r['disableSeatsInFrontAndBehind'],
- disable_diagonal_seats_in_front_and_behind: r['disableDiagonalSeatsInFrontAndBehind'],
- number_of_disabled_aisle_seats: r['numberOfDisabledAisleSeats'],
- max_group_size: r['maxGroupSize'],
- max_occupancy_absolute: r['maxOccupancyAbsolute'],
- max_occupancy_percentage: r['maxOccupancyPercentage'],
- one_group_per_table: r['oneGroupPerTable'],
- fixed_group_layout: r['fixedGroupLayout'],
- disabled_seats: r['disabledSeats'],
- enabled_seats: r['enabledSeats'],
- index: r['index'])]
+ |key, r| [key, SocialDistancingRuleset.new(r['name'],
+ number_of_disabled_seats_to_the_sides: r['numberOfDisabledSeatsToTheSides'],
+ disable_seats_in_front_and_behind: r['disableSeatsInFrontAndBehind'],
+ disable_diagonal_seats_in_front_and_behind: r['disableDiagonalSeatsInFrontAndBehind'],
+ number_of_disabled_aisle_seats: r['numberOfDisabledAisleSeats'],
+ max_group_size: r['maxGroupSize'],
+ max_occupancy_absolute: r['maxOccupancyAbsolute'],
+ max_occupancy_percentage: r['maxOccupancyPercentage'],
+ one_group_per_table: r['oneGroupPerTable'],
+ fixed_group_layout: r['fixedGroupLayout'],
+ disabled_seats: r['disabledSeats'],
+ enabled_seats: r['enabledSeats'],
+ index: r['index'])]
}.to_h
end
end
class ChartValidationResult
@@ -113,14 +113,14 @@
@objects = objects
end
def == (other)
self.key == other.key &&
- self.name == other.name &&
- self.color == other.color &&
- self.index == other.index &&
- self.objects == other.objects
+ self.name == other.name &&
+ self.color == other.color &&
+ self.index == other.index &&
+ self.objects == other.objects
end
end
class Event
@@ -137,26 +137,53 @@
@table_booking_config = TableBookingConfig::from_json(data['tableBookingConfig'])
@for_sale_config = ForSaleConfig.new(data['forSaleConfig']) if data['forSaleConfig']
@created_on = parse_date(data['createdOn'])
@updated_on = parse_date(data['updatedOn'])
@channels = data['channels'].map {
- |d| Channel.new(d['key'], d['name'], d['color'], d['index'], d['objects'])
+ |d| Channel.new(d['key'], d['name'], d['color'], d['index'], d['objects'])
} if data['channels']
@social_distancing_ruleset_key = data['socialDistancingRulesetKey']
end
+ def is_season
+ false
+ end
+
+ def self.from_json(data)
+ if data['isSeason']
+ Season.new(data)
+ else
+ Event.new(data)
+ end
+ end
+
def self.create_list(list = [])
result = []
list.each do |item|
- result << Event.new(item)
+ result << Event.from_json(item)
end
- return result
+ result
end
end
+ class Season < Event
+
+ attr_accessor :partial_season_keys, :events
+
+ def initialize(data)
+ super(data)
+ @partial_season_keys = data['partialSeasonKeys']
+ @events = data['events'] ? Event.create_list(data['events']) : nil
+ end
+
+ def is_season
+ true
+ end
+ end
+
class Events
attr_accessor :events
def initialize(data)
@events = Event.create_list(data['events']) if data['events']
@@ -519,44 +546,44 @@
@enabled_seats = enabled_seats
@index = index
end
def self.fixed(name, disabled_seats: [], index: 0)
- return SocialDistancingRuleset.new(name, index: index, disabled_seats: disabled_seats, fixed_group_layout: true)
+ SocialDistancingRuleset.new(name, index: index, disabled_seats: disabled_seats, fixed_group_layout: true)
end
def self.rule_based(name, number_of_disabled_seats_to_the_sides: 0, disable_seats_in_front_and_behind: false, disable_diagonal_seats_in_front_and_behind: false,
number_of_disabled_aisle_seats: 0, max_group_size: 0, max_occupancy_absolute: 0, max_occupancy_percentage: 0, one_group_per_table: false,
disabled_seats: [], enabled_seats: [], index: 0)
- return SocialDistancingRuleset.new(name,
- number_of_disabled_seats_to_the_sides: number_of_disabled_seats_to_the_sides,
- disable_seats_in_front_and_behind: disable_seats_in_front_and_behind,
- disable_diagonal_seats_in_front_and_behind: disable_diagonal_seats_in_front_and_behind,
- number_of_disabled_aisle_seats: number_of_disabled_aisle_seats,
- max_group_size: max_group_size,
- max_occupancy_absolute: max_occupancy_absolute,
- max_occupancy_percentage: max_occupancy_percentage,
- one_group_per_table: one_group_per_table,
- fixed_group_layout: false,
- disabled_seats: disabled_seats,
- enabled_seats: enabled_seats,
- index: index)
+ SocialDistancingRuleset.new(name,
+ number_of_disabled_seats_to_the_sides: number_of_disabled_seats_to_the_sides,
+ disable_seats_in_front_and_behind: disable_seats_in_front_and_behind,
+ disable_diagonal_seats_in_front_and_behind: disable_diagonal_seats_in_front_and_behind,
+ number_of_disabled_aisle_seats: number_of_disabled_aisle_seats,
+ max_group_size: max_group_size,
+ max_occupancy_absolute: max_occupancy_absolute,
+ max_occupancy_percentage: max_occupancy_percentage,
+ one_group_per_table: one_group_per_table,
+ fixed_group_layout: false,
+ disabled_seats: disabled_seats,
+ enabled_seats: enabled_seats,
+ index: index)
end
def == (other)
self.name == other.name &&
- self.number_of_disabled_seats_to_the_sides == other.number_of_disabled_seats_to_the_sides &&
- self.disable_seats_in_front_and_behind == other.disable_seats_in_front_and_behind &&
- self.disable_diagonal_seats_in_front_and_behind == other.disable_diagonal_seats_in_front_and_behind &&
- self.number_of_disabled_aisle_seats == other.number_of_disabled_aisle_seats &&
- self.max_group_size == other.max_group_size &&
- self.max_occupancy_absolute == other.max_occupancy_absolute &&
- self.max_occupancy_percentage == other.max_occupancy_percentage &&
- self.one_group_per_table == other.one_group_per_table &&
- self.fixed_group_layout == other.fixed_group_layout &&
- self.disabled_seats == other.disabled_seats &&
- self.enabled_seats == other.enabled_seats &&
- self.index == other.index
+ self.number_of_disabled_seats_to_the_sides == other.number_of_disabled_seats_to_the_sides &&
+ self.disable_seats_in_front_and_behind == other.disable_seats_in_front_and_behind &&
+ self.disable_diagonal_seats_in_front_and_behind == other.disable_diagonal_seats_in_front_and_behind &&
+ self.number_of_disabled_aisle_seats == other.number_of_disabled_aisle_seats &&
+ self.max_group_size == other.max_group_size &&
+ self.max_occupancy_absolute == other.max_occupancy_absolute &&
+ self.max_occupancy_percentage == other.max_occupancy_percentage &&
+ self.one_group_per_table == other.one_group_per_table &&
+ self.fixed_group_layout == other.fixed_group_layout &&
+ self.disabled_seats == other.disabled_seats &&
+ self.enabled_seats == other.enabled_seats &&
+ self.index == other.index
end
end
end