From b82bc8b595c9f0bbae91883e14572c4b40b8c2c6 Mon Sep 17 00:00:00 2001 From: Ben Verbeken Date: Fri, 4 Oct 2024 11:31:25 +0200 Subject: [PATCH] add methods to put up objects for resale (#127) --- lib/seatsio/domain.rb | 1 + lib/seatsio/events.rb | 4 ++++ ..._object_status_for_multiple_events_test.rb | 12 ++++++++++ test/events/put_objects_up_for_resale_test.rb | 22 +++++++++++++++++++ 4 files changed, 39 insertions(+) create mode 100644 test/events/put_objects_up_for_resale_test.rb diff --git a/lib/seatsio/domain.rb b/lib/seatsio/domain.rb index 48ec793..e81cf2b 100644 --- a/lib/seatsio/domain.rb +++ b/lib/seatsio/domain.rb @@ -419,6 +419,7 @@ class EventObjectInfo FREE = 'free' BOOKED = 'booked' HELD = 'reservedByToken' + RESALE = 'resale' attr_reader :labels, :ids, :label, :order_id, :extra_data, :capacity, :status, :category_key, :entrance, :object_type, :hold_token, :category_label, diff --git a/lib/seatsio/events.rb b/lib/seatsio/events.rb index 3a8290f..de5f6a5 100644 --- a/lib/seatsio/events.rb +++ b/lib/seatsio/events.rb @@ -76,6 +76,10 @@ def book(event_key_or_keys, object_or_objects, hold_token: nil, order_id: nil, k self.change_object_status(event_key_or_keys, object_or_objects, Seatsio::EventObjectInfo::BOOKED, hold_token: hold_token, order_id: order_id, keep_extra_data: keep_extra_data, ignore_channels: ignore_channels, channel_keys: channel_keys) end + def put_up_for_resale(event_key_or_keys, object_or_objects) + self.change_object_status(event_key_or_keys, object_or_objects, Seatsio::EventObjectInfo::RESALE) + end + def change_object_status(event_key_or_keys, object_or_objects, status, hold_token: nil, order_id: nil, keep_extra_data: nil, ignore_channels: nil, channel_keys: nil, allowed_previous_statuses: nil, rejected_previous_statuses: nil) request = create_change_object_status_request(object_or_objects, status, hold_token, order_id, event_key_or_keys, keep_extra_data, ignore_channels, channel_keys, allowed_previous_statuses, rejected_previous_statuses) request[:params] = { diff --git a/test/events/change_object_status_for_multiple_events_test.rb b/test/events/change_object_status_for_multiple_events_test.rb index b1d287f..2a9797d 100644 --- a/test/events/change_object_status_for_multiple_events_test.rb +++ b/test/events/change_object_status_for_multiple_events_test.rb @@ -28,6 +28,18 @@ def test_book assert_equal(Seatsio::EventObjectInfo::BOOKED, fetch_status(event2.key, 'A-2')) end + def test_put_up_for_resale + chart_key = create_test_chart + event1 = @seatsio.events.create chart_key: chart_key + event2 = @seatsio.events.create chart_key: chart_key + + @seatsio.events.put_up_for_resale([event1.key, event2.key], %w(A-1 A-2)) + assert_equal(Seatsio::EventObjectInfo::RESALE, fetch_status(event1.key, 'A-1')) + assert_equal(Seatsio::EventObjectInfo::RESALE, fetch_status(event2.key, 'A-1')) + assert_equal(Seatsio::EventObjectInfo::RESALE, fetch_status(event1.key, 'A-2')) + assert_equal(Seatsio::EventObjectInfo::RESALE, fetch_status(event2.key, 'A-2')) + end + def test_hold chart_key = create_test_chart event1 = @seatsio.events.create chart_key: chart_key diff --git a/test/events/put_objects_up_for_resale_test.rb b/test/events/put_objects_up_for_resale_test.rb new file mode 100644 index 0000000..2190b6f --- /dev/null +++ b/test/events/put_objects_up_for_resale_test.rb @@ -0,0 +1,22 @@ +require 'test_helper' +require 'util' +require 'seatsio/domain' + +class PutObjectsUpForResaleTest < SeatsioTestClient + def test_put_up_for_resale + chart_key = create_test_chart + event = @seatsio.events.create chart_key: chart_key + + res = @seatsio.events.put_up_for_resale(event.key, %w(A-1 A-2)) + + a1_status = @seatsio.events.retrieve_object_info(key: event.key, label: 'A-1').status + a2_status = @seatsio.events.retrieve_object_info(key: event.key, label: 'A-2').status + a3_status = @seatsio.events.retrieve_object_info(key: event.key, label: 'A-3').status + + assert_equal(Seatsio::EventObjectInfo::RESALE, a1_status) + assert_equal(Seatsio::EventObjectInfo::RESALE, a2_status) + assert_equal(Seatsio::EventObjectInfo::FREE, a3_status) + + assert_equal(res.objects.keys.sort, ['A-1', 'A-2']) + end +end