Class: WarrantyMailer

Inherits:
ApplicationMailer show all
Defined in:
app/mailers/warranty_mailer.rb

Overview

Staff notification for warranty registrations (Warranty Registration v2,
Phase 2). Replaces the raw mail_form delivery the legacy
MailForm::Warranty* classes fired at info@warmlyyours.com. Keeps the
long-standing rule that Shower Waterproofing registrations also CC the
manufacturer, PSC (warranty@pscamerica.com).

Constant Summary collapse

STAFF_RECIPIENT =
'info@warmlyyours.com'
PSC_CC =
'warranty@pscamerica.com'

Instance Method Summary collapse

Methods inherited from ApplicationMailer

#null_mail

Instance Method Details

#confirmation(warranty) ⇒ Object

Customer-facing confirmation: what they registered and until when each
product is covered. Sent to the registrant (the end-consumer customer's
email) for both web submissions and CRM-keyed cards; silently skipped
when we have no email (mailed-in cards often carry none).

Parameters:



18
19
20
21
22
23
24
25
26
27
28
# File 'app/mailers/warranty_mailer.rb', line 18

def confirmation(warranty)
  @warranty = warranty
  @order = warranty.order
  @customer = warranty.customer
  @products = warranty.products.to_a
  recipient = @customer.email.presence
  return null_mail unless recipient

  mail(to: recipient,
       subject: "Your WarmlyYours warranty registration — #{@order&.reference_number || warranty.external_order_number.presence || 'confirmation'}")
end

#registered(warranty) ⇒ Object

Parameters:



32
33
34
35
36
37
38
39
40
41
42
# File 'app/mailers/warranty_mailer.rb', line 32

def registered(warranty)
  @warranty = warranty
  @order = warranty.order
  @customer = warranty.customer
  @products = warranty.products.to_a

  mail(to: STAFF_RECIPIENT,
       cc: (PSC_CC if @products.any? { |product| product.product_line == 'shower_waterproofing' }),
       subject: "[Warranty] #{warranty.product_line_labels.to_sentence.presence || 'Warranty'} registration — " \
                "#{@order&.reference_number || warranty.external_order_number.presence || 'no order'}")
end