Module: GenesisClient::Devices

Included in:
Client
Defined in:
lib/genesis_client/devices.rb

Instance Method Summary collapse

Instance Method Details

#create_device_log(sku, message) ⇒ Hashie::Mash

Create a new Log for a Device.

Parameters:

  • sku (Integer)

    The SKU of the device

  • message (String)

    Log message

Returns:

  • (Hashie::Mash)

    Hash representing the log



39
40
41
42
# File 'lib/genesis_client/devices.rb', line 39

def create_device_log(sku, message)
  data = { message: message }
  post("/devices/#{sku}/logs", data)['log']
end

#device(sku) ⇒ Hashie::Mash

Receive a single Device.

Examples:

client = GenesisClient::Client.new
client.device('UNK-12345534')

Parameters:

  • sku (String)

    The SKU of the device

Returns:

  • (Hashie::Mash)

    Hash representing the device.



21
22
23
# File 'lib/genesis_client/devices.rb', line 21

def device(sku)
  get("/devices/#{sku}")['device']
end

#devices(type = nil) ⇒ Array<Hashie::Mash> Also known as: list_devices

Receive a list of all Devices.

Examples:

client = GenesisClient::Client.new
client.devices

Returns:

  • (Array<Hashie::Mash>)

    Array of hashes representing devices.



9
10
11
# File 'lib/genesis_client/devices.rb', line 9

def devices(type = nil)
  (type.nil? ? get('/devices') : get("/devices?type=#{type}"))['devices']
end

#update_device(sku, data) ⇒ Hashie::Mash

Modify an existing Device.

Parameters:

  • sku (Integer)

    The SKU of the device

  • data (Hash)

    Device attributes to update

Returns:

  • (Hashie::Mash)

    Hash representing the device



30
31
32
# File 'lib/genesis_client/devices.rb', line 30

def update_device(sku, data)
  put("/devices/#{sku}", data)['device']
end