class Applocate::API

Public Class Methods

active_commands(udid) click to toggle source

expected params, udid = “ABCD-DCCDDC-12394812389-CDC”

# File lib/applocate/api.rb, line 24
def self.active_commands(udid)
  response = self.get("/api/devices/#{udid}/active_commands", { headers: authentication })
  JSON.parse response.body rescue []
end
app_list(options = {}) click to toggle source

expected options { udid: “ABCD-DCCDDC-12394812389-CDC” }

# File lib/applocate/api.rb, line 92
def self.app_list(options = {})
  response = self.post('/deploy/app_list', { body: options.to_json, headers: authentication })
  JSON.parse response.body rescue []
end
apply_named_restrictions(udid, name, options = {}) click to toggle source

expected params: udid = “ABCD-DCCDDC-12394812389-CDC”, name = “me.example.restrictions” options { … Apple MDM Restrictions Profile … }

# File lib/applocate/api.rb, line 48
def self.apply_named_restrictions(udid, name, options = {})
  options = options.merge({ profile_name: name })
  response = self.post("/api/devices/#{udid}/profiles", { body: options.to_json, headers: authentication })
  JSON.parse response.body rescue {}
end
authentication() click to toggle source
# File lib/applocate/api.rb, line 128
def self.authentication
  { "X-Applocate-Secret" => secret, "X-Applocate-Token" => token, 'Content-Type' => "application/json" }
end
cancel_commmand(udid, commmand_uuid) click to toggle source

expected params, udid = “ABCD-DCCDDC-12394812389-CDC”, commmand_uuid = “xxxx-xxx-xxxx-xxxxxxxxxxx”

# File lib/applocate/api.rb, line 30
def self.cancel_commmand(udid, commmand_uuid)
  response = self.get("/api/devices/#{udid}/commands/#{commmand_uuid}", { headers: authentication })
  JSON.parse response.body rescue {}
end
delete_device(options) click to toggle source

expected options { device_id: 12345 }

OR { udid: "ABCD-DCCDDC-12394812389-CDC" }
# File lib/applocate/api.rb, line 123
def self.delete_device(options)
  response = self.delete("/api/devices", { body: options.to_json, headers: authentication })
  response.code == 200
end
get_devices(udid_or_identifier) click to toggle source

expected options udid_or_identifier = 12345 OR udid_or_identifier = “ABCD-DCCDDC-12394812389-CDC” NOTE: this may return more than one device.

# File lib/applocate/api.rb, line 116
def self.get_devices(udid_or_identifier)
  response = self.get("/api/devices/#{udid_or_identifier}", { headers: authentication })
  JSON.parse response.body rescue []
end
install_app(options = {}) click to toggle source

expected options { udid: “ABCD-DCCDDC-12394812389-CDC”, itunes_id: “284910350” }

# File lib/applocate/api.rb, line 86
def self.install_app(options = {})
  response = self.post('/deploy/app', { body: options.to_json, headers: authentication })
  JSON.parse response.body rescue []
end
install_vpn(options = {}) click to toggle source

expected options { udid: “ABCD-DCCDDC-12394812389-CDC”, vpn_username: “123456”, vpn_password: “p@ssw0rd” }

# File lib/applocate/api.rb, line 74
def self.install_vpn(options = {})
  response = self.post('/deploy/vpn', { body: options.to_json, headers: authentication })
  JSON.parse response.body rescue []
end
list_devices() click to toggle source
# File lib/applocate/api.rb, line 109
def self.list_devices
  response = self.get('/api/devices', { headers: authentication })
  JSON.parse response.body rescue []
end
mdm_app_list(options = {}) click to toggle source

expected options { udid: “ABCD-DCCDDC-12394812389-CDC” }

# File lib/applocate/api.rb, line 98
def self.mdm_app_list(options = {})
  response = self.post('/deploy/mdm_app_list', { body: options.to_json, headers: authentication })
  JSON.parse response.body rescue []
end
profile_list(udid) click to toggle source

expected params, udid = “ABCD-DCCDDC-12394812389-CDC”

# File lib/applocate/api.rb, line 42
def self.profile_list(udid)
  response = self.get("/api/devices/#{udid}/profiles", { headers: authentication })
  JSON.parse response.body rescue []
end
recent_checkins(udid) click to toggle source

expected params, udid = “ABCD-DCCDDC-12394812389-CDC”

# File lib/applocate/api.rb, line 12
def self.recent_checkins(udid)
  response = self.get("/api/devices/#{udid}/recent_checkins", { headers: authentication })
  JSON.parse response.body rescue []
end
recent_commands(udid) click to toggle source

expected params, udid = “ABCD-DCCDDC-12394812389-CDC”

# File lib/applocate/api.rb, line 18
def self.recent_commands(udid)
  response = self.get("/api/devices/#{udid}/recent_commands", { headers: authentication })
  JSON.parse response.body rescue []
end
register_device(options = {}) click to toggle source

expected options { name: “Steve J's iPad Air”, identifier: “XXX-123456 APPLE INC.”, configuration: “default” }

# File lib/applocate/api.rb, line 104
def self.register_device(options = {})
  response = self.post('/api/devices', { body: options.to_json, headers: authentication })
  JSON.parse response.body rescue []
end
remove_named_restrictions(udid, name) click to toggle source

expected params, udid = “ABCD-DCCDDC-12394812389-CDC”, name = “me.example.restrictions”

# File lib/applocate/api.rb, line 55
def self.remove_named_restrictions(udid, name)
  query = { profile_name: name }
  response = self.delete("/api/devices/#{udid}/profiles", { query: query, headers: authentication })
  JSON.parse response.body rescue {}
end
remove_vpn(options = {}) click to toggle source

expected options { udid: “ABCD-DCCDDC-12394812389-CDC” }

# File lib/applocate/api.rb, line 80
def self.remove_vpn(options = {})
  response = self.delete('/deploy/vpn', { body: options.to_json, headers: authentication })
  JSON.parse response.body rescue []
end
restrict(options = {}) click to toggle source

expected options { udid: “ABCD-DCCDDC-12394812389-CDC” }

# File lib/applocate/api.rb, line 62
def self.restrict(options = {})
  response = self.post('/deploy/profile', { body: options.to_json, headers: authentication })
  JSON.parse response.body rescue []
end
restrictions(udid) click to toggle source

expected params, udid = “ABCD-DCCDDC-12394812389-CDC”

# File lib/applocate/api.rb, line 36
def self.restrictions(udid)
  response = self.get("/api/devices/#{udid}/restrictions", { headers: authentication })
  JSON.parse response.body rescue []
end
secret() click to toggle source
# File lib/applocate/api.rb, line 136
def self.secret
  Applocate.configuration.secret
end
token() click to toggle source
# File lib/applocate/api.rb, line 132
def self.token
  Applocate.configuration.token
end
unrestrict(options = {}) click to toggle source

expected options { udid: “ABCD-DCCDDC-12394812389-CDC” }

# File lib/applocate/api.rb, line 68
def self.unrestrict(options = {})
  response = self.delete('/deploy/profile', { body: options.to_json, headers: authentication })
  JSON.parse response.body rescue []
end