class Mdm::Enrollment::CreateProfile

Attributes

devices[RW]
profile[R]

Public Class Methods

accepted_params() click to toggle source
# File lib/mdm/enrollment/service/create_profile.rb, line 11
def self.accepted_params
  [
    :devices,
    :profile_name,
    :org_magic,
    :url,
    :allow_pairing,
    :is_supervised,
    :is_mandatory,
    :await_device_configured,
    :is_mdm_removable,
    :support_phone_number,
    :support_email_address,
    :anchor_certs,
    :supervising_host_certs,
    :skip_setup_items,
    :department
  ]
end
new() click to toggle source
Calls superclass method
# File lib/mdm/enrollment/service/create_profile.rb, line 31
def initialize
  super
  @devices = []
end

Public Instance Methods

method() click to toggle source
# File lib/mdm/enrollment/service/create_profile.rb, line 53
def method
  :post
end
path() click to toggle source
# File lib/mdm/enrollment/service/create_profile.rb, line 49
def path
  '/profile'
end
result() click to toggle source
# File lib/mdm/enrollment/service/create_profile.rb, line 57
def result
  if @profile.persisted?
    { profile: @profile.to_json }
  else
    { errors: @profile.errors }
  end
end
start() click to toggle source
Calls superclass method Mdm::Enrollment::Service::Base#start
# File lib/mdm/enrollment/service/create_profile.rb, line 36
def start
  params[:devices] = devices.map(&:serial_number)
  # TODO: A string that uniquely identifies various services that are managed by a single organization.
  # wtf, so what do we use?
  params[:org_magic] = SecureRandom.uuid

  super

  @profile = Profile.new(params)
  @profile.profile_uuid = client.response['profile_uuid']
  @profile.save!
end