Class: SupportMailer
- Inherits:
-
InternalNotificationMailer
- Object
- ActionMailer::Base
- ApplicationMailer
- InternalNotificationMailer
- SupportMailer
- Defined in:
- app/mailers/support_mailer.rb
Overview
Customer-service / comms: smart service, warranty, voicemail, praise.
Extracted from the former InternalMailer god object.
Instance Method Summary collapse
- #praise_email(praise) ⇒ Object
- #service_warranty_claim(support_case) ⇒ Object
- #smart_service_confirmed_notification(support_case) ⇒ Object
- #smart_service_requested_notification(support_case) ⇒ Object
- #voicemail_notification(call_record) ⇒ Object
Methods inherited from InternalNotificationMailer
Methods included from SendgridSmtpApi::InternalMailerHeaders
Methods inherited from ApplicationMailer
Instance Method Details
#praise_email(praise) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/mailers/support_mailer.rb', line 9 def praise_email(praise) if praise.image&.stored? && (img = praise.image) file_name = img.name || praise.headline.parameterize mime_type = praise.image_mime_type || img.mime_type ext = Mime::Type.lookup(mime_type)&.symbol&.to_s if ext file_name = "#{file_name}.#{ext}" if /^image/.match?(img.mime_type) # Inline it .inline[file_name] = img.data else [file_name] = img.data end end else .inline['be-radiant.png'] = Rails.public_path.join('images/mailer/be-radiant-logo.png').read end @sender = praise.originating_employee_record.try(:party) @sender ||= praise.creator from_email = @sender.try(:email_with_name) || 'Julia Billen <jbillen@warmlyyours.com>' @praise = praise @recipients = praise.employee_records.select { |er| er.try(:party) } recipient_names = @recipients.map { |r| r.try(:full_name) }.join(',') recipient_names = 'WarmlyYours Staff' if recipient_names.blank? to_email = @recipients.filter_map { |r| r.try(:employee).try(:email).presence }.join(',') cc_email = @praise.notify_staff? ? 'staff@warmlyyours.com' : 'jbillen@warmlyyours.com' # Broadcast praises (e.g. Monday Motivation) carry no individual # appraisals — promote the staff list to `to:` so the message is # well-formed and actually delivers. to_email = cc_email if to_email.blank? mail(from: from_email, to: to_email, cc: (cc_email if cc_email != to_email), subject: "A new praise for #{recipient_names}") end |
#service_warranty_claim(support_case) ⇒ Object
62 63 64 65 66 67 68 |
# File 'app/mailers/support_mailer.rb', line 62 def service_warranty_claim(support_case) @support_case = support_case mail(from: 'Heatwave Team <heatwaveteam@warmlyyours.com>', cc: 'epasek@warmlyyours.com;srosenbaum@warmlyyours.com;rmatejacabello@warmlyyours.com', to: 'heatwaveteam@warmlyyours.com', subject: "Warranty Claim Service order needs to be manually closed: #{support_case.case_number}") end |
#smart_service_confirmed_notification(support_case) ⇒ Object
55 56 57 58 59 60 |
# File 'app/mailers/support_mailer.rb', line 55 def smart_service_confirmed_notification(support_case) @support_case = support_case mail(from: 'Heatwave Team <heatwaveteam@warmlyyours.com>', to: 'serviceordernotifications@warmlyyours.com', subject: "New SmartService Confirmed: #{support_case.case_number}") end |
#smart_service_requested_notification(support_case) ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'app/mailers/support_mailer.rb', line 46 def smart_service_requested_notification(support_case) return null_mail if support_case.nil? @support_case = support_case mail(from: 'Heatwave Team <heatwaveteam@warmlyyours.com>', to: 'epasek@warmlyyours.com;srosenbaum@warmlyyours.com;jbillen@warmlyyours.com', subject: "New SmartService Requested: #{support_case.case_number}") end |
#voicemail_notification(call_record) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'app/mailers/support_mailer.rb', line 70 def voicemail_notification(call_record) @call_record = call_record @employee = call_record.destination_party if call_record.destination_party.is_a?(Employee) return null_mail if @employee&.email.blank? @caller_label = call_record.origin_name.presence || call_record.origin_number.presence || 'Unknown caller' @call_record_url = call_record_url(call_record, host: CRM_HOSTNAME, protocol: 'https') mail(from: 'Heatwave Team <heatwaveteam@warmlyyours.com>', to: @employee.email, subject: "New voicemail from #{@caller_label}") end |