Class: Seatsio::EventsClient

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#channelsObject (readonly)

Returns the value of attribute channels.



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

def channels
  @channels
end

Class Method Details

.categories_to_request(categories) ⇒ Object



204
205
206
207
208
209
210
211
212
213
214
215
# File 'lib/seatsio/events.rb', line 204

def self.categories_to_request(categories)
  result = []
  categories.each do |category|
    r = {}
    r["key"] = category.key if category.key != nil
    r["label"] = category.label if category.label != nil
    r["color"] = category.color if category.color != nil
    r["accessible"] = category.accessible if category.accessible != nil
    result.push(r)
  end
  result
end

.for_sale_config_to_request(for_sale_config) ⇒ Object



217
218
219
220
221
222
223
224
# File 'lib/seatsio/events.rb', line 217

def self.for_sale_config_to_request(for_sale_config)
  result = {}
  result["forSale"] = for_sale_config.for_sale
  result["objects"] = for_sale_config.objects if for_sale_config.objects != nil
  result["areaPlaces"] = for_sale_config.area_places if for_sale_config.area_places != nil
  result["categories"] = for_sale_config.categories if for_sale_config.categories != nil
  result
end

.table_booking_config_to_request(table_booking_config) ⇒ Object



197
198
199
200
201
202
# File 'lib/seatsio/events.rb', line 197

def self.table_booking_config_to_request(table_booking_config)
  result = {}
  result["mode"] = table_booking_config.mode
  result["tables"] = table_booking_config.tables if table_booking_config.tables != nil
  result
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



77
78
79
# File 'lib/seatsio/events.rb', line 77

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



113
114
115
# File 'lib/seatsio/events.rb', line 113

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, zone: nil, sections: 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, zone: zone, sections: sections)
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, zone: nil, sections: nil, accessible_seats: nil) ⇒ Object



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

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, zone: nil, sections: nil, accessible_seats: nil)
  request = create_change_best_available_object_status_request(number, status, categories, zone, sections, extra_data, ticket_types, hold_token, order_id, keep_extra_data, ignore_channels, channel_keys, try_to_prevent_orphan_seats, accessible_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, resale_listing_id: nil) ⇒ Object



85
86
87
88
89
90
91
92
# File 'lib/seatsio/events.rb', line 85

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, resale_listing_id: nil)
  request = create_change_object_status_request(Seatsio::StatusChangeType::CHANGE_STATUS_TO, 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, resale_listing_id)
  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



94
95
96
97
98
99
100
101
# File 'lib/seatsio/events.rb', line 94

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



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

def delete(key:)
  @http_client.delete("events/#{key}")
end

#edit_for_sale_config(key:, for_sale: nil, not_for_sale: nil) ⇒ Object



155
156
157
158
159
160
161
# File 'lib/seatsio/events.rb', line 155

def edit_for_sale_config(key:, for_sale: nil, not_for_sale: nil)
  request = {}
  request[:forSale] = for_sale if for_sale
  request[:notForSale] = not_for_sale if not_for_sale
  response = @http_client.post("events/#{key}/actions/edit-for-sale-config", request)
  EditForSaleConfigResult.from_json(response)
end

#edit_for_sale_config_for_events(events) ⇒ Object



163
164
165
166
167
168
169
170
# File 'lib/seatsio/events.rb', line 163

def edit_for_sale_config_for_events(events)
  request = build_parameters_for_edit_for_sale_config_for_events(events)
  response = @http_client.post("events/actions/edit-for-sale-config", request)
  response.each do |key, value|
    response[key] = EditForSaleConfigResult.from_json(value)
  end
  response
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



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

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



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

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, zone: nil, sections: 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, zone: zone, sections: sections)
end

#listObject



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

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

#list_status_changes(key, object_id = nil) ⇒ Object



143
144
145
146
147
148
149
# File 'lib/seatsio/events.rb', line 143

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

Deprecated.


184
185
186
# File 'lib/seatsio/events.rb', line 184

def mark_as_for_sale(key:, objects: nil, area_places: nil, categories: nil)
  replace_for_sale_config(key: key, for_sale: true, objects: objects, area_places: area_places, categories: categories)
end

#mark_as_not_for_sale(key:, objects: nil, area_places: nil, categories: nil) ⇒ Object

Deprecated.


179
180
181
# File 'lib/seatsio/events.rb', line 179

def mark_as_not_for_sale(key:, objects: nil, area_places: nil, categories: nil)
  replace_for_sale_config(key: key, for_sale: false, objects: objects, area_places: area_places, categories: categories)
end

#mark_everything_as_for_sale(key: nil) ⇒ Object



188
189
190
# File 'lib/seatsio/events.rb', line 188

def mark_everything_as_for_sale(key: nil)
  @http_client.post("events/#{key}/actions/mark-everything-as-for-sale")
end

#move_to_new_chart_copy(event_key) ⇒ Object



192
193
194
195
# File 'lib/seatsio/events.rb', line 192

def move_to_new_chart_copy(event_key)
  response = @http_client.post("events/#{event_key}/actions/move-to-new-chart-copy")
  Event.from_json(response)
end

#override_season_object_status(key:, objects:, season: nil) ⇒ Object



38
39
40
41
42
43
# File 'lib/seatsio/events.rb', line 38

def override_season_object_status(key:, objects:, season: nil)
  request = {}
  request[:objects] = objects
  request[:season] = season if season != nil
  @http_client.post("events/#{key}/actions/override-season-status", request)
end

#put_up_for_resale(event_key_or_keys, object_or_objects, resale_listing_id: nil) ⇒ Object



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

def put_up_for_resale(event_key_or_keys, object_or_objects, resale_listing_id: nil)
  self.change_object_status(event_key_or_keys, object_or_objects, Seatsio::EventObjectInfo::RESALE, resale_listing_id: resale_listing_id)
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



121
122
123
124
125
126
127
128
# File 'lib/seatsio/events.rb', line 121

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)
  request = create_change_object_status_request(Seatsio::StatusChangeType::RELEASE, object_or_objects, nil, hold_token, order_id, event_key_or_keys, keep_extra_data, ignore_channels, channel_keys, nil, nil, nil)
  request[:params] = {
    :expand => 'objects'
  }
  response = @http_client.post("events/groups/actions/change-object-status", request)
  ChangeObjectStatusResult.new(response)
end

#replace_for_sale_config(key:, for_sale:, objects: nil, area_places: nil, categories: nil) ⇒ Object



172
173
174
175
176
# File 'lib/seatsio/events.rb', line 172

def replace_for_sale_config(key:, for_sale:, objects: nil, area_places: nil, categories: nil)
  action = for_sale ? "mark-as-for-sale" : "mark-as-not-for-sale"
  request = build_parameters_for_mark_as_sale objects, area_places, categories
  @http_client.post("events/#{key}/actions/#{action}", request)
end

#retrieve(key:) ⇒ Object



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

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

#retrieve_object_info(key:, label:) ⇒ Object



62
63
64
65
# File 'lib/seatsio/events.rb', line 62

def retrieve_object_info(key:, label:)
  result = retrieve_object_infos key: key, labels: [label]
  result[label]
end

#retrieve_object_infos(key:, labels:) ⇒ Object



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

def retrieve_object_infos(key:, labels:)
  url = "events/#{key}/objects"
  query_params = URI.encode_www_form({ label: labels })
  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



151
152
153
# File 'lib/seatsio/events.rb', line 151

def status_changes_for_object(key:, object_id:)
  Pagination::Cursor.new(StatusChange, "events/#{key}/objects/#{object_id}/status-changes", @http_client)
end

#update(key:, 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:, 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(nil, 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



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

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



57
58
59
60
# File 'lib/seatsio/events.rb', line 57

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

#use_season_object_status(key:, objects:, season: nil) ⇒ Object



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

def use_season_object_status(key:, objects:, season: nil)
  request = {}
  request[:objects] = objects
  request[:season] = season if season != nil
  @http_client.post("events/#{key}/actions/use-season-status", request)
end