Class: Order::DefaultTrackingEmailExtractor
- Inherits:
-
Object
- Object
- Order::DefaultTrackingEmailExtractor
- Defined in:
- app/services/order/default_tracking_email_extractor.rb
Overview
Class is responsible for extracting the default email addresses for an order
Instance Method Summary collapse
- #emails ⇒ Object
-
#initialize(order) ⇒ DefaultTrackingEmailExtractor
constructor
A new instance of DefaultTrackingEmailExtractor.
Constructor Details
#initialize(order) ⇒ DefaultTrackingEmailExtractor
Returns a new instance of DefaultTrackingEmailExtractor.
3 4 5 |
# File 'app/services/order/default_tracking_email_extractor.rb', line 3 def initialize(order) @order = order end |
Instance Method Details
#emails ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/services/order/default_tracking_email_extractor.rb', line 7 def emails return [] unless @order.customer emails = [] emails += @order.customer.notification_channels.orders_shipment.email.pluck(:detail) # We will pull in customer emails only if the customer is not an etailer or distributor # they can always override by specifying a notification channel if !@order.customer.is_e_commerce_misc_or_direct_pro? # If our order is part of a job we default to pulling primary party details if @order.opportunity emails << @order.opportunity.primary_party&.email end # If no email comes from the opportunity and no email, customer email if emails.empty? emails << @order.customer.email end end emails.compact.uniq end |