diff --git a/lib/seatsio/domain.rb b/lib/seatsio/domain.rb index f1e9bce..e3121d9 100644 --- a/lib/seatsio/domain.rb +++ b/lib/seatsio/domain.rb @@ -316,7 +316,7 @@ class ChartObjectInfo attr_reader :label, :labels, :ids, :category_key, :category_label, :section, :entrance, :capacity, :object_type, :left_neighbour, :right_neighbour, :book_as_a_whole, :distance_to_focal_point, :num_seats, :is_accessible, - :is_companion_seat, :has_restricted_view + :is_companion_seat, :has_restricted_view, :zone def initialize(data) @label = data['label'] @@ -336,6 +336,7 @@ def initialize(data) @is_accessible = data['isAccessible'] @is_companion_seat = data['isCompanionSeat'] @has_restricted_view = data['hasRestrictedView'] + @zone = data['zone'] end end @@ -392,7 +393,8 @@ class EventObjectInfo :is_accessible, :is_companion_seat, :has_restricted_view, :displayed_object_type, :left_neighbour, :right_neighbour, :is_available, :channel, :book_as_a_whole, :distance_to_focal_point, :holds, :num_seats, :variable_occupancy, - :min_occupancy, :max_occupancy, :season_status_overridden_quantity, :num_not_for_sale + :min_occupancy, :max_occupancy, :season_status_overridden_quantity, :num_not_for_sale, + :zone def initialize(data) @status = data['status'] @@ -430,6 +432,7 @@ def initialize(data) @max_occupancy = data['maxOccupancy'] @season_status_overridden_quantity = data['seasonStatusOverriddenQuantity'] @num_not_for_sale = data['numNotForSale'] + @zone = data['zone'] end end diff --git a/lib/seatsio/event_reports.rb b/lib/seatsio/event_reports.rb index 2ed167b..90c3d94 100644 --- a/lib/seatsio/event_reports.rb +++ b/lib/seatsio/event_reports.rb @@ -71,6 +71,18 @@ def deep_summary_by_section(event_key) fetch_deep_summary_report('bySection', event_key) end + def by_zone(event_key, zone = nil) + fetch_report('byZone', event_key, zone) + end + + def summary_by_zone(event_key) + fetch_summary_report('byZone', event_key) + end + + def deep_summary_by_zone(event_key) + fetch_deep_summary_report('byZone', event_key) + end + def by_availability(event_key, availability = nil) fetch_report('byAvailability', event_key, availability) end diff --git a/test/reports/charts/chart_reports_test.rb b/test/reports/charts/chart_reports_test.rb index 5bb6858..ec15a54 100644 --- a/test/reports/charts/chart_reports_test.rb +++ b/test/reports/charts/chart_reports_test.rb @@ -230,6 +230,7 @@ def test_by_zone report = get_report.(chart_key) assert_equal(3, report.items.length) assert_equal(6032, report.items['midtrack'].length) + assert_equal('midtrack', report.items['midtrack'][0].zone) assert_equal(2865, report.items['finishline'].length) assert_equal(0, report.items['NO_ZONE'].length) end diff --git a/test/reports/events/event_reports_deep_summary_test.rb b/test/reports/events/event_reports_deep_summary_test.rb index 6cffec5..928983e 100644 --- a/test/reports/events/event_reports_deep_summary_test.rb +++ b/test/reports/events/event_reports_deep_summary_test.rb @@ -67,6 +67,16 @@ def test_deep_summary_by_section assert_equal(1, report['NO_SECTION']['byCategoryLabel']['Cat1']['byAvailability']['not_available']) end + def test_deep_summary_by_zone + chart_key = create_test_chart_with_zones + event = @seatsio.events.create chart_key: chart_key + + report = @seatsio.event_reports.deep_summary_by_zone(event.key) + + assert_equal(6032, report['midtrack']['count']) + assert_equal(6032, report['midtrack']['byCategoryLabel']['Mid Track Stand']['count']) + end + def test_deep_summary_by_availability chart_key = create_test_chart event = @seatsio.events.create chart_key: chart_key diff --git a/test/reports/events/event_reports_summary_test.rb b/test/reports/events/event_reports_summary_test.rb index 534277f..3916273 100644 --- a/test/reports/events/event_reports_summary_test.rb +++ b/test/reports/events/event_reports_summary_test.rb @@ -108,6 +108,17 @@ def test_summary_by_section assert_equal(116, report['NO_SECTION']['byCategoryLabel']['Cat1']) assert_equal(116, report['NO_SECTION']['byCategoryLabel']['Cat2']) assert_equal(232, report['NO_SECTION']['byChannel']['NO_CHANNEL']) + assert_equal(232, report['NO_SECTION']['byZone']['NO_ZONE']) + end + + def test_summary_by_zone + chart_key = create_test_chart_with_zones + event = @seatsio.events.create chart_key: chart_key + + report = @seatsio.event_reports.summary_by_zone(event.key) + + assert_equal(6032, report['midtrack']['count']) + assert_equal(6032, report['midtrack']['byStatus']['free']) end def test_summary_by_availability diff --git a/test/reports/events/event_reports_test.rb b/test/reports/events/event_reports_test.rb index 3bba0b4..d39c837 100644 --- a/test/reports/events/event_reports_test.rb +++ b/test/reports/events/event_reports_test.rb @@ -283,6 +283,25 @@ def test_by_specific_section assert_equal(34, report.items.length) end + def test_by_zone + chart_key = create_test_chart_with_zones + event = @seatsio.events.create chart_key: chart_key + + report = @seatsio.event_reports.by_zone(event.key) + + assert_equal(6032, report.items['midtrack'].length) + assert_equal('midtrack', report.items['midtrack'][0].zone) + end + + def test_by_specific_zone + chart_key = create_test_chart_with_zones + event = @seatsio.events.create chart_key: chart_key + + report = @seatsio.event_reports.by_zone(event.key, 'midtrack') + + assert_equal(6032, report.items.length) + end + def test_by_availability chart_key = create_test_chart event = @seatsio.events.create chart_key: chart_key