Class: Mailer
- Inherits:
-
ApplicationMailer
- Object
- ActionMailer::Base
- ApplicationMailer
- Mailer
- Defined in:
- app/mailers/mailer.rb
Class Method Summary collapse
Instance Method Summary collapse
- #admin_notification(subj, message = nil) ⇒ Object
- #canada_post_manual_void_email(delivery, tracking_numbers) ⇒ Object
- #canada_post_manual_void_email_for_mail_activity(mail_activity, tracking_numbers) ⇒ Object
- #default_url_options ⇒ Object
- #generic_mailer(options) ⇒ Object
- #personal_connect(sender, values = {}) ⇒ Object
- #purolator_manual_void_email(delivery, tracking_numbers) ⇒ Object
- #saia_schedule_pickup_failed_email(email, deliveries, message) ⇒ Object
- #schedule_pickup_failed_email(email, carrier, deliveries, message) ⇒ Object
Methods inherited from ApplicationMailer
Class Method Details
.format_exception(options) ⇒ Object
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 |
# File 'app/mailers/mailer.rb', line 12 def self.format_exception() request_context = +'' if [:message] request_context << [:message] request_context << "\n-----------------------------------------------\n" end if [:current_user] request_context << "Current User: #{[:current_user]}" request_context << "\n-----------------------------------------------\n" end if [:current_account] request_context << "Current Account: #{[:current_account]}" request_context << "\n-----------------------------------------------\n" end if [:exception] request_context << "Exception: #{[:exception].to_s}\n\n" request_context << "Backtrace:" request_context << [:exception].backtrace.join("\n") request_context << "\n-----------------------------------------------\n" end if [:request] request_context << "\n\nRequest:" [:request].env.each{|k,v| request_context << "#{k} : #{v}\n" } request_context << "\n-----------------------------------------------\n" end return request_context end |
Instance Method Details
#admin_notification(subj, message = nil) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/mailers/mailer.rb', line 45 def admin_notification(subj, =nil) if .nil? = subj subj = "An admin notification was sent" end if .is_a?Hash @message = Mailer.format_exception() else @message = end mail(:to => ADMINISTRATOR_EMAIL, :subject => subj, :from => ADMINISTRATOR_EMAIL) end |
#canada_post_manual_void_email(delivery, tracking_numbers) ⇒ Object
108 109 110 111 112 113 114 |
# File 'app/mailers/mailer.rb', line 108 def canada_post_manual_void_email(delivery, tracking_numbers) store_id = ((delivery.customer.store.id) rescue 1) sender = 'heatwaveteam@warmlyyours.com' @delivery = delivery @tracking_numbers = tracking_numbers mail(from: sender, to: 'orders@warmlyyours.com', subject: "Delivery was voided in Heatwave but shipments were not cancelled through Canada Post API, see enclosed tracking numbers") end |
#canada_post_manual_void_email_for_mail_activity(mail_activity, tracking_numbers) ⇒ Object
100 101 102 103 104 105 106 |
# File 'app/mailers/mailer.rb', line 100 def canada_post_manual_void_email_for_mail_activity(mail_activity, tracking_numbers) store_id = mail_activity.store.id sender = 'heatwaveteam@warmlyyours.com' @mail_activity = mail_activity @tracking_numbers = tracking_numbers mail(from: sender, to: 'orders@warmlyyours.com', subject: "Mail Activity was voided in Heatwave but shipments were not cancelled through Canada Post API, see enclosed tracking numbers") end |
#default_url_options ⇒ Object
8 9 10 |
# File 'app/mailers/mailer.rb', line 8 def UrlHelper.({ host: CRM_HOSTNAME }) end |
#generic_mailer(options) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'app/mailers/mailer.rb', line 58 def generic_mailer() [:extra_headers] ||= {} sender = [:from] sender_email = sender.try(:email) || sender.to_s || "info@warmlyyours.com" files_to_attach = [:attachments] || [] = [] files_to_attach.each do |a| if a.class == Upload and a.category == "purchase_order" [:cc] = ACCOUNTS_PAYABLE_EMAIL end if a.class == Upload and (a.category == "organization_quote_pdf" or a.category == "msrp_quote_pdf") ["Quote #{a.resource.reference_number}.pdf"] = a..data elsif a.class == Upload and a.category == "invoice_pdf" ["Invoice #{a.resource.reference_number}.pdf"] = a..data elsif a.respond_to?('attachment') and a..present? [a.] = a..data elsif a.respond_to?('legacy_attachment') and a..file? [a.] = a..data elsif a.is_a? Item #Publication if [:transmission_method] == "fax" or !a.is_available_to_public [a.public_file_name] = a..data elsif a.is_available_to_public << a end end end headers["Reply-to"] = [:reply_to] || sender_email @documents_plain = Communication.documents_plain() @documents_html = Communication.documents_html() @message_plain = [:message] @message_html = Communication.text_to_html([:message]) @signature_plain = [:signature] @signature_html = Communication.signature_to_html([:signature]) @no_verbage = [:no_verbage] [:extra_headers].each do |k,v| headers[k] = v end mail(:to => [:to], :from => sender_email, :cc => [:cc], :bcc => [:bcc], :subject => [:subject]) end |
#personal_connect(sender, values = {}) ⇒ Object
140 141 142 143 144 |
# File 'app/mailers/mailer.rb', line 140 def personal_connect(sender,values={}) @values = values @no_verbage = true mail(from: sender, to: "webenquiries@warmlyyours.com", subject: "A personal connect enquiry was made from #{sender} on: #{Time.current}") end |
#purolator_manual_void_email(delivery, tracking_numbers) ⇒ Object
116 117 118 119 120 121 122 |
# File 'app/mailers/mailer.rb', line 116 def purolator_manual_void_email(delivery, tracking_numbers) store_id = ((delivery.customer.store.id) rescue 1) sender = 'heatwaveteam@warmlyyours.com' @delivery = delivery @tracking_numbers = tracking_numbers mail(from: sender, to: 'orders@warmlyyours.com', subject: "Delivery was voided in Heatwave but shipments were not cancelled through Purolator API, see enclosed tracking numbers") end |
#saia_schedule_pickup_failed_email(email, deliveries, message) ⇒ Object
124 125 126 127 128 129 130 |
# File 'app/mailers/mailer.rb', line 124 def saia_schedule_pickup_failed_email(email, deliveries, ) sender = 'heatwaveteam@warmlyyours.com' @carrier = 'Saia' @deliveries = deliveries @message = mail(from: sender, to: email, subject: "Could not schedule SAIA pickup, you may want to schedule it manually") end |
#schedule_pickup_failed_email(email, carrier, deliveries, message) ⇒ Object
132 133 134 135 136 137 138 |
# File 'app/mailers/mailer.rb', line 132 def schedule_pickup_failed_email(email, carrier, deliveries, ) sender = 'heatwaveteam@warmlyyours.com' @carrier = carrier @deliveries = deliveries @message = mail(from: sender, to: email, subject: "Could not schedule #{carrier} pickup, you may want to schedule it manually") end |