Module: CloudConnect::Client::Assets

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

Defined Under Namespace

Modules: AssetMethods

Instance Method Summary collapse

Instance Method Details

#asset(imei, options = {}) ⇒ Asset

Get an asset

Examples:

Get asset 0123456789012345

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

Parameters:

  • imei (String)

    IMEI of the asset

Returns:

  • (Asset)

    The asset you requested, if it exists

See Also:



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

def asset(imei, options={})
  enhance( get("assets/#{imei}", options), with: AssetMethods )
end

#assets(options = {}) ⇒ Array Also known as: list_assets

Get assets

Examples:

List all assets

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

Returns:

  • (Array)

    A list of all assets

See Also:



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

def assets(options={})
  enhance( get("assets", options), with: AssetMethods )
end

#create_asset(imei, options = {}) ⇒ Asset

Create an asset

Examples:

Create a new Asset

@client = CloudConnect::CloudConnect.new(:account => 'foo', :token => 'bar')
@client.create_asset("359551033822346", :name => 'General Lee', :serial => "50030000005322", :description => "The Dukes of Hazzard")

Parameters:

  • imei (String)

    IMEI of the asset

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

    A customizable set of options

Returns:

  • (Asset)

    Your newly created asset

See Also:



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

def create_asset(imei, options={})
  enhance( post("assets", options.merge({:imei => imei})), with: AssetMethods )
end

#delete_asset(imei, options = {}) ⇒ Response

Delete a single asset

Examples:

Delete the “359551033822346” asset

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

Parameters:

  • imei (String)

    IMEI fo the field

Returns:

  • (Response)

    A response object with status

See Also:



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

def delete_asset(imei, options={})
  delete("assets/#{imei}", options, true)
end

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

Search assets

Examples:

Search for ‘123’ in the assets

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

Parameters:

  • search_term (String)

    The term to search for

Returns:

  • (Array)

    A list of assets matching the search term

See Also:



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

def search_assets(search_term, options={})
  enhance( get("assets?q=#{search_term}", options), with: AssetMethods )
end

#update_asset(imei, options = {}) ⇒ Asset

Update an asset

Examples:

Update an Asset

@client = CloudConnect::CloudConnect.new(:account => 'foo', :token => 'bar')
@client.update_asset("359551033822346", :name => 'General Lee', :serial => "50030000005322", :description => "The Dukes of Hazzard")

Parameters:

  • imei (String)

    IMEI of the asset

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

    A customizable set of options

Returns:

  • (Asset)

    Your newly updated asset

See Also:



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

def update_asset(imei, options={})
  enhance( put("assets/#{imei}", options.merge({:imei => imei})), with: AssetMethods )
end