Class: Seatsio::EventsClient

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

Instance Attribute 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

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



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

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



111
112
113
# File 'lib/seatsio/events.rb', line 111

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



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

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, accessible_seats: nil)
  request = create_change_best_available_object_status_request(number, status, categories, zone, 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) ⇒ Object



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

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



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

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



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

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



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

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



115
116
117
# File 'lib/seatsio/events.rb', line 115

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

#listObject



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

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

#list_status_changes(key, object_id = nil) ⇒ Object



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

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



162
163
164
165
# File 'lib/seatsio/events.rb', line 162

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



153
154
155
156
# File 'lib/seatsio/events.rb', line 153

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



158
159
160
# File 'lib/seatsio/events.rb', line 158

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

#override_season_object_status(key:, objects:) ⇒ Object



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

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

#put_up_for_resale(event_key_or_keys, object_or_objects) ⇒ Object



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

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



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

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

#retrieve(key:) ⇒ Object



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

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

#retrieve_object_info(key:, label:) ⇒ Object



60
61
62
63
# File 'lib/seatsio/events.rb', line 60

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

#retrieve_object_infos(key:, labels:) ⇒ Object



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

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



149
150
151
# File 'lib/seatsio/events.rb', line 149

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



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

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



55
56
57
58
# File 'lib/seatsio/events.rb', line 55

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



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

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