From c8aa694b11b77393585f36795d292f897c712198 Mon Sep 17 00:00:00 2001 From: Ben Verbeken Date: Wed, 2 Oct 2024 11:27:26 +0200 Subject: [PATCH] refactoring --- lib/seatsio/events.rb | 1 - .../events/change_object_status_request.rb | 19 +++++++++++ lib/seatsio/events/release_objects_request.rb | 32 ------------------- 3 files changed, 19 insertions(+), 33 deletions(-) delete mode 100644 lib/seatsio/events/release_objects_request.rb diff --git a/lib/seatsio/events.rb b/lib/seatsio/events.rb index 22b0ba9..3a8290f 100644 --- a/lib/seatsio/events.rb +++ b/lib/seatsio/events.rb @@ -5,7 +5,6 @@ require "json" require "cgi" require "seatsio/events/change_object_status_request" -require "seatsio/events/release_objects_request" require "seatsio/events/change_best_available_object_status_request" require 'seatsio/channels' 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 diff --git a/lib/seatsio/events/release_objects_request.rb b/lib/seatsio/events/release_objects_request.rb deleted file mode 100644 index 92502ca..0000000 --- a/lib/seatsio/events/release_objects_request.rb +++ /dev/null @@ -1,32 +0,0 @@ -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 - [] - end - - result = [] - object_or_objects.each do |object| - result << object - end - return result - - end - normalize([object_or_objects]) -end