Class: Mdm::Enrollment::CreateProfile

Inherits:
Service::Base show all
Defined in:
lib/mdm/enrollment/service/create_profile.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Service::Base

#authenticate?, available_services, #params, #params=

Constructor Details

#initializeCreateProfile

Returns a new instance of CreateProfile.



31
32
33
34
# File 'lib/mdm/enrollment/service/create_profile.rb', line 31

def initialize
  super
  @devices = []
end

Instance Attribute Details

#devicesObject

Returns the value of attribute devices.



7
8
9
# File 'lib/mdm/enrollment/service/create_profile.rb', line 7

def devices
  @devices
end

#profileObject (readonly)

Returns the value of attribute profile.



9
10
11
# File 'lib/mdm/enrollment/service/create_profile.rb', line 9

def profile
  @profile
end

Class Method Details

.accepted_paramsObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# 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

Instance Method Details

#methodObject



53
54
55
# File 'lib/mdm/enrollment/service/create_profile.rb', line 53

def method
  :post
end

#pathObject



49
50
51
# File 'lib/mdm/enrollment/service/create_profile.rb', line 49

def path
  '/profile'
end

#resultObject



57
58
59
60
61
62
63
# 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

#startObject



36
37
38
39
40
41
42
43
44
45
46
47
# 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