Class: Seatsio::EventsClient

Inherits:
Object
  • Object
show all
Defined in:
lib/seatsio/events.rb

Instance Method Summary collapse

Constructor Details

#initialize(secret_key, workspace_key, base_url) ⇒ 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



141
142
143
# File 'lib/seatsio/events.rb', line 141

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, ignore_channels: nil, channel_keys: nil) ⇒ Object



53
54
55
# File 'lib/seatsio/events.rb', line 53

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, Domain::ObjectStatus::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) ⇒ Object



85
86
87
# File 'lib/seatsio/events.rb', line 85

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, Domain::ObjectStatus::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



79
80
81
82
83
# File 'lib/seatsio/events.rb', line 79

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)
  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, ignore_channels: nil, channel_keys: nil) ⇒ Object



57
58
59
60
61
62
63
64
# File 'lib/seatsio/events.rb', line 57

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)
  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)
  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



66
67
68
69
70
71
72
73
# File 'lib/seatsio/events.rb', line 66

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: 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



97
98
99
# File 'lib/seatsio/events.rb', line 97

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



75
76
77
# File 'lib/seatsio/events.rb', line 75

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, Domain::ObjectStatus::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) ⇒ Object



89
90
91
# File 'lib/seatsio/events.rb', line 89

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, Domain::ObjectStatus::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

#listObject



107
108
109
# File 'lib/seatsio/events.rb', line 107

def list
  Pagination::Cursor.new(Domain::Event, 'events', @http_client)
end

#list_status_changes(key, object_id = nil) ⇒ Object



111
112
113
114
115
116
117
# File 'lib/seatsio/events.rb', line 111

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



132
133
134
135
# File 'lib/seatsio/events.rb', line 132

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



123
124
125
126
# File 'lib/seatsio/events.rb', line 123

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



128
129
130
# File 'lib/seatsio/events.rb', line 128

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



93
94
95
# File 'lib/seatsio/events.rb', line 93

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, Domain::ObjectStatus::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



102
103
104
105
# File 'lib/seatsio/events.rb', line 102

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



119
120
121
# File 'lib/seatsio/events.rb', line 119

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: social_distancing_ruleset_key)
  @http_client.post("/events/#{key}", payload)
end

#update_channels(key:, channels:) ⇒ Object



137
138
139
# File 'lib/seatsio/events.rb', line 137

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