Module: GenesisClient::Devices

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

Instance Method Summary collapse

Instance Method Details

#create_device(sku) ⇒ Hashie::Mash

Create a new Device.

Parameters:

  • sku (String)

    The SKU of the new device

Returns:

  • (Hashie::Mash)

    Hash representing the device



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

def create_device(sku)
  post('/devices', sku: sku)['device']
end

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

Create a new Log for the current Remote Action for a Device.

Parameters:

  • sku (String)

    The SKU of the device

  • message (String)

    Log message

Returns:

  • (Hashie::Mash)

    Hash representing the log



57
58
59
60
# File 'lib/genesis_client/devices.rb', line 57

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

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

Create a new Log for a Device.

Parameters:

  • sku (String)

    The SKU of the device

  • message (String)

    Log message

Returns:

  • (Hashie::Mash)

    Hash representing the log



47
48
49
50
# File 'lib/genesis_client/devices.rb', line 47

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 (String)

    The SKU of the device

  • data (Hash)

    Device attributes to update

Returns:

  • (Hashie::Mash)

    Hash representing the device



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

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