Class: SimpleMDM::Device

Inherits:
Base
  • Object
show all
Defined in:
lib/simplemdm/device.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.rb', line 4

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

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

.find(id) ⇒ Object



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

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

  build hash['data']
end

Instance Method Details

#clear_passcodeObject



32
33
34
35
36
# File 'lib/simplemdm/device.rb', line 32

def clear_passcode
  hash, code = fetch("devices/#{id}/clear_passcode", :post)

  code == 202
end

#installed_appsObject



16
17
18
19
20
21
22
# File 'lib/simplemdm/device.rb', line 16

def installed_apps
  raise "You cannot retrieve installed apps for a device that hasn't been created yet." if new?

  hash, code = fetch("devices/#{id}/installed_apps")

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

#lock(options = {}) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/simplemdm/device.rb', line 24

def lock(options = {})
  params = options.delete_if { |k,v| ![:message, :phone_number, :pin].include?(k) }

  hash, code = fetch("devices/#{id}/lock", :post, params)

  code == 202
end

#push_appsObject



44
45
46
47
48
# File 'lib/simplemdm/device.rb', line 44

def push_apps
  hash, code = fetch("devices/#{id}/push_apps", :post)

  code == 202
end

#wipeObject



38
39
40
41
42
# File 'lib/simplemdm/device.rb', line 38

def wipe
  hash, code = fetch("devices/#{id}/wipe", :post)

  code == 202
end