lib/sendgrid_actionmailer.rb in sendgrid-actionmailer-3.0.2 vs lib/sendgrid_actionmailer.rb in sendgrid-actionmailer-3.1.0
- old
+ new
@@ -14,11 +14,11 @@
raise_delivery_errors: false
}.freeze
attr_accessor :settings, :api_key
- def initialize(**params)
+ def initialize(params = {})
self.settings = DEFAULTS.merge(params)
end
def deliver!(mail)
sendgrid_mail = Mail.new.tap do |m|
@@ -133,11 +133,11 @@
disposition = get_disposition(part)
a.disposition = disposition unless disposition.nil?
has_content_id = part.header && part.has_content_id?
- a.content_id = part.header['content_id'].value if has_content_id
+ a.content_id = part.header['content_id'].field.content_id if has_content_id
end
end
def get_disposition(message)
return if message.header.nil?
@@ -183,11 +183,11 @@
if mail['personalizations']
mail['personalizations'].unparsed_value.each do |p|
sendgrid_mail.add_personalization(setup_personalization(mail, p))
end
end
- if (mail.to && mail.to.any?) || (mail.cc && mail.cc.any?) || (mail.bcc && mail.bcc.any?)
+ if (mail.to && !mail.to.empty?) || (mail.cc && !mail.cc.empty?) || (mail.bcc && !mail.bcc.empty?)
personalization = setup_personalization(mail, {})
to_emails(mail.to).each { |to| personalization.add_to(to) }
to_emails(mail.cc).each { |cc| personalization.add_cc(cc) }
to_emails(mail.bcc).each { |bcc| personalization.add_bcc(bcc) }
sendgrid_mail.add_personalization(personalization)
@@ -227,11 +227,11 @@
if mail['asm']
asm = mail['asm'].unparsed_value
asm = asm.delete_if { |key, value|
!key.to_s.match(/(group_id)|(groups_to_display)/) }
if asm.keys.map(&:to_s).include?('group_id')
- sendgrid_mail.asm = ASM.new(self.class.transform_keys(asm, &:to_sym))
+ sendgrid_mail.asm = ASM.new(**self.class.transform_keys(asm, &:to_sym))
end
end
if mail['ip_pool_name']
sendgrid_mail.ip_pool_name = mail['ip_pool_name'].to_s
end
@@ -240,42 +240,42 @@
def add_mail_settings(sendgrid_mail, mail)
if mail['mail_settings']
settings = mail['mail_settings'].unparsed_value || {}
sendgrid_mail.mail_settings = MailSettings.new.tap do |m|
if settings[:bcc]
- m.bcc = BccSettings.new(settings[:bcc])
+ m.bcc = BccSettings.new(**settings[:bcc])
end
if settings[:bypass_list_management]
- m.bypass_list_management = BypassListManagement.new(settings[:bypass_list_management])
+ m.bypass_list_management = BypassListManagement.new(**settings[:bypass_list_management])
end
if settings[:footer]
- m.footer = Footer.new(settings[:footer])
+ m.footer = Footer.new(**settings[:footer])
end
if settings[:sandbox_mode]
- m.sandbox_mode = SandBoxMode.new(settings[:sandbox_mode])
+ m.sandbox_mode = SandBoxMode.new(**settings[:sandbox_mode])
end
if settings[:spam_check]
- m.spam_check = SpamCheck.new(settings[:spam_check])
+ m.spam_check = SpamCheck.new(**settings[:spam_check])
end
end
end
end
def add_tracking_settings(sendgrid_mail, mail)
if mail['tracking_settings']
settings = mail['tracking_settings'].unparsed_value
sendgrid_mail.tracking_settings = TrackingSettings.new.tap do |t|
if settings[:click_tracking]
- t.click_tracking = ClickTracking.new(settings[:click_tracking])
+ t.click_tracking = ClickTracking.new(**settings[:click_tracking])
end
if settings[:open_tracking]
- t.open_tracking = OpenTracking.new(settings[:open_tracking])
+ t.open_tracking = OpenTracking.new(**settings[:open_tracking])
end
if settings[:subscription_tracking]
- t.subscription_tracking = SubscriptionTracking.new(settings[:subscription_tracking])
+ t.subscription_tracking = SubscriptionTracking.new(**settings[:subscription_tracking])
end
if settings[:ganalytics]
- t.ganalytics = Ganalytics.new(settings[:ganalytics])
+ t.ganalytics = Ganalytics.new(**settings[:ganalytics])
end
end
end
end