diff --git a/lib/seatsio/events.rb b/lib/seatsio/events.rb index e494346..3a8290f 100644 --- a/lib/seatsio/events.rb +++ b/lib/seatsio/events.rb @@ -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:) diff --git a/lib/seatsio/events/change_object_status_request.rb b/lib/seatsio/events/change_object_status_request.rb index f09fbcc..950e586 100644 --- a/lib/seatsio/events/change_object_status_request.rb +++ b/lib/seatsio/events/change_object_status_request.rb @@ -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 @@ -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