Class: Seatsio::ChannelsClient
- Inherits:
-
Object
- Object
- Seatsio::ChannelsClient
- Defined in:
- lib/seatsio/channels.rb
Class Method Summary collapse
Instance Method Summary collapse
- #add(event_key:, channel_key:, channel_name:, channel_color:, index: nil, objects: nil, area_places: nil) ⇒ Object
- #add_multiple(event_key:, channel_creation_properties:) ⇒ Object
- #add_objects(event_key:, channel_key:, objects: nil, area_places: nil) ⇒ Object
-
#initialize(http_client) ⇒ ChannelsClient
constructor
A new instance of ChannelsClient.
- #remove(event_key:, channel_key:) ⇒ Object
- #remove_objects(event_key:, channel_key:, objects: nil, area_places: nil) ⇒ Object
- #replace(key:, channels:) ⇒ Object
- #update(event_key:, channel_key:, channel_name: nil, channel_color: nil, objects: nil, area_places: nil) ⇒ Object
Constructor Details
#initialize(http_client) ⇒ ChannelsClient
Returns a new instance of ChannelsClient.
4 5 6 |
# File 'lib/seatsio/channels.rb', line 4 def initialize(http_client) @http_client = http_client end |
Class Method Details
.channels_to_request(channels) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/seatsio/channels.rb', line 55 def self.channels_to_request(channels) result = [] channels.each do |channel| r = {} r["key"] = channel.key r["name"] = channel.name r["color"] = channel.color r["index"] = channel.index if channel.index != nil r["objects"] = channel.objects if channel.objects != nil r["areaPlaces"] = channel.area_places if channel.area_places != nil result.push(r) end result end |
Instance Method Details
#add(event_key:, channel_key:, channel_name:, channel_color:, index: nil, objects: nil, area_places: nil) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/seatsio/channels.rb', line 8 def add(event_key:, channel_key:, channel_name:, channel_color:, index: nil, objects: nil, area_places: nil) payload = { key: channel_key, name: channel_name, color: channel_color } payload['index'] = index if index != nil payload['objects'] = objects if objects != nil payload['areaPlaces'] = area_places if area_places != nil @http_client.post("events/#{event_key}/channels", payload) end |
#add_multiple(event_key:, channel_creation_properties:) ⇒ Object
20 21 22 |
# File 'lib/seatsio/channels.rb', line 20 def add_multiple(event_key:, channel_creation_properties:) @http_client.post("events/#{event_key}/channels", channel_creation_properties) end |
#add_objects(event_key:, channel_key:, objects: nil, area_places: nil) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/seatsio/channels.rb', line 37 def add_objects(event_key:, channel_key:, objects: nil, area_places: nil) payload = {} payload['objects'] = objects if objects != nil payload['areaPlaces'] = area_places if area_places != nil @http_client.post("events/#{event_key}/channels/#{channel_key}/objects", payload) end |
#remove(event_key:, channel_key:) ⇒ Object
24 25 26 |
# File 'lib/seatsio/channels.rb', line 24 def remove(event_key:, channel_key:) @http_client.delete("events/#{event_key}/channels/#{channel_key}") end |
#remove_objects(event_key:, channel_key:, objects: nil, area_places: nil) ⇒ Object
44 45 46 47 48 49 |
# File 'lib/seatsio/channels.rb', line 44 def remove_objects(event_key:, channel_key:, objects: nil, area_places: nil) payload = {} payload['objects'] = objects if objects != nil payload['areaPlaces'] = area_places if area_places != nil @http_client.delete("events/#{event_key}/channels/#{channel_key}/objects", payload) end |
#replace(key:, channels:) ⇒ Object
51 52 53 |
# File 'lib/seatsio/channels.rb', line 51 def replace(key:, channels:) @http_client.post("events/#{key}/channels/replace", { channels: ChannelsClient::channels_to_request(channels) }) end |
#update(event_key:, channel_key:, channel_name: nil, channel_color: nil, objects: nil, area_places: nil) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/seatsio/channels.rb', line 28 def update(event_key:, channel_key:, channel_name: nil, channel_color: nil, objects: nil, area_places: nil) payload = {} payload['name'] = channel_name if channel_name != nil payload['color'] = channel_color if channel_color != nil payload['objects'] = objects if objects != nil payload['areaPlaces'] = area_places if area_places != nil @http_client.post("events/#{event_key}/channels/#{channel_key}", payload) end |