Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use new RELEASE statusChangeCommand type instead of hardcoded FREE status, when releasing objects #91

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,14 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.7', '3.10']
python-version: ['3.8', '3.10']

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
python setup.py install
- uses: zcong1993/setup-timezone@master
with:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Build](https://github.com/seatsio/seatsio-python/workflows/Build/badge.svg)](https://github.com/seatsio/seatsio-python/actions/workflows/build.yml)
[![PyPI version](https://badge.fury.io/py/seatsio.svg)](https://badge.fury.io/py/seatsio)

This is the official Python client library for the [Seats.io V2 REST API](https://docs.seats.io/docs/api-overview), supporting Python 3.7+.
This is the official Python client library for the [Seats.io V2 REST API](https://docs.seats.io/docs/api-overview), supporting Python 3.8+.

## Installing

Expand Down
1 change: 0 additions & 1 deletion requirements.txt

This file was deleted.

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])
Loading