Class: MAP::SignUp::Service

Inherits:
Common::Client::Base show all
Defined in:
lib/map/sign_up/service.rb

Instance Method Summary collapse

Methods inherited from Common::Client::Base

configuration, #raise_backend_exception

Methods included from SentryLogging

#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger

Instance Method Details

#agreements_accept(icn:, signature_name:, version:) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/map/sign_up/service.rb', line 19

def agreements_accept(icn:, signature_name:, version:)
  perform(:post,
          config.patients_agreements_path(icn),
          agreements_body(icn, signature_name, version),
          authenticated_header(icn))
  Rails.logger.info("#{config.logging_prefix} agreements accept success, icn: #{icn}")
rescue Common::Client::Errors::ClientError => e
  parse_and_raise_error(e, icn, 'agreements accept')
end

#agreements_decline(icn:) ⇒ Object



29
30
31
32
33
34
# File 'lib/map/sign_up/service.rb', line 29

def agreements_decline(icn:)
  perform(:delete, config.patients_agreements_path(icn), nil, authenticated_header(icn))
  Rails.logger.info("#{config.logging_prefix} agreements decline success, icn: #{icn}")
rescue Common::Client::Errors::ClientError => e
  parse_and_raise_error(e, icn, 'agreements decline')
end

#status(icn:) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/map/sign_up/service.rb', line 11

def status(icn:)
  response = perform(:get, config.status_unauthenticated_path(icn), nil)
  Rails.logger.info("#{config.logging_prefix} status success, icn: #{icn}")
  parse_response(response.body, icn, 'status')
rescue Common::Client::Errors::ClientError => e
  parse_and_raise_error(e, icn, 'status')
end

#update_provisioning(icn:, first_name:, last_name:, mpi_gcids:) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/map/sign_up/service.rb', line 36

def update_provisioning(icn:, first_name:, last_name:, mpi_gcids:)
  response = perform(:put,
                     config.patients_provisioning_path(icn),
                     update_provisioning_params(first_name, last_name, mpi_gcids).to_json,
                     config.authenticated_provisioning_header)
  successful_update_provisioning_response(response, icn)
rescue Common::Client::Errors::ClientError => e
  if config.provisioning_acceptable_status.include?(e.status)
    successful_update_provisioning_response(e, icn)
  else
    parse_and_raise_error(e, icn, 'update provisioning')
  end
end