Class: EdiMailer
- Inherits:
-
InternalNotificationMailer
- Object
- ActionMailer::Base
- ApplicationMailer
- InternalNotificationMailer
- EdiMailer
- Defined in:
- app/mailers/edi_mailer.rb
Overview
EDI partner / Mirakl notifications (admin + AR alerts, order pushes).
Extracted from the former InternalMailer god object.
Constant Summary collapse
- PARTNER_DISPLAY_NAMES =
Recognised partner display names.
{ 'amazon_seller_central' => 'Amazon', 'amazon_vc_seller_api' => 'Amazon Vendor Central', 'mft_gateway_amazon_vc' => 'Amazon Vendor Central', 'commercehub_costco' => 'Costco', 'commercehub_thd' => 'Home Depot', 'commercehub_lowes' => "Lowe's", 'walmart_seller' => 'Walmart', 'wayfair' => 'Wayfair', 'houzz' => 'Houzz', 'mft_gateway_build_com' => 'Build.com', 'mft_gateway_canadian_tire' => 'Canadian Tire', 'mft_gateway_zoro_tools' => 'Zoro Tools', 'leroymerlin_adeo' => 'Leroy Merlin', 'castorama' => 'Castorama', 'bricodepot' => 'Brico Dépôt', 'bricomarche' => 'Bricomarché', 'leclerc' => 'Leclerc', 'maxeda' => 'Maxeda' }.freeze
Instance Method Summary collapse
-
#amazon_seller_central_orders_notification(orders) ⇒ Object
Amazon Seller Central is an EDI partner; this delegates to +edi_orders_notification+ (same instance) and renders its template.
- #edi_orders_notification(orders, partner_name: nil) ⇒ Object
- #notify_ar_of_edi_credit_limit_issue(edi_communication_log, msg: nil) ⇒ Object
- #notify_ar_of_new_receipt_created_from_edi_log(receipt, msg: nil) ⇒ Object
- #notify_edi_admin_of_edi_cancel(order, msg = nil) ⇒ Object
- #notify_edi_admin_of_error(edi_communication_log, msg: nil) ⇒ Object
- #notify_edi_admin_of_menard_inventory_error(error_message, item_count: 0) ⇒ Object
- #notify_edi_admin_of_mirakl_error(partner, category, msg) ⇒ Object
- #notify_edi_admin_of_order_status_mismatches(result) ⇒ Object
- #notify_edi_admin_of_warning(subj, msg) ⇒ Object
- #notify_menard_of_pending_discontinue(catalog_item, discontinue_date:, recipients:) ⇒ Object
Methods inherited from InternalNotificationMailer
Methods included from SendgridSmtpApi::InternalMailerHeaders
Methods inherited from ApplicationMailer
Instance Method Details
#amazon_seller_central_orders_notification(orders) ⇒ Object
Amazon Seller Central is an EDI partner; this delegates to
+edi_orders_notification+ (same instance) and renders its template.
48 49 50 |
# File 'app/mailers/edi_mailer.rb', line 48 def amazon_seller_central_orders_notification(orders) edi_orders_notification(orders, partner_name: 'Amazon') end |
#edi_orders_notification(orders, partner_name: nil) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/mailers/edi_mailer.rb', line 31 def edi_orders_notification(orders, partner_name: nil) return null_mail if orders.blank? @orders = orders @partner_name = partner_name || edi_partner_display_name(@orders.first&.edi_orchestrator_partner) subject = "#{@partner_name} Orders Imported into Heatwave: #{@orders.map(&:reference_number).join(', ')}" mail(from: 'Order Notifications <orders@warmlyyours.com>', to: 'orders@warmlyyours.com', cc: 'ediadmin@warmlyyours.com', subject: subject, template_name: 'edi_orders_notification') end |
#notify_ar_of_edi_credit_limit_issue(edi_communication_log, msg: nil) ⇒ Object
84 85 86 87 88 89 90 |
# File 'app/mailers/edi_mailer.rb', line 84 def notify_ar_of_edi_credit_limit_issue(edi_communication_log, msg: nil) sender = 'ediadmin@warmlyyours.com' recipient = 'ar@warmlyyours.com' @edi_communication_log = edi_communication_log @msg = msg mail(from: sender, to: recipient, subject: "EDI Order Could Not Be Processed Due To Credit Limit #{@edi_communication_log.partner} #{@edi_communication_log.category}") end |
#notify_ar_of_new_receipt_created_from_edi_log(receipt, msg: nil) ⇒ Object
118 119 120 121 122 123 124 125 |
# File 'app/mailers/edi_mailer.rb', line 118 def notify_ar_of_new_receipt_created_from_edi_log(receipt, msg: nil) sender = 'ediadmin@warmlyyours.com' recipient = 'ar@warmlyyours.com' @receipt = receipt @customer = Customer.find(@receipt.customer_id) @msg = msg mail(from: sender, to: recipient, subject: "Manual attention required to Receipt #{@receipt.id}") end |
#notify_edi_admin_of_edi_cancel(order, msg = nil) ⇒ Object
92 93 94 95 96 97 98 |
# File 'app/mailers/edi_mailer.rb', line 92 def notify_edi_admin_of_edi_cancel(order, msg = nil) sender = 'ediadmin@warmlyyours.com' recipient = 'ediadmin@warmlyyours.com' @order = order @msg = msg mail(from: sender, to: recipient, subject: "EDI Order Cancellation #{order.reference_number}") end |
#notify_edi_admin_of_error(edi_communication_log, msg: nil) ⇒ Object
61 62 63 64 65 66 67 |
# File 'app/mailers/edi_mailer.rb', line 61 def notify_edi_admin_of_error(edi_communication_log, msg: nil) sender = 'ediadmin@warmlyyours.com' recipient = 'ediadmin@warmlyyours.com' @edi_communication_log = edi_communication_log @msg = msg mail(from: sender, to: recipient, subject: "EDI Processing Error #{@edi_communication_log.partner} #{@edi_communication_log.category}") end |
#notify_edi_admin_of_menard_inventory_error(error_message, item_count: 0) ⇒ Object
100 101 102 103 104 105 106 |
# File 'app/mailers/edi_mailer.rb', line 100 def notify_edi_admin_of_menard_inventory_error(, item_count: 0) sender = 'ediadmin@warmlyyours.com' recipient = 'ediadmin@warmlyyours.com' @error_message = @item_count = item_count mail(from: sender, to: recipient, subject: 'Menard Inventory Upload Failed') end |
#notify_edi_admin_of_mirakl_error(partner, category, msg) ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'app/mailers/edi_mailer.rb', line 52 def notify_edi_admin_of_mirakl_error(partner, category, msg) sender = 'ediadmin@warmlyyours.com' recipient = 'ediadmin@warmlyyours.com' @partner = partner @category = category @msg = msg mail(from: sender, to: recipient, subject: "EDI Processing Error #{partner} #{category}") end |
#notify_edi_admin_of_order_status_mismatches(result) ⇒ Object
69 70 71 72 73 74 75 |
# File 'app/mailers/edi_mailer.rb', line 69 def notify_edi_admin_of_order_status_mismatches(result) sender = 'ediadmin@warmlyyours.com' recipient = 'ediadmin@warmlyyours.com' @result = result mail(from: sender, to: recipient, subject: "Amazon Order Status Mismatch: #{result.partner} — #{result.mismatches.size} order(s)") end |
#notify_edi_admin_of_warning(subj, msg) ⇒ Object
77 78 79 80 81 82 |
# File 'app/mailers/edi_mailer.rb', line 77 def notify_edi_admin_of_warning(subj, msg) sender = 'ediadmin@warmlyyours.com' recipient = 'ediadmin@warmlyyours.com' @msg = msg mail(from: sender, to: recipient, subject: "EDI Processing Warning: #{subj}") end |
#notify_menard_of_pending_discontinue(catalog_item, discontinue_date:, recipients:) ⇒ Object
108 109 110 111 112 113 114 115 116 |
# File 'app/mailers/edi_mailer.rb', line 108 def notify_menard_of_pending_discontinue(catalog_item, discontinue_date:, recipients:) sender = 'ediadmin@warmlyyours.com' @catalog_item = catalog_item @item = catalog_item.store_item.item @discontinue_date = discontinue_date @parent_sku = catalog_item.parent_sku @model_number = catalog_item.third_party_sku.presence || @item.sku mail(from: sender, to: recipients, subject: "WarmlyYours — Pending Discontinue Notice for #{@model_number}") end |