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 #126

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
7 changes: 6 additions & 1 deletion lib/seatsio/events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,12 @@ def hold_best_available(key, number, hold_token, categories: nil, order_id: nil,
end

def release(event_key_or_keys, object_or_objects, hold_token: nil, order_id: nil, keep_extra_data: nil, ignore_channels: nil, channel_keys: nil)
change_object_status(event_key_or_keys, object_or_objects, Seatsio::EventObjectInfo::FREE, hold_token: hold_token, order_id: order_id, keep_extra_data: keep_extra_data, ignore_channels: ignore_channels, channel_keys: channel_keys)
request = create_release_objects_request(object_or_objects, hold_token, order_id, event_key_or_keys, keep_extra_data, ignore_channels, channel_keys)
request[:params] = {
:expand => 'objects'
}
response = @http_client.post("events/groups/actions/change-object-status", request)
ChangeObjectStatusResult.new(response)
end

def delete(key:)
Expand Down
19 changes: 19 additions & 0 deletions lib/seatsio/events/change_object_status_request.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
def create_change_object_status_request(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)
result = {}
result[:objects] = normalize(object_or_objects)
result[:type] = 'CHANGE_STATUS_TO'
result[:status] = status
result[:holdToken] = hold_token if hold_token != nil
result[:orderId] = order_id if order_id != nil
Expand All @@ -17,6 +18,24 @@ def create_change_object_status_request(object_or_objects, status, hold_token, o
result
end

def create_release_objects_request(object_or_objects, hold_token, order_id, event_key_or_keys, keep_extra_data, ignore_channels, channel_keys)
result = {}
result[:objects] = normalize(object_or_objects)
result[:type] = "RELEASE"
result[:holdToken] = hold_token if hold_token != nil
result[:orderId] = order_id if order_id != nil
if event_key_or_keys.is_a? Array
result[:events] = event_key_or_keys
else
result[:events] = [event_key_or_keys]
end
result[:keepExtraData] = keep_extra_data if keep_extra_data != nil
result[:ignoreChannels] = ignore_channels if ignore_channels != nil
result[:channelKeys] = channel_keys if channel_keys != nil
result
end


def normalize(object_or_objects)
if object_or_objects.is_a? Array
if object_or_objects.length == 0
Expand Down
Loading