Class: EducationForm::SendSchoolCertifyingOfficialsEmail
- Inherits:
-
Object
- Object
- EducationForm::SendSchoolCertifyingOfficialsEmail
- Includes:
- Sidekiq::Job
- Defined in:
- app/sidekiq/education_form/send_school_certifying_officials_email.rb
Class Method Summary collapse
Instance Method Summary collapse
- #get_institution(facility_code) ⇒ Object private
- #perform(claim_id, less_than_six_months, facility_code) ⇒ Object
- #recipients ⇒ Object private
- #school_changed? ⇒ Boolean private
- #send_sco_email ⇒ Object private
- #stats_key ⇒ Object private
Class Method Details
.sco_emails(scos) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'app/sidekiq/education_form/send_school_certifying_officials_email.rb', line 21 def self.sco_emails(scos) emails = [] primary = scos.find { |sco| sco[:priority] == 'Primary' && sco[:email].present? } secondary = scos.find { |sco| sco[:priority] == 'Secondary' && sco[:email].present? } emails.push(primary[:email]) if primary.present? emails.push(secondary[:email]) if secondary.present? emails end |
Instance Method Details
#get_institution(facility_code) ⇒ Object (private)
34 35 36 |
# File 'app/sidekiq/education_form/send_school_certifying_officials_email.rb', line 34 def get_institution(facility_code) GI::Client.new.get_institution_details_v0({ id: facility_code }).body[:data][:attributes] end |
#perform(claim_id, less_than_six_months, facility_code) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/sidekiq/education_form/send_school_certifying_officials_email.rb', line 9 def perform(claim_id, less_than_six_months, facility_code) @claim = SavedClaim::EducationBenefits::VA10203.find(claim_id) @claim.email_sent(false) if less_than_six_months && facility_code.present? @institution = get_institution(facility_code) send_sco_email end end |
#recipients ⇒ Object (private)
68 69 70 71 |
# File 'app/sidekiq/education_form/send_school_certifying_officials_email.rb', line 68 def recipients scos = @institution[:versioned_school_certifying_officials] EducationForm::SendSchoolCertifyingOfficialsEmail.sco_emails(scos) end |
#school_changed? ⇒ Boolean (private)
38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/sidekiq/education_form/send_school_certifying_officials_email.rb', line 38 def school_changed? application = @claim.parsed_form form_school_name = application['schoolName'] form_school_city = application['schoolCity'] form_school_state = application['schoolState'] prefill_name = @institution[:name] prefill_city = @institution[:city] prefill_state = @institution[:state] form_school_name != prefill_name || form_school_city != prefill_city || form_school_state != prefill_state end |
#send_sco_email ⇒ Object (private)
53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'app/sidekiq/education_form/send_school_certifying_officials_email.rb', line 53 def send_sco_email return if @institution.blank? || school_changed? emails = recipients if emails.any? StatsD.increment("#{stats_key}.success") SchoolCertifyingOfficialsMailer.build(@claim.open_struct_form, emails, nil).deliver_now StemApplicantScoMailer.build(@claim.open_struct_form, nil).deliver_now @claim.email_sent(true) else StatsD.increment("#{stats_key}.failure") end end |
#stats_key ⇒ Object (private)
73 74 75 |
# File 'app/sidekiq/education_form/send_school_certifying_officials_email.rb', line 73 def stats_key 'api.education_benefits_claim.22-10203.school_certifying_officials_mailer' end |