Class: SimpleMDM::Device
- Defined in:
- lib/simplemdm/device.rb
Class Method Summary collapse
Instance Method Summary collapse
- #clear_passcode ⇒ Object
- #installed_apps ⇒ Object
- #lock(options = {}) ⇒ Object
- #push_apps ⇒ Object
- #save ⇒ Object
- #wipe ⇒ Object
Methods inherited from Base
Class Method Details
.all ⇒ Object
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_passcode ⇒ Object
51 52 53 54 55 |
# File 'lib/simplemdm/device.rb', line 51 def clear_passcode hash, code = fetch("devices/#{id}/clear_passcode", :post) code == 202 end |
#installed_apps ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/simplemdm/device.rb', line 35 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
43 44 45 46 47 48 49 |
# File 'lib/simplemdm/device.rb', line 43 def lock( = {}) params = .delete_if { |k,v| ![:message, :phone_number, :pin].include?(k) } hash, code = fetch("devices/#{id}/lock", :post, params) code == 202 end |
#push_apps ⇒ Object
63 64 65 66 67 |
# File 'lib/simplemdm/device.rb', line 63 def push_apps hash, code = fetch("devices/#{id}/push_apps", :post) code == 202 end |
#save ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/simplemdm/device.rb', line 16 def save unless new? raise "You can only save new device objects" end params = {} params[:name] = self.name unless self.name.nil? params[:group_id] = self.group_id unless self.group_id.nil? hash, code = fetch("devices", :post, params) self.id = hash['data']['id'] self.merge!(hash['data']['attributes']) @dirty = false self end |
#wipe ⇒ Object
57 58 59 60 61 |
# File 'lib/simplemdm/device.rb', line 57 def wipe hash, code = fetch("devices/#{id}/wipe", :post) code == 202 end |