Class: Mdm::Enrollment::CreateProfile
- Inherits:
-
Service::Base
- Object
- Service::Base
- Mdm::Enrollment::CreateProfile
- Defined in:
- lib/mdm/enrollment/service/create_profile.rb
Instance Attribute Summary collapse
-
#devices ⇒ Object
Returns the value of attribute devices.
-
#profile ⇒ Object
readonly
Returns the value of attribute profile.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ CreateProfile
constructor
A new instance of CreateProfile.
- #method ⇒ Object
- #path ⇒ Object
- #result ⇒ Object
- #start ⇒ Object
Methods inherited from Service::Base
#authenticate?, available_services, #params, #params=
Constructor Details
#initialize ⇒ CreateProfile
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
#devices ⇒ Object
Returns the value of attribute devices.
7 8 9 |
# File 'lib/mdm/enrollment/service/create_profile.rb', line 7 def devices @devices end |
#profile ⇒ Object (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_params ⇒ Object
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
#method ⇒ Object
53 54 55 |
# File 'lib/mdm/enrollment/service/create_profile.rb', line 53 def method :post end |
#path ⇒ Object
49 50 51 |
# File 'lib/mdm/enrollment/service/create_profile.rb', line 49 def path '/profile' end |
#result ⇒ Object
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 |
#start ⇒ Object
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 |