Class: Seatsio::ChannelsClient

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

Class Method Summary collapse

Instance Method Summary collapse

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



47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/seatsio/channels.rb', line 47

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
    result.push(r)
  end
  result
end

Instance Method Details

#add(event_key:, channel_key:, channel_name:, channel_color:, index: nil, objects: nil) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/seatsio/channels.rb', line 8

def add(event_key:, channel_key:, channel_name:, channel_color:, index: nil, objects: nil)
  payload = {
    key: channel_key,
    name: channel_name,
    color: channel_color
  }
  payload['index'] = index if index != nil
  payload['objects'] = objects if objects != nil
  @http_client.post("events/#{event_key}/channels", payload)
end

#add_multiple(event_key:, channel_creation_properties:) ⇒ Object



19
20
21
# File 'lib/seatsio/channels.rb', line 19

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



35
36
37
# File 'lib/seatsio/channels.rb', line 35

def add_objects(event_key:, channel_key:, objects:)
  @http_client.post("events/#{event_key}/channels/#{channel_key}/objects", { objects: objects })
end

#remove(event_key:, channel_key:) ⇒ Object



23
24
25
# File 'lib/seatsio/channels.rb', line 23

def remove(event_key:, channel_key:)
  @http_client.delete("events/#{event_key}/channels/#{channel_key}")
end

#remove_objects(event_key:, channel_key:, objects:) ⇒ Object



39
40
41
# File 'lib/seatsio/channels.rb', line 39

def remove_objects(event_key:, channel_key:, objects:)
  @http_client.delete("events/#{event_key}/channels/#{channel_key}/objects", { objects: objects })
end

#replace(key:, channels:) ⇒ Object



43
44
45
# File 'lib/seatsio/channels.rb', line 43

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



27
28
29
30
31
32
33
# File 'lib/seatsio/channels.rb', line 27

def update(event_key:, channel_key:, channel_name: nil, channel_color: nil, objects: nil)
  payload = {}
  payload['name'] = channel_name if channel_name != nil
  payload['color'] = channel_color if channel_color != nil
  payload['objects'] = objects if objects != nil
  @http_client.post("events/#{event_key}/channels/#{channel_key}", payload)
end