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) ⇒ 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, try_to_prevent_orphan_seats: 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, try_to_prevent_orphan_seats: 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, 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, name: nil, date: nil, table_booking_config: nil, object_categories: nil, categories: nil, channels: nil, for_sale_config: 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) ⇒ 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, try_to_prevent_orphan_seats: 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, name: nil, date: nil, table_booking_config: nil, object_categories: nil, categories: nil, is_in_the_past: 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) ⇒ Object
63 64 65 |
# File 'lib/seatsio/events.rb', line 63 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) 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) 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, try_to_prevent_orphan_seats: nil) ⇒ Object
95 96 97 |
# File 'lib/seatsio/events.rb', line 95 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, try_to_prevent_orphan_seats: 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, try_to_prevent_orphan_seats: try_to_prevent_orphan_seats) 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, try_to_prevent_orphan_seats: nil) ⇒ Object
89 90 91 92 93 |
# File 'lib/seatsio/events.rb', line 89 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, try_to_prevent_orphan_seats: 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, try_to_prevent_orphan_seats) 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, allowed_previous_statuses: nil, rejected_previous_statuses: nil) ⇒ Object
67 68 69 70 71 72 73 74 |
# File 'lib/seatsio/events.rb', line 67 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, 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
76 77 78 79 80 81 82 83 |
# File 'lib/seatsio/events.rb', line 76 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, name: nil, date: nil, table_booking_config: nil, object_categories: nil, categories: nil, channels: nil, for_sale_config: nil) ⇒ Object
21 22 23 24 25 |
# File 'lib/seatsio/events.rb', line 21 def create(chart_key: nil, event_key: nil, name: nil, date: nil, table_booking_config: nil, object_categories: nil, categories: nil, channels: nil, for_sale_config: nil) payload = build_event_request(chart_key, event_key, name, date, table_booking_config, object_categories, categories, channels: channels, is_in_the_past: nil, for_sale_config: for_sale_config) response = @http_client.post("events", payload) Event.new(response) end |
#create_multiple(key: nil, event_creation_params: nil) ⇒ Object
27 28 29 30 31 |
# File 'lib/seatsio/events.rb', line 27 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
107 108 109 |
# File 'lib/seatsio/events.rb', line 107 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) ⇒ Object
85 86 87 |
# File 'lib/seatsio/events.rb', line 85 def hold(event_key_or_keys, object_or_objects, hold_token, 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::HELD, hold_token: hold_token, order_id: order_id, keep_extra_data: keep_extra_data, ignore_channels: ignore_channels, channel_keys: channel_keys) 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, try_to_prevent_orphan_seats: nil) ⇒ Object
99 100 101 |
# File 'lib/seatsio/events.rb', line 99 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, try_to_prevent_orphan_seats: 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, try_to_prevent_orphan_seats: try_to_prevent_orphan_seats) end |
#list ⇒ Object
116 117 118 |
# File 'lib/seatsio/events.rb', line 116 def list Pagination::Cursor.new(Event, 'events', @http_client) end |
#list_status_changes(key, object_id = nil) ⇒ Object
120 121 122 123 124 125 126 |
# File 'lib/seatsio/events.rb', line 120 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
141 142 143 144 |
# File 'lib/seatsio/events.rb', line 141 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
132 133 134 135 |
# File 'lib/seatsio/events.rb', line 132 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
137 138 139 |
# File 'lib/seatsio/events.rb', line 137 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
103 104 105 |
# File 'lib/seatsio/events.rb', line 103 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
111 112 113 114 |
# File 'lib/seatsio/events.rb', line 111 def retrieve(key:) response = @http_client.get("events/#{key}") Event.from_json(response) end |
#retrieve_object_info(key:, label:) ⇒ Object
48 49 50 51 |
# File 'lib/seatsio/events.rb', line 48 def retrieve_object_info(key:, label:) result = retrieve_object_infos key: key, labels: [label] result[label] end |
#retrieve_object_infos(key:, labels:) ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'lib/seatsio/events.rb', line 53 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
128 129 130 |
# File 'lib/seatsio/events.rb', line 128 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, name: nil, date: nil, table_booking_config: nil, object_categories: nil, categories: nil, is_in_the_past: nil) ⇒ Object
33 34 35 36 |
# File 'lib/seatsio/events.rb', line 33 def update(key:, chart_key: nil, event_key: nil, name: nil, date: nil, table_booking_config: nil, object_categories: nil, categories: nil, is_in_the_past: nil) payload = build_event_request(chart_key, event_key, name, date, table_booking_config, object_categories, categories, channels: nil, is_in_the_past: is_in_the_past) @http_client.post("/events/#{key}", payload) end |
#update_extra_data(key:, object:, extra_data: nil) ⇒ Object
38 39 40 41 |
# File 'lib/seatsio/events.rb', line 38 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
43 44 45 46 |
# File 'lib/seatsio/events.rb', line 43 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 |