Module: CloudConnect::Client::Channels

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

Defined Under Namespace

Modules: ChannelMethods

Instance Method Summary collapse

Instance Method Details

#channel(name, options = {}) ⇒ Channel

Get a channel

Examples:

Get channel 0123456789012345

@client = CloudConnect::Client.new(:account => 'foo', :token => 'bar')
@client.channel("0123456789012345")

Parameters:

  • name (String)

    Name of the channel

Returns:

  • (Channel)

    The channel you requested, if it exists

See Also:



12
13
14
# File 'lib/cloud_connect/client/channels.rb', line 12

def channel(name, options={})
  enhance( get("channels/#{name}", options), with: ChannelMethods )
end

#channels(options = {}) ⇒ Array Also known as: list_channels

Get channels

Examples:

List all channels

@client = CloudConnect::Client.new(:account => 'foo', :token => 'bar')
@client.channels

Returns:

  • (Array)

    A list of all channels

See Also:



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

def channels(options={})
  enhance( get("channels", options), with: ChannelMethods )
end

#create_channel(name, options = {}) ⇒ Channel

Create a channel

Examples:

Create a new Channel

@client = CloudConnect::CloudConnect.new(:account => 'foo', :token => 'bar')
@client.create_channel("weather")

Parameters:

  • name (String)

    Name of the channel

  • options (Hash) (defaults to: {})

    A customizable set of options

Returns:

  • (Channel)

    Your newly created channel

See Also:



52
53
54
# File 'lib/cloud_connect/client/channels.rb', line 52

def create_channel(name, options={})
  enhance( post("channels", options.merge({:name => name})), with: ChannelMethods )
end

#delete_channel(name, options = {}) ⇒ Response

Delete a single channel

Examples:

Delete the CUSTOM_SENSOR_TEMP channel

@client = CloudConnect::CloudConnect.new(:account => 'foo', :token => 'bar')
@client.delete_channel("com.acmecorp.weather")

Parameters:

  • name (String)

    Name fo the channel

Returns:

  • (Response)

    A response object with status

See Also:



80
81
82
# File 'lib/cloud_connect/client/channels.rb', line 80

def delete_channel(name, options={})
  delete("channels/#{name}", options, true)
end

#search_channels(search_term, options = {}) ⇒ Array

Search channels

Examples:

Search for ‘com.mdi.services.adminProtocol’ in the channels

@client = CloudConnect::Client.new(:account => 'foor', :token => 'bar')
@client.search_channels

Parameters:

  • search_term (String)

    The term to search for

Returns:

  • (Array)

    A list of channels matching the search term

See Also:



24
25
26
# File 'lib/cloud_connect/client/channels.rb', line 24

def search_channels(search_term, options={})
  enhance( get("channels?q=#{search_term}", options), with: ChannelMethods )
end

#update_channel(name, options = {}) ⇒ Channel

Update a channel

Examples:

Update a Channel

@client = CloudConnect::CloudConnect.new(:account => 'foo', :token => 'bar')
@client.create_channel("weather", :msgttl => 123, ...)

Parameters:

  • name (String)

    Name of the channel

  • options (Hash) (defaults to: {})

    A customizable set of options

Returns:

  • (Channel)

    Your newly updated channel

See Also:



68
69
70
# File 'lib/cloud_connect/client/channels.rb', line 68

def update_channel(name, options={})
  enhance( put("channels/#{name}", options.merge({:name => name})), with: ChannelMethods )
end