Sha256: e65ef39d6f1af0cc46ce6aa9ba61570b5044ea0c4e2482ff145e150e202a5e11

Contents?: true

Size: 1 KB

Versions: 6

Compression:

Stored size: 1 KB

Contents

module SimpleMDM
  class Device < Base

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

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

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

      build hash['data']
    end

    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

    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

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

      code == 202
    end

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

      code == 202
    end

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

      code == 202
    end


  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
simplemdm-1.1.3 lib/simplemdm/device.rb
simplemdm-1.1.2 lib/simplemdm/device.rb
simplemdm-1.0.0 lib/simplemdm/device.rb
simplemdm-0.2.0 lib/simplemdm/device.rb
simplemdm-0.1.1 lib/simplemdm/device.rb
simplemdm-0.1.0 lib/simplemdm/device.rb