Class: TermsOfUse::Provisioner
- Inherits:
-
Object
- Object
- TermsOfUse::Provisioner
- Includes:
- ActiveModel::Validations
- Defined in:
- app/services/terms_of_use/provisioner.rb
Instance Attribute Summary collapse
-
#icn ⇒ Object
readonly
Returns the value of attribute icn.
Instance Method Summary collapse
- #first_name ⇒ Object private
-
#initialize(icn:) ⇒ Provisioner
constructor
A new instance of Provisioner.
- #last_name ⇒ Object private
- #log_provisioner_error(error) ⇒ Object private
- #mpi_gcids ⇒ Object private
- #mpi_profile ⇒ Object private
- #perform ⇒ Object
- #update_provisioning ⇒ Object private
Constructor Details
#initialize(icn:) ⇒ Provisioner
Returns a new instance of Provisioner.
13 14 15 16 17 18 19 20 |
# File 'app/services/terms_of_use/provisioner.rb', line 13 def initialize(icn:) @icn = icn validate! rescue ActiveModel::ValidationError => e log_provisioner_error(e) raise Errors::ProvisionerError, e. end |
Instance Attribute Details
#icn ⇒ Object (readonly)
Returns the value of attribute icn.
9 10 11 |
# File 'app/services/terms_of_use/provisioner.rb', line 9 def icn @icn end |
Instance Method Details
#first_name ⇒ Object (private)
53 54 55 |
# File 'app/services/terms_of_use/provisioner.rb', line 53 def first_name mpi_profile.given_names.first end |
#last_name ⇒ Object (private)
57 58 59 |
# File 'app/services/terms_of_use/provisioner.rb', line 57 def last_name mpi_profile.family_name end |
#log_provisioner_error(error) ⇒ Object (private)
44 45 46 |
# File 'app/services/terms_of_use/provisioner.rb', line 44 def log_provisioner_error(error) Rails.logger.error("[TermsOfUse] [Provisioner] Error: #{error.}", { icn: }) end |
#mpi_gcids ⇒ Object (private)
61 62 63 |
# File 'app/services/terms_of_use/provisioner.rb', line 61 def mpi_gcids mpi_profile.full_mvi_ids.join('|') end |
#mpi_profile ⇒ Object (private)
48 49 50 51 |
# File 'app/services/terms_of_use/provisioner.rb', line 48 def mpi_profile @mpi_profile ||= MPI::Service.new.find_profile_by_identifier(identifier: icn, identifier_type: MPI::Constants::ICN)&.profile end |
#perform ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/services/terms_of_use/provisioner.rb', line 22 def perform response = update_provisioning if response[:agreement_signed].blank? Rails.logger.error('[TermsOfUse] [Provisioner] update_provisioning error', { icn:, response: }) raise(Errors::ProvisionerError, 'Agreement not accepted') end if response[:cerner_provisioned].blank? Rails.logger.error('[TermsOfUse] [Provisioner] update_provisioning error', { icn:, response: }) raise(Errors::ProvisionerError, 'Account not Provisioned') end rescue Common::Client::Errors::ClientError => e log_provisioner_error(e) raise Errors::ProvisionerError, e. end |
#update_provisioning ⇒ Object (private)
40 41 42 |
# File 'app/services/terms_of_use/provisioner.rb', line 40 def update_provisioning MAP::SignUp::Service.new.update_provisioning(icn:, first_name:, last_name:, mpi_gcids:) end |