module AppleDEPClient::Device

Constants

DETAILS_PATH
DISOWN_PATH
FETCH_LIMIT
FETCH_PATH
SYNC_PATH

Public Class Methods

details(devices) click to toggle source
# File lib/apple_dep_client/device.rb, line 42
def self.details(devices)
  body = devices
  body = JSON.dump body
  response = AppleDEPClient::Request.make_request(AppleDEPClient::Request.make_url(DETAILS_PATH), :post, body)
  response["devices"]
end
disown(devices) click to toggle source

Accepts an array of device ID strings WARNING - this will remove devices from DEP accounts and may render devices permanently inoperable DEPRECATED by Apple

# File lib/apple_dep_client/device.rb, line 53
def self.disown(devices)
  Kernel.warn "Disown is a deprecated request and may not be supported in the future"
  body = { "devices" => devices }
  body = JSON.dump body
  response = AppleDEPClient::Request.make_request(AppleDEPClient::Request.make_url(DISOWN_PATH), :post, body)
  response["devices"]
end
fetch(cursor: nil, url: nil) { |device| ... } click to toggle source
# File lib/apple_dep_client/device.rb, line 13
def self.fetch(cursor: nil, url: nil)
  url ||= FETCH_PATH
  response = { "cursor" => cursor, "more_to_follow" => "true" }
  while response["more_to_follow"] == "true"
    response = make_fetch_request response["cursor"], url
    response["devices"].each do |device|
      yield device
    end
  end
  response["cursor"]
end
fetch_body(cursor) click to toggle source
# File lib/apple_dep_client/device.rb, line 30
def self.fetch_body(cursor)
  body = { "limit" => FETCH_LIMIT }
  if cursor
    body["cursor"] = cursor
  end
  JSON.dump body
end
make_fetch_request(cursor, url) click to toggle source
# File lib/apple_dep_client/device.rb, line 25
def self.make_fetch_request(cursor, url)
  body = fetch_body(cursor)
  AppleDEPClient::Request.make_request(AppleDEPClient::Request.make_url(url), :post, body)
end
sync(cursor, &block) click to toggle source
# File lib/apple_dep_client/device.rb, line 38
def self.sync(cursor, &block)
  fetch(cursor: cursor, url: SYNC_PATH, &block)
end