Class: Mdm::Enrollment::Service::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/mdm/enrollment/service/base.rb

Direct Known Subclasses

Account, AssignProfile, Auth, CreateProfile, Devices, Profile

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.accepted_paramsObject



13
14
15
# File 'lib/mdm/enrollment/service/base.rb', line 13

def self.accepted_params
  []
end

.available_servicesObject



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

def self.available_services
  [:account]
end

Instance Method Details

#authenticate?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/mdm/enrollment/service/base.rb', line 43

def authenticate?
  true
end

#methodObject



35
36
37
# File 'lib/mdm/enrollment/service/base.rb', line 35

def method
  raise 'Subclasses must implement this method'
end

#paramsObject



47
48
49
# File 'lib/mdm/enrollment/service/base.rb', line 47

def params
  @params ||= {}
end

#params=(params) ⇒ Object



51
52
53
# File 'lib/mdm/enrollment/service/base.rb', line 51

def params=(params)
  @params = params.permit(self.class.accepted_params)
end

#pathObject



39
40
41
# File 'lib/mdm/enrollment/service/base.rb', line 39

def path
  raise 'Subclasses must implement this method'
end

#resultObject



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

def result
  raise 'Subclasses must implement this method'
end

#startObject



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/mdm/enrollment/service/base.rb', line 17

def start
  if authenticate?
    client.authenticate!
  end

  options = if [:post, :put].include? method
              { body: params.to_json }
            else
              { query: params }
            end

  client.send(method, path, options)
end