Class: TermsOfUse::SignUpServiceUpdaterJob
- Inherits:
-
Object
- Object
- TermsOfUse::SignUpServiceUpdaterJob
- Includes:
- Sidekiq::Job
- Defined in:
- app/sidekiq/terms_of_use/sign_up_service_updater_job.rb
Constant Summary collapse
- LOG_TITLE =
'[TermsOfUse][SignUpServiceUpdaterJob]'
Instance Attribute Summary collapse
-
#user_account_uuid ⇒ Object
readonly
Returns the value of attribute user_account_uuid.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #accept ⇒ Object private
- #agreement_unchanged? ⇒ Boolean private
- #decline ⇒ Object private
- #log_updated_icn ⇒ Object private
- #map_client ⇒ Object private
- #map_status ⇒ Object private
- #missing_sec_id? ⇒ Boolean private
- #mpi_profile ⇒ Object private
- #perform(user_account_uuid, version) ⇒ Object
- #signature_name ⇒ Object private
- #terms_of_use_agreement ⇒ Object private
- #user_account ⇒ Object private
- #validate_multiple_sec_ids ⇒ Object private
Instance Attribute Details
#user_account_uuid ⇒ Object (readonly)
Returns the value of attribute user_account_uuid.
30 31 32 |
# File 'app/sidekiq/terms_of_use/sign_up_service_updater_job.rb', line 30 def user_account_uuid @user_account_uuid end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
30 31 32 |
# File 'app/sidekiq/terms_of_use/sign_up_service_updater_job.rb', line 30 def version @version end |
Instance Method Details
#accept ⇒ Object (private)
70 71 72 |
# File 'app/sidekiq/terms_of_use/sign_up_service_updater_job.rb', line 70 def accept map_client.agreements_accept(icn: mpi_profile.icn, signature_name:, version:) end |
#agreement_unchanged? ⇒ Boolean (private)
59 60 61 62 63 64 65 66 67 68 |
# File 'app/sidekiq/terms_of_use/sign_up_service_updater_job.rb', line 59 def agreement_unchanged? if terms_of_use_agreement.declined? != map_status[:opt_out] || terms_of_use_agreement.accepted? != map_status[:agreement_signed] return false end Rails.logger.info("#{LOG_TITLE} Not updating Sign Up Service due to unchanged agreement", { icn: user_account.icn }) true end |
#decline ⇒ Object (private)
74 75 76 |
# File 'app/sidekiq/terms_of_use/sign_up_service_updater_job.rb', line 74 def decline map_client.agreements_decline(icn: mpi_profile.icn) end |
#log_updated_icn ⇒ Object (private)
44 45 46 47 48 49 |
# File 'app/sidekiq/terms_of_use/sign_up_service_updater_job.rb', line 44 def log_updated_icn if user_account.icn != mpi_profile.icn Rails.logger.info("#{LOG_TITLE} Detected changed ICN for user", { icn: user_account.icn, mpi_icn: mpi_profile.icn }) end end |
#map_client ⇒ Object (private)
51 52 53 |
# File 'app/sidekiq/terms_of_use/sign_up_service_updater_job.rb', line 51 def map_client @map_client ||= MAP::SignUp::Service.new end |
#map_status ⇒ Object (private)
55 56 57 |
# File 'app/sidekiq/terms_of_use/sign_up_service_updater_job.rb', line 55 def map_status @map_status ||= map_client.status(icn: mpi_profile.icn) end |
#missing_sec_id? ⇒ Boolean (private)
78 79 80 81 82 83 84 85 86 87 |
# File 'app/sidekiq/terms_of_use/sign_up_service_updater_job.rb', line 78 def missing_sec_id? if mpi_profile.sec_id.present? validate_multiple_sec_ids return false end Rails.logger.info("#{LOG_TITLE} Sign Up Service not updated due to user missing sec_id", { icn: user_account.icn }) true end |
#mpi_profile ⇒ Object (private)
107 108 109 110 |
# File 'app/sidekiq/terms_of_use/sign_up_service_updater_job.rb', line 107 def mpi_profile @mpi_profile ||= MPI::Service.new.find_profile_by_identifier(identifier: user_account.icn, identifier_type: MPI::Constants::ICN)&.profile end |
#perform(user_account_uuid, version) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'app/sidekiq/terms_of_use/sign_up_service_updater_job.rb', line 32 def perform(user_account_uuid, version) @user_account_uuid = user_account_uuid @version = version return if missing_sec_id? || agreement_unchanged? log_updated_icn terms_of_use_agreement.accepted? ? accept : decline end |
#signature_name ⇒ Object (private)
103 104 105 |
# File 'app/sidekiq/terms_of_use/sign_up_service_updater_job.rb', line 103 def signature_name "#{mpi_profile.given_names.first} #{mpi_profile.family_name}" end |
#terms_of_use_agreement ⇒ Object (private)
99 100 101 |
# File 'app/sidekiq/terms_of_use/sign_up_service_updater_job.rb', line 99 def terms_of_use_agreement user_account.terms_of_use_agreements.where(agreement_version: version).last end |
#user_account ⇒ Object (private)
95 96 97 |
# File 'app/sidekiq/terms_of_use/sign_up_service_updater_job.rb', line 95 def user_account @user_account ||= UserAccount.find(user_account_uuid) end |
#validate_multiple_sec_ids ⇒ Object (private)
89 90 91 92 93 |
# File 'app/sidekiq/terms_of_use/sign_up_service_updater_job.rb', line 89 def validate_multiple_sec_ids if mpi_profile.sec_ids.many? Rails.logger.info("#{LOG_TITLE} Multiple sec_id values detected", { icn: user_account.icn }) end end |