Skip to content

Commit

Permalink
use new RELEASE statusChangeCommand type instead of hardcoded FREE st…
Browse files Browse the repository at this point in the history
…atus, when releasing objects (#91)

* instead of passing in FREE as a status, we now use RELEASE as statusChangeCommand type.

* Minimum supported Python version is now 3.8 (#92)

* Minimum supported Python version is now 3.8

* Removed unnecessary requirements.txt

---------

Co-authored-by: Steve Chaloner <[email protected]>

---------

Co-authored-by: Steve Chaloner <[email protected]>
Co-authored-by: Steve Chaloner <[email protected]>
  • Loading branch information
3 people authored Oct 4, 2024
1 parent 5025e71 commit a21bcde
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 2 deletions.
1 change: 1 addition & 0 deletions seatsio/events/changeObjectStatusRequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
class ChangeObjectStatusRequest:
def __init__(self, object_or_objects, status, hold_token, order_id, event_key_or_keys, keep_extra_data, ignore_channels, channel_keys, allowed_previous_statuses=None, rejected_previous_statuses=None):
self.objects = self.__normalize_objects(object_or_objects)
self.type = 'CHANGE_STATUS_TO'
self.status = status
if hold_token:
self.holdToken = hold_token
Expand Down
10 changes: 8 additions & 2 deletions seatsio/events/eventsClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from seatsio.events.extraDataRequest import ExtraDataRequest
from seatsio.events.forSaleRequest import ForSaleRequest
from seatsio.events.overrideSeasonObjectStatusRequest import OverrideSeasonObjectStatusRequest
from seatsio.events.releaseObjectsRequest import ReleaseObjectsRequest
from seatsio.events.updateEventRequest import UpdateEventRequest
from seatsio.pagination.listableObjectsClient import ListableObjectsClient
from seatsio.pagination.lister import Lister
Expand Down Expand Up @@ -131,8 +132,10 @@ def change_best_available_object_status(self, event_key, number, status, categor

def release(self, event_key_or_keys, object_or_objects, hold_token=None, order_id=None, keep_extra_data=None,
ignore_channels=None, channel_keys=None):
return self.change_object_status(event_key_or_keys, object_or_objects, EventObjectInfo.FREE, hold_token,
order_id, keep_extra_data, ignore_channels, channel_keys)
request = ReleaseObjectsRequest(
object_or_objects, hold_token, order_id, event_key_or_keys,
keep_extra_data, ignore_channels, channel_keys)
return self.__do_change_status(request)

def hold(self, event_key_or_keys, object_or_objects, hold_token, order_id=None, keep_extra_data=None,
ignore_channels=None, channel_keys=None):
Expand All @@ -146,6 +149,9 @@ def change_object_status(self, event_key_or_keys, object_or_objects, status, hol
request = ChangeObjectStatusRequest(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)
return self.__do_change_status(request)

def __do_change_status(self, request):
response = self.http_client.url("/events/groups/actions/change-object-status",
query_params={"expand": "objects"}).post(request)
return ChangeObjectStatusResult(response.json())
Expand Down
42 changes: 42 additions & 0 deletions seatsio/events/releaseObjectsRequest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from past.builtins import basestring

from seatsio.events.objectProperties import ObjectProperties


class ReleaseObjectsRequest:
def __init__(self, object_or_objects, hold_token, order_id, event_key_or_keys, keep_extra_data, ignore_channels, channel_keys, allowed_previous_statuses=None, rejected_previous_statuses=None):
self.objects = self.__normalize_objects(object_or_objects)
self.type = 'RELEASE'
if hold_token:
self.holdToken = hold_token
if order_id:
self.orderId = order_id
if isinstance(event_key_or_keys, basestring):
self.events = [event_key_or_keys]
else:
self.events = event_key_or_keys
if keep_extra_data is not None:
self.keepExtraData = keep_extra_data
if ignore_channels is not None:
self.ignoreChannels = ignore_channels
if channel_keys is not None:
self.channelKeys = channel_keys
if allowed_previous_statuses is not None:
self.allowedPreviousStatuses = allowed_previous_statuses
if rejected_previous_statuses is not None:
self.rejectedPreviousStatuses = rejected_previous_statuses

def __normalize_objects(self, object_or_objects):
if isinstance(object_or_objects, list):
if len(object_or_objects) == 0:
return []
if isinstance(object_or_objects[0], ObjectProperties):
return object_or_objects
if isinstance(object_or_objects[0], basestring):
result = []
for o in object_or_objects:
result.append(ObjectProperties(o))
return result
else:
raise Exception("Unsupported type " + str(type(object_or_objects[0])))
return self.__normalize_objects([object_or_objects])

0 comments on commit a21bcde

Please sign in to comment.