Skip to content

Commit

Permalink
Added channel support to call that changes object statuses in batch
Browse files Browse the repository at this point in the history
  • Loading branch information
mroloux committed Jul 24, 2020
1 parent ec432b8 commit 83a6ce7
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 5 deletions.
6 changes: 3 additions & 3 deletions seatsio/events/eventsClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ def change_object_status(self, event_key_or_keys, object_or_objects, status, hol
return ChangeObjectStatusResult(response.json())

def change_object_status_in_batch(self, status_change_requests):
requests = list(map(lambda r: self.__change_object_status_in_batch_request(r.event_key, r.object_or_objects, r.status, r.hold_token, r.order_id, r.keep_extra_data), status_change_requests))
requests = list(map(lambda r: self.__change_object_status_in_batch_request(r.event_key, r.object_or_objects, r.status, r.hold_token, r.order_id, r.keep_extra_data, r.ignore_channels, r.channel_keys), status_change_requests))
response = self.http_client.url("/events/actions/change-object-status",
query_params={"expand": "objects"}).post({"statusChanges": requests})
return list(map(lambda r: ChangeObjectStatusResult(r), response.json().get("results")))

def __change_object_status_in_batch_request(self, event_key, object_or_objects, status, hold_token, order_id, keep_extra_data):
request = ChangeObjectStatusRequest(object_or_objects, status, hold_token, order_id, "", keep_extra_data, None, None)
def __change_object_status_in_batch_request(self, event_key, object_or_objects, status, hold_token, order_id, keep_extra_data, ignore_channels, channel_keys):
request = ChangeObjectStatusRequest(object_or_objects, status, hold_token, order_id, "", keep_extra_data, ignore_channels, channel_keys)
request.event = event_key
delattr(request, "events")
return request
Expand Down
4 changes: 3 additions & 1 deletion seatsio/events/statusChangeRequest.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
class StatusChangeRequest:
def __init__(self, event_key, object_or_objects, status, hold_token=None, order_id=None, keep_extra_data=None):
def __init__(self, event_key, object_or_objects, status, hold_token=None, order_id=None, keep_extra_data=None, ignore_channels=None, channel_keys=None):
self.event_key = event_key
self.object_or_objects = object_or_objects
self.status = status
self.hold_token = hold_token
self.order_id = order_id
self.keep_extra_data = keep_extra_data
self.ignore_channels = ignore_channels
self.channel_keys = channel_keys
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name='seatsio',
version='v51.9.0',
version='v51.10.0',
description='The official Seats.io Python client library',
author='The seats.io dev team',
author_email='[email protected]',
Expand Down
33 changes: 33 additions & 0 deletions tests/events/changeObjectStatusInBatchTest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from seatsio import Channel
from seatsio.events.statusChangeRequest import StatusChangeRequest
from tests.seatsioClientTest import SeatsioClientTest
from tests.util.asserts import assert_that
Expand All @@ -21,3 +22,35 @@ def test(self):

assert_that(self.client.events.retrieve_object_status(event2.key, "A-2").status).is_equal_to("lolzor")
assert_that(res[1].objects["A-2"].status).is_equal_to("lolzor")

def test_channelKeys(self):
chart_key = self.create_test_chart()
event = self.client.events.create(chart_key)
self.client.events.update_channels(event.key, {
'channelKey1': Channel(name='channel 1', color='#00FF00', index=1)
})
self.client.events.assign_objects_to_channels(event.key, {
"channelKey1": ["A-1"]
})

res = self.client.events.change_object_status_in_batch([
StatusChangeRequest(event.key, ["A-1"], "lolzor", channel_keys=["channelKey1"]),
])

assert_that(res[0].objects["A-1"].status).is_equal_to("lolzor")

def test_ignoreChannels(self):
chart_key = self.create_test_chart()
event = self.client.events.create(chart_key)
self.client.events.update_channels(event.key, {
'channelKey1': Channel(name='channel 1', color='#00FF00', index=1)
})
self.client.events.assign_objects_to_channels(event.key, {
"channelKey1": ["A-1"]
})

res = self.client.events.change_object_status_in_batch([
StatusChangeRequest(event.key, ["A-1"], "lolzor", ignore_channels=True),
])

assert_that(res[0].objects["A-1"].status).is_equal_to("lolzor")

0 comments on commit 83a6ce7

Please sign in to comment.