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) ⇒ 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) ⇒ 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
73 74 75 |
# File 'lib/seatsio/events.rb', line 73 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
105 106 107 |
# File 'lib/seatsio/events.rb', line 105 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
99 100 101 102 103 |
# File 'lib/seatsio/events.rb', line 99 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
77 78 79 80 81 82 83 84 |
# File 'lib/seatsio/events.rb', line 77 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
86 87 88 89 90 91 92 93 |
# File 'lib/seatsio/events.rb', line 86 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) ⇒ Object
21 22 23 24 25 26 27 28 |
# 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) payload = build_event_request(chart_key: chart_key, event_key: event_key, name: name, date: date, table_booking_config: table_booking_config, 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
117 118 119 |
# File 'lib/seatsio/events.rb', line 117 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
95 96 97 |
# File 'lib/seatsio/events.rb', line 95 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
109 110 111 |
# File 'lib/seatsio/events.rb', line 109 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
126 127 128 |
# File 'lib/seatsio/events.rb', line 126 def list Pagination::Cursor.new(Event, 'events', @http_client) end |
#list_status_changes(key, object_id = nil) ⇒ Object
130 131 132 133 134 135 136 |
# File 'lib/seatsio/events.rb', line 130 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
151 152 153 154 |
# File 'lib/seatsio/events.rb', line 151 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
142 143 144 145 |
# File 'lib/seatsio/events.rb', line 142 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
147 148 149 |
# File 'lib/seatsio/events.rb', line 147 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
113 114 115 |
# File 'lib/seatsio/events.rb', line 113 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
121 122 123 124 |
# File 'lib/seatsio/events.rb', line 121 def retrieve(key:) response = @http_client.get("events/#{key}") Event.from_json(response) end |
#retrieve_object_info(key:, label:) ⇒ Object
58 59 60 61 |
# File 'lib/seatsio/events.rb', line 58 def retrieve_object_info(key:, label:) result = retrieve_object_infos key: key, labels: [label] result[label] end |
#retrieve_object_infos(key:, labels:) ⇒ Object
63 64 65 66 67 68 69 70 71 |
# File 'lib/seatsio/events.rb', line 63 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
138 139 140 |
# File 'lib/seatsio/events.rb', line 138 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) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/seatsio/events.rb', line 36 def update(key:, chart_key: nil, event_key: nil, name: nil, date: nil, table_booking_config: nil, object_categories: nil, categories: nil) payload = build_event_request( chart_key: chart_key, event_key: event_key, name: name, date: date, table_booking_config: table_booking_config, object_categories: object_categories, categories: categories) @http_client.post("/events/#{key}", payload) end |
#update_extra_data(key:, object:, extra_data: nil) ⇒ Object
48 49 50 51 |
# File 'lib/seatsio/events.rb', line 48 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
53 54 55 56 |
# File 'lib/seatsio/events.rb', line 53 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 |