Class: TermsOfUse::Provisioner

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
app/services/terms_of_use/provisioner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(icn:, first_name:, last_name:, mpi_gcids:) ⇒ Provisioner

Returns a new instance of Provisioner.



13
14
15
16
17
18
19
20
21
22
23
# File 'app/services/terms_of_use/provisioner.rb', line 13

def initialize(icn:, first_name:, last_name:, mpi_gcids:)
  @icn = icn
  @first_name = first_name
  @last_name = last_name
  @mpi_gcids = mpi_gcids

  validate!
rescue ActiveModel::ValidationError => e
  log_provisioner_error(e)
  raise Errors::ProvisionerError, e.message
end

Instance Attribute Details

#first_nameObject (readonly)

Returns the value of attribute first_name.



9
10
11
# File 'app/services/terms_of_use/provisioner.rb', line 9

def first_name
  @first_name
end

#icnObject (readonly)

Returns the value of attribute icn.



9
10
11
# File 'app/services/terms_of_use/provisioner.rb', line 9

def icn
  @icn
end

#last_nameObject (readonly)

Returns the value of attribute last_name.



9
10
11
# File 'app/services/terms_of_use/provisioner.rb', line 9

def last_name
  @last_name
end

#mpi_gcidsObject (readonly)

Returns the value of attribute mpi_gcids.



9
10
11
# File 'app/services/terms_of_use/provisioner.rb', line 9

def mpi_gcids
  @mpi_gcids
end

Instance Method Details

#performObject



25
26
27
28
29
30
31
32
33
# File 'app/services/terms_of_use/provisioner.rb', line 25

def perform
  response = update_provisioning
  raise(Errors::ProvisionerError, 'Agreement not accepted') if response[:agreement_signed].blank?

  ActiveModel::Type::Boolean.new.cast(response[:agreement_signed])
rescue Common::Client::Errors::ClientError => e
  log_provisioner_error(e)
  raise Errors::ProvisionerError, e.message
end