Class: TrainingMailer
- Inherits:
-
InternalNotificationMailer
- Object
- ActionMailer::Base
- ApplicationMailer
- InternalNotificationMailer
- TrainingMailer
- Defined in:
- app/mailers/training_mailer.rb
Overview
Training: courses, certifications, liability insurance, room design.
Extracted from the former InternalMailer god object.
Instance Method Summary collapse
-
#certification_expired(certification) ⇒ Mail::Message
Tell training staff and the rep a certification lapsed.
-
#certification_insurance_needs_attention(certification, reason) ⇒ Mail::Message
Rep alert for the edge cases Certification::InsuranceEscalation can't resolve on its own: the customer has no insurance record to remind against, or is unreachable (no email on file).
-
#course_enrollment_exam(enrollment, passed) ⇒ Mail::Message
Tell training staff and the rep an exam was taken, and how it went.
-
#new_certification_request(certification) ⇒ Mail::Message
Tell training staff and the rep a certification was requested.
-
#new_course_enrollment(enrollment) ⇒ Mail::Message
Tell training staff and the customer's rep about a new enrollment.
-
#new_liability_insurance_card(insurance) ⇒ Mail::Message
Tell training staff, the rep, and AP about an uploaded insurance card.
-
#plans_ready_to_be_relased(room_plans, overnight: false) ⇒ Mail::Message
QC-queue alert: plans sitting in awaiting_quality_control.
-
#same_day_design_complete(room_configuration) ⇒ Mail::Message
Tell the customer's rep their same-day plan is done.
-
#same_day_design_request(room_configuration) ⇒ Mail::Message
Tell the Hyderabad design team a customer asked for a same-day plan.
Methods inherited from InternalNotificationMailer
Methods included from SendgridSmtpApi::InternalMailerHeaders
Methods inherited from ApplicationMailer
Instance Method Details
#certification_expired(certification) ⇒ Mail::Message
Tell training staff and the rep a certification lapsed.
138 139 140 141 142 143 144 |
# File 'app/mailers/training_mailer.rb', line 138 def certification_expired(certification) @certification = certification rep = @certification.party&.primary_rep mail(from: ADMINISTRATOR_EMAIL, to: "epasek@warmlyyours.com, rmatejacabello@warmlyyours.com, #{rep&.email}", subject: "Certification expired for user #{@certification.party.full_name}") end |
#certification_insurance_needs_attention(certification, reason) ⇒ Mail::Message
Rep alert for the edge cases Certification::InsuranceEscalation can't resolve
on its own: the customer has no insurance record to remind against, or is
unreachable (no email on file). Throttled by the escalation service.
113 114 115 116 117 118 119 120 |
# File 'app/mailers/training_mailer.rb', line 113 def certification_insurance_needs_attention(certification, reason) @certification = certification @reason = reason rep = @certification.customer&.primary_rep mail(from: ADMINISTRATOR_EMAIL, to: rep&.email.presence || ADMINISTRATOR_EMAIL, subject: "Liability insurance needs attention — certification #{certification.reference.presence || certification.id}") end |
#course_enrollment_exam(enrollment, passed) ⇒ Mail::Message
Tell training staff and the rep an exam was taken, and how it went.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'app/mailers/training_mailer.rb', line 78 def course_enrollment_exam(enrollment, passed) @course_enrollment = enrollment @status = (passed ? 'passed' : 'failed') if @course_enrollment.party.is_a?(Contact) rep = @course_enrollment.party.customer.primary_rep elsif @course_enrollment.party.is_a?(Customer) rep = @course_enrollment.party.primary_rep else # This shouldn't happen. Investigate. ErrorReporting.error("Course exam email error. Expecting contact or customer. Got #{@course_enrollment.party.class}") end mail(from: ADMINISTRATOR_EMAIL, to: "epasek@warmlyyours.com, rmatejacabello@warmlyyours.com, #{rep&.email}", subject: "New course exam taken and #{@status}. Enrollment #{@course_enrollment.id}") end |
#new_certification_request(certification) ⇒ Mail::Message
Tell training staff and the rep a certification was requested.
126 127 128 129 130 131 132 |
# File 'app/mailers/training_mailer.rb', line 126 def new_certification_request(certification) @certification = certification rep = @certification.party&.primary_rep mail(from: ADMINISTRATOR_EMAIL, to: "epasek@warmlyyours.com, rmatejacabello@warmlyyours.com, #{rep&.email}", subject: "New Certification request for user #{@certification.party.full_name}") end |
#new_course_enrollment(enrollment) ⇒ Mail::Message
Tell training staff and the customer's rep about a new enrollment.
65 66 67 68 69 70 71 |
# File 'app/mailers/training_mailer.rb', line 65 def new_course_enrollment(enrollment) @course_enrollment = enrollment rep = @course_enrollment.party&.primary_rep mail(from: ADMINISTRATOR_EMAIL, to: "epasek@warmlyyours.com, rmatejacabello@warmlyyours.com, #{rep&.email}", subject: "New Course Enrollment #{@course_enrollment.id}") end |
#new_liability_insurance_card(insurance) ⇒ Mail::Message
Tell training staff, the rep, and AP about an uploaded insurance card.
98 99 100 101 102 103 104 |
# File 'app/mailers/training_mailer.rb', line 98 def new_liability_insurance_card(insurance) @liability_insurance = insurance rep = @liability_insurance.party&.primary_rep mail(from: ADMINISTRATOR_EMAIL, to: "epasek@warmlyyours.com, rmatejacabello@warmlyyours.com, #{rep&.email}, ap@warmlyyours.com", subject: "New Liability Insurance card uploaded. Customer #{@liability_insurance.customer.reference_number}") end |
#plans_ready_to_be_relased(room_plans, overnight: false) ⇒ Mail::Message
QC-queue alert: plans sitting in awaiting_quality_control. The hourly
run reports plans ready to release; the 7:29am overnight run reports
what accumulated while the hourly worker slept (see
AwaitingQualityControlPlansWorker).
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/mailers/training_mailer.rb', line 45 def plans_ready_to_be_relased(room_plans, overnight: false) return null_mail if room_plans.blank? @room_plans = room_plans subject = if overnight "#{@room_plans.size} plans waiting in QC overnight." else "#{@room_plans.size} plans in Awaiting QC ready to be released." end mail(from: ADMINISTRATOR_EMAIL, to: 'aisayenko@warmlyyours.com', cc: 'techteam@warmlyyours.com', subject: subject) end |
#same_day_design_complete(room_configuration) ⇒ Mail::Message
Tell the customer's rep their same-day plan is done.
26 27 28 29 30 31 32 33 34 35 |
# File 'app/mailers/training_mailer.rb', line 26 def same_day_design_complete(room_configuration) @room_configuration = room_configuration @customer = @room_configuration.customer @rep = @customer.primary_sales_rep || @customer.sales_manager recipient = @rep&.email || ADMINISTRATOR_EMAIL mail(from: 'Heatwave Team <heatwaveteam@warmlyyours.com>', to: recipient, subject: "Same Day Plan Completed for Room #{@room_configuration.reference_number}") end |
#same_day_design_request(room_configuration) ⇒ Mail::Message
Tell the Hyderabad design team a customer asked for a same-day plan.
13 14 15 16 17 18 19 20 |
# File 'app/mailers/training_mailer.rb', line 13 def same_day_design_request(room_configuration) @room_configuration = room_configuration @customer = @room_configuration.customer mail(from: 'Heatwave Team <heatwaveteam@warmlyyours.com>', to: 'hyderabadstaff@warmlyyours.com', subject: "Same Day Design Request for #{@room_configuration.reference_number}") end |