Module: CloudConnect::Channels

Included in:
Client
Defined in:
lib/cloud_connect/client/channels.rb

Instance Method Summary collapse

Instance Method Details

#channels(reload = false) ⇒ Array of Hashie::Mash

Retrieve list of channels WARNING: This method uses calls not officially supported by Mobile Devices.

Returns:

  • (Array of Hashie::Mash)

    Channels



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

def channels(reload = false)
  return @channels if @channels && !reload
  page  = 1
  limit = 100
  channels = []
  while (slice = connection.get(connection.build_url("channels", :per_page => limit, :page => page)).body).size > 0
    page += 1
    channels += slice.map!{|hash| hash.values.first} if slice.size > 0
    slice.size < limit ? break : sleep(1)
  end
  @channels = channels.sort_by(&:channel)
end