Skip to content

Commit

Permalink
Zone can be passed in to best available calls (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
mroloux authored Jul 17, 2024
1 parent f38c472 commit b5f9fce
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
4 changes: 3 additions & 1 deletion seatsio/events/changeBestAvailableObjectStatusRequest.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
class ChangeBestAvailableObjectStatusRequest:
def __init__(self, number, categories, extra_data, ticket_types, status, hold_token, order_id, keep_extra_data, ignore_channels, channel_keys, try_to_prevent_orphan_seats):
def __init__(self, number, categories, zone, extra_data, ticket_types, status, hold_token, order_id, keep_extra_data, ignore_channels, channel_keys, try_to_prevent_orphan_seats):
best_available = {"number": number}
if categories:
best_available["categories"] = categories
if zone:
best_available["zone"] = zone
if extra_data:
best_available["extraData"] = extra_data
if ticket_types:
Expand Down
23 changes: 15 additions & 8 deletions seatsio/events/eventsClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def book(self, event_key_or_keys, object_or_objects, hold_token=None, order_id=N

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):
channel_keys=None, try_to_prevent_orphan_seats=None, zone=None):
return self.change_best_available_object_status(
event_key,
number,
Expand All @@ -94,12 +94,14 @@ def book_best_available(self, event_key, number, categories=None, hold_token=Non
order_id,
keep_extra_data,
ignore_channels,
channel_keys
channel_keys,
try_to_prevent_orphan_seats,
zone
)

def hold_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):
channel_keys=None, try_to_prevent_orphan_seats=None, zone=None):
return self.change_best_available_object_status(
event_key,
number,
Expand All @@ -112,15 +114,19 @@ def hold_best_available(self, event_key, number, categories=None, hold_token=Non
keep_extra_data,
ignore_channels,
channel_keys,
try_to_prevent_orphan_seats
try_to_prevent_orphan_seats,
zone
)

def change_best_available_object_status(self, event_key, number, status, 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):
ignore_channels=None, channel_keys=None, try_to_prevent_orphan_seats=None,
zone=None):
response = self.http_client.url("/events/{key}/actions/change-object-status", key=event_key).post(
ChangeBestAvailableObjectStatusRequest(number, categories, extra_data, ticket_types, status, hold_token,
order_id, keep_extra_data, ignore_channels, channel_keys, try_to_prevent_orphan_seats))
ChangeBestAvailableObjectStatusRequest(number, categories, zone, extra_data, ticket_types, status,
hold_token,
order_id, keep_extra_data, ignore_channels, channel_keys,
try_to_prevent_orphan_seats))
return BestAvailableObjects(response.json())

def release(self, event_key_or_keys, object_or_objects, hold_token=None, order_id=None, keep_extra_data=None,
Expand Down Expand Up @@ -160,7 +166,8 @@ def __change_object_status_in_batch_request(self, event_key, object_or_objects,
keep_extra_data, ignore_channels, channel_keys,
allowed_previous_statuses, rejected_previous_statuses):
request = ChangeObjectStatusRequest(object_or_objects, status, hold_token, order_id, "", keep_extra_data,
ignore_channels, channel_keys, allowed_previous_statuses, rejected_previous_statuses)
ignore_channels, channel_keys, allowed_previous_statuses,
rejected_previous_statuses)
request.event = event_key
delattr(request, "events")
return request
Expand Down
10 changes: 10 additions & 0 deletions tests/events/testChangeBestAvailableObjectStatus.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ def test_categories(self):
result = self.client.events.change_best_available_object_status(event.key, 3, "myStatus", categories=["cat2"])
assert_that(result.objects).contains_exactly("C-4", "C-5", "C-6")

def test_zone(self):
chart_key = self.create_test_chart_with_zones()
event = self.client.events.create(chart_key)

result_midtrack = self.client.events.change_best_available_object_status(event.key, 1, "myStatus", zone="midtrack")
assert_that(result_midtrack.objects).contains_exactly("MT3-A-139")

result_finishline = self.client.events.change_best_available_object_status(event.key, 1, "myStatus", zone="finishline")
assert_that(result_finishline.objects).contains_exactly("Goal Stand 4-A-1")

def test_extra_data(self):
chart_key = self.create_test_chart()
event = self.client.events.create(chart_key)
Expand Down

0 comments on commit b5f9fce

Please sign in to comment.