Class: Seatsio::EventsClient
- Inherits:
-
Object
- Object
- Seatsio::EventsClient
- Defined in:
- lib/seatsio/events.rb
Instance Method Summary collapse
- #assign_objects_to_channels(key:, channelConfig:) ⇒ Object
- #book(event_key_or_keys, object_or_objects, hold_token = nil, order_id = nil, keep_extra_data = nil) ⇒ Object
- #book_best_available(key, number, categories: nil, hold_token: nil, order_id: nil, keep_extra_data: nil, extra_data: nil) ⇒ Object
- #change_best_available_object_status(key, number, status, categories: nil, hold_token: nil, extra_data: nil, order_id: nil, keep_extra_data: nil) ⇒ Object
- #change_object_status(event_key_or_keys, object_or_objects, status, hold_token = nil, order_id = nil, keep_extra_data = nil) ⇒ Object
- #change_object_status_in_batch(status_change_requests) ⇒ Object
- #create(chart_key: nil, event_key: nil, book_whole_tables: nil, table_booking_modes: nil, social_distancing_ruleset_key: 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) ⇒ Object
- #hold_best_available(key, number, hold_token, categories: nil, order_id: nil, keep_extra_data: nil, extra_data: nil) ⇒ Object
-
#initialize(secret_key, workspace_key, base_url) ⇒ EventsClient
constructor
A new instance of EventsClient.
- #list ⇒ Object
- #list_status_changes(key, object_id = nil) ⇒ Object
- #mark_as_for_sale(key:, objects: nil, categories: nil) ⇒ Object
- #mark_as_not_for_sale(key:, objects: 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) ⇒ Object
- #retrieve(key:) ⇒ Object
- #retrieve_object_status(key:, object_key:) ⇒ Object
- #status_changes_for_object(key:, object_id:) ⇒ Object
- #update(key:, chart_key: nil, event_key: nil, book_whole_tables: nil, table_booking_modes: nil, social_distancing_ruleset_key: nil) ⇒ Object
- #update_channels(key:, channels:) ⇒ Object
- #update_extra_data(key:, object:, extra_data: nil) ⇒ Object
- #update_extra_datas(key:, extra_data:) ⇒ Object
Constructor Details
#initialize(secret_key, workspace_key, base_url) ⇒ EventsClient
Returns a new instance of EventsClient.
14 15 16 |
# File 'lib/seatsio/events.rb', line 14 def initialize(secret_key, workspace_key, base_url) @http_client = ::Seatsio::HttpClient.new(secret_key, workspace_key, base_url) end |
Instance Method Details
#assign_objects_to_channels(key:, channelConfig:) ⇒ Object
145 146 147 |
# File 'lib/seatsio/events.rb', line 145 def assign_objects_to_channels(key:, channelConfig:) @http_client.post("events/#{key}/channels/assign-objects", channelConfig: channelConfig) end |
#book(event_key_or_keys, object_or_objects, hold_token = nil, order_id = nil, keep_extra_data = nil) ⇒ Object
57 58 59 |
# File 'lib/seatsio/events.rb', line 57 def book(event_key_or_keys, object_or_objects, hold_token = nil, order_id = nil, keep_extra_data = nil) self.change_object_status(event_key_or_keys, object_or_objects, Domain::ObjectStatus::BOOKED, hold_token, order_id, keep_extra_data) end |
#book_best_available(key, number, categories: nil, hold_token: nil, order_id: nil, keep_extra_data: nil, extra_data: nil) ⇒ Object
89 90 91 |
# File 'lib/seatsio/events.rb', line 89 def book_best_available(key, number, categories: nil, hold_token: nil, order_id: nil, keep_extra_data: nil, extra_data: nil) change_best_available_object_status(key, number, Domain::ObjectStatus::BOOKED, categories: categories, hold_token: hold_token, order_id: order_id, keep_extra_data: keep_extra_data, extra_data: extra_data) end |
#change_best_available_object_status(key, number, status, categories: nil, hold_token: nil, extra_data: nil, order_id: nil, keep_extra_data: nil) ⇒ Object
83 84 85 86 87 |
# File 'lib/seatsio/events.rb', line 83 def change_best_available_object_status(key, number, status, categories: nil, hold_token: nil, extra_data: nil, order_id: nil, keep_extra_data: nil) request = create_change_best_available_object_status_request(number, status, categories, extra_data, hold_token, order_id, keep_extra_data) response = @http_client.post("events/#{key}/actions/change-object-status", request) Domain::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) ⇒ Object
61 62 63 64 65 66 67 68 |
# File 'lib/seatsio/events.rb', line 61 def change_object_status(event_key_or_keys, object_or_objects, status, hold_token = nil, order_id = nil, keep_extra_data = nil) request = create_change_object_status_request(object_or_objects, status, hold_token, order_id, event_key_or_keys, keep_extra_data) request[:params] = { :expand => 'objects' } response = @http_client.post("seasons/actions/change-object-status", request) Domain::ChangeObjectStatusResult.new(response) end |
#change_object_status_in_batch(status_change_requests) ⇒ Object
70 71 72 73 74 75 76 77 |
# File 'lib/seatsio/events.rb', line 70 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) Domain::ChangeObjectStatusInBatchResult.new(response).results end |
#create(chart_key: nil, event_key: nil, book_whole_tables: nil, table_booking_modes: nil, social_distancing_ruleset_key: nil) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/seatsio/events.rb', line 18 def create(chart_key: nil, event_key: nil, book_whole_tables: nil, table_booking_modes: nil, social_distancing_ruleset_key: nil) payload = build_event_request(chart_key: chart_key, event_key: event_key, book_whole_tables: book_whole_tables, table_booking_modes: table_booking_modes, social_distancing_ruleset_key: ) response = @http_client.post("events", payload) Domain::Event.new(response) end |
#create_multiple(key: nil, event_creation_params: nil) ⇒ Object
25 26 27 28 29 |
# File 'lib/seatsio/events.rb', line 25 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) Domain::Events.new(response).events end |
#delete(key:) ⇒ Object
101 102 103 |
# File 'lib/seatsio/events.rb', line 101 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) ⇒ Object
79 80 81 |
# File 'lib/seatsio/events.rb', line 79 def hold(event_key_or_keys, object_or_objects, hold_token, order_id = nil, keep_extra_data = nil) change_object_status(event_key_or_keys, object_or_objects, Domain::ObjectStatus::HELD, hold_token, order_id, keep_extra_data) end |
#hold_best_available(key, number, hold_token, categories: nil, order_id: nil, keep_extra_data: nil, extra_data: nil) ⇒ Object
93 94 95 |
# File 'lib/seatsio/events.rb', line 93 def hold_best_available(key, number, hold_token, categories: nil, order_id: nil, keep_extra_data: nil, extra_data: nil) change_best_available_object_status(key, number, Domain::ObjectStatus::HELD, categories: categories, hold_token: hold_token, order_id: order_id, keep_extra_data: keep_extra_data, extra_data: extra_data) end |
#list ⇒ Object
111 112 113 |
# File 'lib/seatsio/events.rb', line 111 def list Pagination::Cursor.new(Domain::Event, 'events', @http_client) end |
#list_status_changes(key, object_id = nil) ⇒ Object
115 116 117 118 119 120 121 |
# File 'lib/seatsio/events.rb', line 115 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(Domain::StatusChange, "/events/#{key}/status-changes", @http_client) end end |
#mark_as_for_sale(key:, objects: nil, categories: nil) ⇒ Object
136 137 138 139 |
# File 'lib/seatsio/events.rb', line 136 def mark_as_for_sale(key:, objects: nil, categories: nil) request = build_parameters_for_mark_as_sale objects: objects, categories: categories @http_client.post("events/#{key}/actions/mark-as-for-sale", request) end |
#mark_as_not_for_sale(key:, objects: nil, categories: nil) ⇒ Object
127 128 129 130 |
# File 'lib/seatsio/events.rb', line 127 def mark_as_not_for_sale(key:, objects: nil, categories: nil) request = build_parameters_for_mark_as_sale objects: objects, categories: categories @http_client.post("events/#{key}/actions/mark-as-not-for-sale", request) end |
#mark_everything_as_for_sale(key: nil) ⇒ Object
132 133 134 |
# File 'lib/seatsio/events.rb', line 132 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) ⇒ Object
97 98 99 |
# File 'lib/seatsio/events.rb', line 97 def release(event_key_or_keys, object_or_objects, hold_token = nil, order_id = nil, keep_extra_data = nil) change_object_status(event_key_or_keys, object_or_objects, Domain::ObjectStatus::FREE, hold_token, order_id, keep_extra_data) end |
#retrieve(key:) ⇒ Object
106 107 108 109 |
# File 'lib/seatsio/events.rb', line 106 def retrieve(key:) response = @http_client.get("events/#{key}") Domain::Event.new(response) end |
#retrieve_object_status(key:, object_key:) ⇒ Object
47 48 49 50 51 |
# File 'lib/seatsio/events.rb', line 47 def retrieve_object_status(key:, object_key:) url = "events/#{key}/objects/#{CGI::escape(object_key).gsub('+', '%20')}" response = @http_client.get(url) Domain::ObjectStatus.new(response) end |
#status_changes_for_object(key:, object_id:) ⇒ Object
123 124 125 |
# File 'lib/seatsio/events.rb', line 123 def status_changes_for_object(key:, object_id:) Pagination::Cursor.new(Domain::StatusChange, "/events/#{key}/objects/#{object_id}/status-changes", @http_client) end |
#update(key:, chart_key: nil, event_key: nil, book_whole_tables: nil, table_booking_modes: nil, social_distancing_ruleset_key: nil) ⇒ Object
31 32 33 34 35 |
# File 'lib/seatsio/events.rb', line 31 def update(key:, chart_key: nil, event_key: nil, book_whole_tables: nil, table_booking_modes: nil, social_distancing_ruleset_key: nil) payload = build_event_request(chart_key: chart_key, event_key: event_key, book_whole_tables: book_whole_tables, table_booking_modes: table_booking_modes, social_distancing_ruleset_key: ) @http_client.post("/events/#{key}", payload) end |
#update_channels(key:, channels:) ⇒ Object
141 142 143 |
# File 'lib/seatsio/events.rb', line 141 def update_channels(key:, channels:) @http_client.post("events/#{key}/channels/update", channels: channels) end |
#update_extra_data(key:, object:, extra_data: nil) ⇒ Object
37 38 39 40 |
# File 'lib/seatsio/events.rb', line 37 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
42 43 44 45 |
# File 'lib/seatsio/events.rb', line 42 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 |