Class: Seatsio::EventsClient
- Inherits:
-
Object
- Object
- Seatsio::EventsClient
- Defined in:
- lib/seatsio/events.rb
Instance Attribute Summary collapse
-
#channels ⇒ Object
readonly
Returns the value of attribute channels.
Instance Method Summary collapse
- #book(event_key_or_keys, object_or_objects, hold_token: nil, order_id: nil, keep_extra_data: nil, ignore_channels: nil, channel_keys: nil, ignore_social_distancing: nil) ⇒ Object
- #book_best_available(key, number, categories: nil, hold_token: nil, order_id: nil, keep_extra_data: nil, extra_data: nil, ticket_types: nil, ignore_channels: nil, channel_keys: nil) ⇒ Object
- #change_best_available_object_status(key, number, status, categories: nil, hold_token: nil, extra_data: nil, ticket_types: nil, order_id: nil, keep_extra_data: nil, ignore_channels: nil, channel_keys: nil) ⇒ Object
- #change_object_status(event_key_or_keys, object_or_objects, status, hold_token: nil, order_id: nil, keep_extra_data: nil, ignore_channels: nil, channel_keys: nil, ignore_social_distancing: nil, allowed_previous_statuses: nil, rejected_previous_statuses: nil) ⇒ Object
- #change_object_status_in_batch(status_change_requests) ⇒ Object
- #create(chart_key: nil, event_key: nil, table_booking_config: nil, social_distancing_ruleset_key: nil, object_categories: nil, categories: nil) ⇒ Object
- #create_multiple(key: nil, event_creation_params: nil) ⇒ Object
- #delete(key:) ⇒ Object
- #hold(event_key_or_keys, object_or_objects, hold_token, order_id: nil, keep_extra_data: nil, ignore_channels: nil, channel_keys: nil, ignore_social_distancing: nil) ⇒ Object
- #hold_best_available(key, number, hold_token, categories: nil, order_id: nil, keep_extra_data: nil, extra_data: nil, ticket_types: nil, ignore_channels: nil, channel_keys: nil) ⇒ Object
-
#initialize(http_client) ⇒ EventsClient
constructor
A new instance of EventsClient.
- #list ⇒ Object
- #list_status_changes(key, object_id = nil) ⇒ Object
- #mark_as_for_sale(key:, objects: nil, area_places: nil, categories: nil) ⇒ Object
- #mark_as_not_for_sale(key:, objects: nil, area_places: nil, categories: nil) ⇒ Object
- #mark_everything_as_for_sale(key: nil) ⇒ Object
- #release(event_key_or_keys, object_or_objects, hold_token: nil, order_id: nil, keep_extra_data: nil, ignore_channels: nil, channel_keys: nil) ⇒ Object
- #retrieve(key:) ⇒ Object
- #retrieve_object_info(key:, label:) ⇒ Object
- #retrieve_object_infos(key:, labels:) ⇒ Object
- #status_changes_for_object(key:, object_id:) ⇒ Object
- #update(key:, chart_key: nil, event_key: nil, table_booking_config: nil, social_distancing_ruleset_key: nil, object_categories: nil, categories: nil) ⇒ Object
- #update_extra_data(key:, object:, extra_data: nil) ⇒ Object
- #update_extra_datas(key:, extra_data:) ⇒ Object
Constructor Details
#initialize(http_client) ⇒ EventsClient
Returns a new instance of EventsClient.
16 17 18 19 |
# File 'lib/seatsio/events.rb', line 16 def initialize(http_client) @http_client = http_client @channels = ChannelsClient.new(@http_client) end |
Instance Attribute Details
#channels ⇒ Object (readonly)
Returns the value of attribute channels.
14 15 16 |
# File 'lib/seatsio/events.rb', line 14 def channels @channels end |
Instance Method Details
#book(event_key_or_keys, object_or_objects, hold_token: nil, order_id: nil, keep_extra_data: nil, ignore_channels: nil, channel_keys: nil, ignore_social_distancing: nil) ⇒ Object
72 73 74 |
# File 'lib/seatsio/events.rb', line 72 def book(event_key_or_keys, object_or_objects, hold_token: nil, order_id: nil, keep_extra_data: nil, ignore_channels: nil, channel_keys: nil, ignore_social_distancing: nil) self.change_object_status(event_key_or_keys, object_or_objects, Seatsio::EventObjectInfo::BOOKED, hold_token: hold_token, order_id: order_id, keep_extra_data: keep_extra_data, ignore_channels: ignore_channels, channel_keys: channel_keys, ignore_social_distancing: ) end |
#book_best_available(key, number, categories: nil, hold_token: nil, order_id: nil, keep_extra_data: nil, extra_data: nil, ticket_types: nil, ignore_channels: nil, channel_keys: nil) ⇒ Object
104 105 106 |
# File 'lib/seatsio/events.rb', line 104 def book_best_available(key, number, categories: nil, hold_token: nil, order_id: nil, keep_extra_data: nil, extra_data: nil, ticket_types: nil, ignore_channels: nil, channel_keys: nil) change_best_available_object_status(key, number, Seatsio::EventObjectInfo::BOOKED, categories: categories, hold_token: hold_token, order_id: order_id, keep_extra_data: keep_extra_data, extra_data: extra_data, ticket_types: ticket_types, ignore_channels: ignore_channels, channel_keys: channel_keys) end |
#change_best_available_object_status(key, number, status, categories: nil, hold_token: nil, extra_data: nil, ticket_types: nil, order_id: nil, keep_extra_data: nil, ignore_channels: nil, channel_keys: nil) ⇒ Object
98 99 100 101 102 |
# File 'lib/seatsio/events.rb', line 98 def change_best_available_object_status(key, number, status, categories: nil, hold_token: nil, extra_data: nil, ticket_types: nil, order_id: nil, keep_extra_data: nil, ignore_channels: nil, channel_keys: nil) request = create_change_best_available_object_status_request(number, status, categories, extra_data, ticket_types, hold_token, order_id, keep_extra_data, ignore_channels, channel_keys) response = @http_client.post("events/#{key}/actions/change-object-status", request) BestAvailableObjects.new(response) end |
#change_object_status(event_key_or_keys, object_or_objects, status, hold_token: nil, order_id: nil, keep_extra_data: nil, ignore_channels: nil, channel_keys: nil, ignore_social_distancing: nil, allowed_previous_statuses: nil, rejected_previous_statuses: nil) ⇒ Object
76 77 78 79 80 81 82 83 |
# File 'lib/seatsio/events.rb', line 76 def change_object_status(event_key_or_keys, object_or_objects, status, hold_token: nil, order_id: nil, keep_extra_data: nil, ignore_channels: nil, channel_keys: nil, ignore_social_distancing: nil, allowed_previous_statuses: nil, rejected_previous_statuses: nil) request = 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) request[:params] = { :expand => 'objects' } response = @http_client.post("events/groups/actions/change-object-status", request) ChangeObjectStatusResult.new(response) end |
#change_object_status_in_batch(status_change_requests) ⇒ Object
85 86 87 88 89 90 91 92 |
# File 'lib/seatsio/events.rb', line 85 def change_object_status_in_batch(status_change_requests) request = { :statusChanges => status_change_requests, :params => { :expand => 'objects' } } response = @http_client.post("events/actions/change-object-status", request) ChangeObjectStatusInBatchResult.new(response).results end |
#create(chart_key: nil, event_key: nil, table_booking_config: nil, social_distancing_ruleset_key: nil, object_categories: nil, categories: nil) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/seatsio/events.rb', line 21 def create(chart_key: nil, event_key: nil, table_booking_config: nil, social_distancing_ruleset_key: nil, object_categories: nil, categories: nil) payload = build_event_request(chart_key: chart_key, event_key: event_key, table_booking_config: table_booking_config, social_distancing_ruleset_key: , object_categories: object_categories, categories: categories) response = @http_client.post("events", payload) Event.new(response) end |
#create_multiple(key: nil, event_creation_params: nil) ⇒ Object
30 31 32 33 34 |
# File 'lib/seatsio/events.rb', line 30 def create_multiple(key: nil, event_creation_params: nil) payload = build_events_request(chart_key: key, event_creation_params: event_creation_params) response = @http_client.post("events/actions/create-multiple", payload) Events.new(response).events end |
#delete(key:) ⇒ Object
116 117 118 |
# File 'lib/seatsio/events.rb', line 116 def delete(key:) @http_client.delete("/events/#{key}") end |
#hold(event_key_or_keys, object_or_objects, hold_token, order_id: nil, keep_extra_data: nil, ignore_channels: nil, channel_keys: nil, ignore_social_distancing: nil) ⇒ Object
94 95 96 |
# File 'lib/seatsio/events.rb', line 94 def hold(event_key_or_keys, object_or_objects, hold_token, order_id: nil, keep_extra_data: nil, ignore_channels: nil, channel_keys: nil, ignore_social_distancing: nil) change_object_status(event_key_or_keys, object_or_objects, Seatsio::EventObjectInfo::HELD, hold_token: hold_token, order_id: order_id, keep_extra_data: keep_extra_data, ignore_channels: ignore_channels, channel_keys: channel_keys, ignore_social_distancing: ) end |
#hold_best_available(key, number, hold_token, categories: nil, order_id: nil, keep_extra_data: nil, extra_data: nil, ticket_types: nil, ignore_channels: nil, channel_keys: nil) ⇒ Object
108 109 110 |
# File 'lib/seatsio/events.rb', line 108 def hold_best_available(key, number, hold_token, categories: nil, order_id: nil, keep_extra_data: nil, extra_data: nil, ticket_types: nil, ignore_channels: nil, channel_keys: nil) change_best_available_object_status(key, number, Seatsio::EventObjectInfo::HELD, categories: categories, hold_token: hold_token, order_id: order_id, keep_extra_data: keep_extra_data, extra_data: extra_data, ticket_types: ticket_types, ignore_channels: ignore_channels, channel_keys: channel_keys) end |
#list ⇒ Object
125 126 127 |
# File 'lib/seatsio/events.rb', line 125 def list Pagination::Cursor.new(Event, 'events', @http_client) end |
#list_status_changes(key, object_id = nil) ⇒ Object
129 130 131 132 133 134 135 |
# File 'lib/seatsio/events.rb', line 129 def list_status_changes(key, object_id = nil) if object_id != nil status_changes_for_object key: key, object_id: object_id else Pagination::Cursor.new(StatusChange, "/events/#{key}/status-changes", @http_client) end end |
#mark_as_for_sale(key:, objects: nil, area_places: nil, categories: nil) ⇒ Object
150 151 152 153 |
# File 'lib/seatsio/events.rb', line 150 def mark_as_for_sale(key:, objects: nil, area_places: nil, categories: nil) request = build_parameters_for_mark_as_sale objects, area_places, categories @http_client.post("events/#{key}/actions/mark-as-for-sale", request) end |
#mark_as_not_for_sale(key:, objects: nil, area_places: nil, categories: nil) ⇒ Object
141 142 143 144 |
# File 'lib/seatsio/events.rb', line 141 def mark_as_not_for_sale(key:, objects: nil, area_places: nil, categories: nil) request = build_parameters_for_mark_as_sale objects, area_places, categories @http_client.post("events/#{key}/actions/mark-as-not-for-sale", request) end |
#mark_everything_as_for_sale(key: nil) ⇒ Object
146 147 148 |
# File 'lib/seatsio/events.rb', line 146 def mark_everything_as_for_sale(key: nil) @http_client.post("events/#{key}/actions/mark-everything-as-for-sale") end |
#release(event_key_or_keys, object_or_objects, hold_token: nil, order_id: nil, keep_extra_data: nil, ignore_channels: nil, channel_keys: nil) ⇒ Object
112 113 114 |
# File 'lib/seatsio/events.rb', line 112 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) end |
#retrieve(key:) ⇒ Object
120 121 122 123 |
# File 'lib/seatsio/events.rb', line 120 def retrieve(key:) response = @http_client.get("events/#{key}") Event.from_json(response) end |
#retrieve_object_info(key:, label:) ⇒ Object
57 58 59 60 |
# File 'lib/seatsio/events.rb', line 57 def retrieve_object_info(key:, label:) result = retrieve_object_infos key: key, labels: [label] result[label] end |
#retrieve_object_infos(key:, labels:) ⇒ Object
62 63 64 65 66 67 68 69 70 |
# File 'lib/seatsio/events.rb', line 62 def retrieve_object_infos(key:, labels:) url = "events/#{key}/objects" query_params = URI.encode_www_form(labels.map { |label| ['label', label] }) response = @http_client.get(url, query_params) response.each do |key, value| response[key] = EventObjectInfo.new(value) end response end |
#status_changes_for_object(key:, object_id:) ⇒ Object
137 138 139 |
# File 'lib/seatsio/events.rb', line 137 def status_changes_for_object(key:, object_id:) Pagination::Cursor.new(StatusChange, "/events/#{key}/objects/#{object_id}/status-changes", @http_client) end |
#update(key:, chart_key: nil, event_key: nil, table_booking_config: nil, social_distancing_ruleset_key: nil, object_categories: nil, categories: nil) ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/seatsio/events.rb', line 36 def update(key:, chart_key: nil, event_key: nil, table_booking_config: nil, social_distancing_ruleset_key: nil, object_categories: nil, categories: nil) payload = build_event_request( chart_key: chart_key, event_key: event_key, table_booking_config: table_booking_config, social_distancing_ruleset_key: , object_categories: object_categories, categories: categories) @http_client.post("/events/#{key}", payload) end |
#update_extra_data(key:, object:, extra_data: nil) ⇒ Object
47 48 49 50 |
# File 'lib/seatsio/events.rb', line 47 def update_extra_data(key:, object:, extra_data: nil) payload = build_extra_data_request(extra_data) @http_client.post("events/#{key}/objects/#{object}/actions/update-extra-data", payload) end |
#update_extra_datas(key:, extra_data:) ⇒ Object
52 53 54 55 |
# File 'lib/seatsio/events.rb', line 52 def update_extra_datas(key:, extra_data:) payload = build_extra_data_request(extra_data) @http_client.post("events/#{key}/actions/update-extra-data", payload) end |