Sha256: e550d3f455148eebf3301d019f691a2577431151542970c1e3d057fbce9b4ed1
Contents?: true
Size: 1.42 KB
Versions: 1
Compression:
Stored size: 1.42 KB
Contents
# frozen_string_literal: true require 'drill/mail/base' module Drill module Mail class Default < Base def deliver template_name = params.template_name Drill.client.messages.send_template(template_name, [], message_hash) end def deliver_later template_name = params.template_name Drill::DeliveryWorker.perform_async(template_name, message_hash) end private def message_hash message_hash = {} to_emails = Array(params.to).map do |email| { email: email } end cc_emails = Array(params.cc).map do |email| { email: email, type: 'cc' } end vars = Hash(params.vars).map do |name, content| { name: name.to_s.upcase, content: content } end all_emails = to_emails + cc_emails unless all_emails.empty? message_hash[:to] = all_emails unless vars.empty? message_hash[:merge_vars] = all_emails.each.with_object([]) do |email, arr| arr << { rcpt: email[:email], vars: vars } end end end message_hash[:from_name] = params.from_name if params.from_name message_hash[:from_email] = params.from_email if params.from_email if params.reply_to message_hash[:headers] = { 'Reply-To' => params.reply_to } end message_hash end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
drill-mailer-0.1.1 | lib/drill/mail/default.rb |