Skip to content

Commit

Permalink
add methods to put up objects for resale (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
bverbeken authored Oct 4, 2024
1 parent b39a50c commit eebe4da
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions seatsio/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ class EventObjectInfo:
FREE = "free"
BOOKED = "booked"
HELD = "reservedByToken"
RESALE = "resale"

def __init__(self, item_data):
self.status = item_data.get("status")
Expand Down
3 changes: 3 additions & 0 deletions seatsio/events/eventsClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ def book(self, event_key_or_keys, object_or_objects, hold_token=None, order_id=N
return self.change_object_status(event_key_or_keys, object_or_objects, EventObjectInfo.BOOKED, hold_token,
order_id, keep_extra_data, ignore_channels, channel_keys)

def put_up_for_resale(self, event_key_or_keys, object_or_objects):
return self.change_object_status(event_key_or_keys, object_or_objects, EventObjectInfo.RESALE)

def book_best_available(self, event_key, number, categories=None, hold_token=None, extra_data=None,
ticket_types=None, order_id=None, keep_extra_data=None, ignore_channels=None,
channel_keys=None, try_to_prevent_orphan_seats=None, zone=None):
Expand Down
16 changes: 16 additions & 0 deletions tests/events/testChangeObjectStatusForMultipleEvents.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,22 @@ def test_book(self):
assert_that(self.fetch_status(event1.key, "A-2")).is_equal_to(EventObjectInfo.BOOKED)
assert_that(self.fetch_status(event2.key, "A-2")).is_equal_to(EventObjectInfo.BOOKED)

def test_put_up_for_resale(self):
chart_key = self.create_test_chart()
event1 = self.client.events.create(chart_key)
event2 = self.client.events.create(chart_key)

self.client.events.put_up_for_resale(
event_key_or_keys=[event1.key, event2.key],
object_or_objects=["A-1", "A-2"],
)

assert_that(self.fetch_status(event1.key, "A-1")).is_equal_to(EventObjectInfo.RESALE)
assert_that(self.fetch_status(event2.key, "A-1")).is_equal_to(EventObjectInfo.RESALE)
assert_that(self.fetch_status(event1.key, "A-2")).is_equal_to(EventObjectInfo.RESALE)
assert_that(self.fetch_status(event2.key, "A-2")).is_equal_to(EventObjectInfo.RESALE)


def test_hold(self):
chart_key = self.create_test_chart()
event1 = self.client.events.create(chart_key)
Expand Down
22 changes: 22 additions & 0 deletions tests/events/testPutObjectsUpForResale.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from seatsio.domain import EventObjectInfo, Channel
from tests.seatsioClientTest import SeatsioClientTest
from tests.util.asserts import assert_that


class PutObjectsUpForResaleTest(SeatsioClientTest):

def test(self):
chart_key = self.create_test_chart()
event = self.client.events.create(chart_key)

res = self.client.events.put_up_for_resale(event.key, ["A-1", "A-2"])

a1_status = self.client.events.retrieve_object_info(event.key, "A-1").status
a2_status = self.client.events.retrieve_object_info(event.key, "A-2").status
a3_status = self.client.events.retrieve_object_info(event.key, "A-3").status

assert_that(a1_status).is_equal_to(EventObjectInfo.RESALE)
assert_that(a2_status).is_equal_to(EventObjectInfo.RESALE)
assert_that(a3_status).is_equal_to(EventObjectInfo.FREE)

assert_that(list(res.objects)).contains_exactly_in_any_order("A-1", "A-2")

0 comments on commit eebe4da

Please sign in to comment.