Skip to content

Commit

Permalink
add methods to put up objects for resale (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
bverbeken authored Oct 4, 2024
1 parent 79fdcc3 commit b82bc8b
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/seatsio/domain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions lib/seatsio/events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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] = {
Expand Down
12 changes: 12 additions & 0 deletions test/events/change_object_status_for_multiple_events_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions test/events/put_objects_up_for_resale_test.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit b82bc8b

Please sign in to comment.