From e58264a374ae5b1d82053a85c4f16da5191c7b73 Mon Sep 17 00:00:00 2001 From: mroloux Date: Fri, 27 Oct 2023 12:05:06 +0200 Subject: [PATCH] Added call to override the season object status (#92) --- lib/seatsio/events.rb | 12 +++++++++++ ...rb => mark_everything_as_for_sale_test.rb} | 0 .../override_season_object_status_test.rb | 19 ++++++++++++++++++ test/events/use_season_object_status_test.rb | 20 +++++++++++++++++++ 4 files changed, 51 insertions(+) rename test/events/{mask_everything_as_for_sale_test.rb => mark_everything_as_for_sale_test.rb} (100%) create mode 100644 test/events/override_season_object_status_test.rb create mode 100644 test/events/use_season_object_status_test.rb diff --git a/lib/seatsio/events.rb b/lib/seatsio/events.rb index 3682d08..ade6f7f 100644 --- a/lib/seatsio/events.rb +++ b/lib/seatsio/events.rb @@ -35,6 +35,18 @@ def update(key:, chart_key: nil, event_key: nil, name: nil, date: nil, table_boo @http_client.post("/events/#{key}", payload) end + def override_season_object_status(key:, objects:) + request = {} + request[:objects] = objects + @http_client.post("events/#{key}/actions/override-season-status", request) + end + + def use_season_object_status(key:, objects:) + request = {} + request[:objects] = objects + @http_client.post("events/#{key}/actions/use-season-status", request) + end + def update_extra_data(key:, object:, extra_data: nil) payload = build_extra_data_request(extra_data) @http_client.post("events/#{key}/objects/#{object}/actions/update-extra-data", payload) diff --git a/test/events/mask_everything_as_for_sale_test.rb b/test/events/mark_everything_as_for_sale_test.rb similarity index 100% rename from test/events/mask_everything_as_for_sale_test.rb rename to test/events/mark_everything_as_for_sale_test.rb diff --git a/test/events/override_season_object_status_test.rb b/test/events/override_season_object_status_test.rb new file mode 100644 index 0000000..4a1944a --- /dev/null +++ b/test/events/override_season_object_status_test.rb @@ -0,0 +1,19 @@ +require 'test_helper' +require 'util' +require 'seatsio/domain' + +class OverrideSeasonObjectStatusTest < SeatsioTestClient + def test_override_season_object_status + chart_key = create_test_chart + season = @seatsio.seasons.create chart_key: chart_key, event_keys: %w[event1] + @seatsio.events.book(season.key, ["A-1", "A-2"]) + + @seatsio.events.override_season_object_status(key: "event1", objects: %w(A-1 A-2)) + + a1_status = @seatsio.events.retrieve_object_info(key: "event1", label: 'A-1').status + a2_status = @seatsio.events.retrieve_object_info(key: "event1", label: 'A-2').status + + assert_equal(Seatsio::EventObjectInfo::FREE, a1_status) + assert_equal(Seatsio::EventObjectInfo::FREE, a2_status) + end +end diff --git a/test/events/use_season_object_status_test.rb b/test/events/use_season_object_status_test.rb new file mode 100644 index 0000000..67fe996 --- /dev/null +++ b/test/events/use_season_object_status_test.rb @@ -0,0 +1,20 @@ +require 'test_helper' +require 'util' +require 'seatsio/domain' + +class UseSeasonObjectStatusTest < SeatsioTestClient + def test_use_season_object_status + chart_key = create_test_chart + season = @seatsio.seasons.create chart_key: chart_key, event_keys: %w[event1] + @seatsio.events.book(season.key, ["A-1", "A-2"]) + @seatsio.events.override_season_object_status(key: "event1", objects: %w(A-1 A-2)) + + @seatsio.events.use_season_object_status(key: "event1", objects: %w(A-1 A-2)) + + a1_status = @seatsio.events.retrieve_object_info(key: "event1", label: 'A-1').status + a2_status = @seatsio.events.retrieve_object_info(key: "event1", label: 'A-2').status + + assert_equal(Seatsio::EventObjectInfo::BOOKED, a1_status) + assert_equal(Seatsio::EventObjectInfo::BOOKED, a2_status) + end +end