-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use new RELEASE statusChangeCommand type instead of hardcoded FREE st…
…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
1 parent
5025e71
commit a21bcde
Showing
3 changed files
with
51 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) |