Skip to content

Commit

Permalink
Merge pull request #7 from apartmentlist/bug/actual-template-calling
Browse files Browse the repository at this point in the history
Bug with substitution calling in template and change to association
  • Loading branch information
yez committed Aug 31, 2015
2 parents 5f4e852 + 1e19538 commit eeedd4d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
12 changes: 2 additions & 10 deletions lib/sendgrid/mail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
module SendGrid
class Mail
attr_accessor :to, :to_name, :from, :from_name, :subject, :text, :html, :cc,
:bcc, :reply_to, :date, :smtpapi, :attachments, :template_id
:bcc, :reply_to, :date, :smtpapi, :attachments, :template

def initialize(params = {})
params.each do |k, v|
Expand Down Expand Up @@ -58,16 +58,8 @@ def to_h
payload
end

private

def template
return if template_id.nil?

@template ||= Template.new(template_id)
end

def smtpapi_json
if template
unless template.nil? && template.is_a?(Template)
template.add_to_smtpapi(@smtpapi)
end

Expand Down
4 changes: 2 additions & 2 deletions lib/sendgrid/recipient.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ def initialize(address)
end

def add_substitution(key, value)
substitutions[key.to_sym] = value
substitutions[key] = value
end

def add_to_smtpapi(smtpapi)
smtpapi.add_to(@address)

@substitutions.each do |key, value|
smtpapi.add_substitution(key, value)
smtpapi.add_substitution(key, [value])
end
end
end
Expand Down

0 comments on commit eeedd4d

Please sign in to comment.