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.
4 5 6 |
# File 'app/services/order/default_tracking_email_extractor.rb', line 4 def initialize(order) @order = order end |
Instance Method Details
#emails ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/services/order/default_tracking_email_extractor.rb', line 8 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 unless @order.customer.is_e_commerce_misc_or_direct_pro? # If our order is part of a job we default to pulling primary party details emails << @order.opportunity.primary_party&.email if @order.opportunity # If no email comes from the opportunity and no email, customer email emails << @order.customer.email if emails.empty? end emails.compact.uniq end |