Class: SimpleMDM::DeviceGroup

Inherits:
Base
  • Object
show all
Defined in:
lib/simplemdm/device_group.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

build

Class Method Details

.allObject



4
5
6
7
8
# File 'lib/simplemdm/device_group.rb', line 4

def self.all
  hash, code = fetch("device_groups")

  hash['data'].collect { |d| build d }
end

.find(id) ⇒ Object



10
11
12
13
14
# File 'lib/simplemdm/device_group.rb', line 10

def self.find(id)
  hash, code = fetch("device_groups/#{id}")

  build hash['data']
end

Instance Method Details

#add_device(device) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/simplemdm/device_group.rb', line 16

def add_device(device)
  raise "The object you provided is not a device" unless device.kind_of?(SimpleMDM::Device)

  hash, code = fetch("device_groups/#{self.id}/devices/#{device.id}", :post)

  if code == 204
    self['device_ids'] = self['device_ids'] | [device.id]
    true
  else
    false
  end
end