Class: Seatsio::EventsClient

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

Instance Method Summary collapse

Constructor Details

#initialize(http_client) ⇒ EventsClient

Returns a new instance of EventsClient.



14
15
16
# File 'lib/seatsio/events.rb', line 14

def initialize(http_client)
  @http_client = http_client
end

Instance Method Details

#assign_objects_to_channels(key:, channelConfig:) ⇒ Object



139
140
141
# File 'lib/seatsio/events.rb', line 139

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



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

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



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

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



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

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



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

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)
  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, ignore_social_distancing)
  request[:params] = {
      :expand => 'objects'
  }
  response = @http_client.post("seasons/actions/change-object-status", request)
  ChangeObjectStatusResult.new(response)
end

#change_object_status_in_batch(status_change_requests) ⇒ Object



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

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



18
19
20
21
22
23
# File 'lib/seatsio/events.rb', line 18

def create(chart_key: nil, event_key: nil, table_booking_config: nil, social_distancing_ruleset_key: nil)
  payload = build_event_request(chart_key: chart_key, event_key: event_key,
                                table_booking_config: table_booking_config, social_distancing_ruleset_key: social_distancing_ruleset_key)
  response = @http_client.post("events", payload)
  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)
  Events.new(response).events
end

#delete(key:) ⇒ Object



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

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



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

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



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

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



105
106
107
# File 'lib/seatsio/events.rb', line 105

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

#list_status_changes(key, object_id = nil) ⇒ Object



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

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



130
131
132
133
# File 'lib/seatsio/events.rb', line 130

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



121
122
123
124
# File 'lib/seatsio/events.rb', line 121

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



126
127
128
# File 'lib/seatsio/events.rb', line 126

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



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

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



100
101
102
103
# File 'lib/seatsio/events.rb', line 100

def retrieve(key:)
  response = @http_client.get("events/#{key}")
  Event.new(response)
end

#retrieve_object_status(key:, object_key:) ⇒ Object



46
47
48
49
50
# File 'lib/seatsio/events.rb', line 46

def retrieve_object_status(key:, object_key:)
  url = "events/#{key}/objects/#{CGI::escape(object_key).gsub('+', '%20')}"
  response = @http_client.get(url)
  ObjectStatus.new(response)
end

#status_changes_for_object(key:, object_id:) ⇒ Object



117
118
119
# File 'lib/seatsio/events.rb', line 117

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



31
32
33
34
# File 'lib/seatsio/events.rb', line 31

def update(key:, chart_key: nil, event_key: nil, table_booking_config: nil, social_distancing_ruleset_key: nil)
  payload = build_event_request(chart_key: chart_key, event_key: event_key, table_booking_config: table_booking_config, social_distancing_ruleset_key: social_distancing_ruleset_key)
  @http_client.post("/events/#{key}", payload)
end

#update_channels(key:, channels:) ⇒ Object



135
136
137
# File 'lib/seatsio/events.rb', line 135

def update_channels(key:, channels:)
  @http_client.post("events/#{key}/channels/update", channels: channels)
end

#update_extra_data(key:, object:, extra_data: nil) ⇒ Object



36
37
38
39
# File 'lib/seatsio/events.rb', line 36

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



41
42
43
44
# File 'lib/seatsio/events.rb', line 41

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