Class: SendGrid::Personalization
- Inherits:
-
Object
- Object
- SendGrid::Personalization
- Defined in:
- lib/sendgrid/helpers/mail/personalization.rb
Instance Attribute Summary collapse
-
#bccs ⇒ Object
readonly
Returns the value of attribute bccs.
-
#ccs ⇒ Object
readonly
Returns the value of attribute ccs.
-
#custom_args ⇒ Object
readonly
Returns the value of attribute custom_args.
-
#dynamic_template_data ⇒ Object
readonly
Returns the value of attribute dynamic_template_data.
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#send_at ⇒ Object
Returns the value of attribute send_at.
-
#subject ⇒ Object
Returns the value of attribute subject.
-
#substitutions ⇒ Object
readonly
Returns the value of attribute substitutions.
-
#tos ⇒ Object
readonly
Returns the value of attribute tos.
Instance Method Summary collapse
- #add_bcc(bcc) ⇒ Object
- #add_cc(cc) ⇒ Object
- #add_custom_arg(custom_arg) ⇒ Object
- #add_dynamic_template_data(dynamic_template_data) ⇒ Object
- #add_from(from) ⇒ Object
- #add_header(header) ⇒ Object
- #add_substitution(substitution) ⇒ Object
- #add_to(to) ⇒ Object
-
#initialize ⇒ Personalization
constructor
A new instance of Personalization.
- #to_json ⇒ Object
Constructor Details
#initialize ⇒ Personalization
Returns a new instance of Personalization.
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/sendgrid/helpers/mail/personalization.rb', line 10 def initialize @tos = [] @from = nil @ccs = [] @bccs = [] @subject = nil @headers = {} @substitutions = {} @custom_args = {} @dynamic_template_data = {} @send_at = nil end |
Instance Attribute Details
#bccs ⇒ Object (readonly)
Returns the value of attribute bccs.
5 6 7 |
# File 'lib/sendgrid/helpers/mail/personalization.rb', line 5 def bccs @bccs end |
#ccs ⇒ Object (readonly)
Returns the value of attribute ccs.
5 6 7 |
# File 'lib/sendgrid/helpers/mail/personalization.rb', line 5 def ccs @ccs end |
#custom_args ⇒ Object (readonly)
Returns the value of attribute custom_args.
5 6 7 |
# File 'lib/sendgrid/helpers/mail/personalization.rb', line 5 def custom_args @custom_args end |
#dynamic_template_data ⇒ Object (readonly)
Returns the value of attribute dynamic_template_data.
5 6 7 |
# File 'lib/sendgrid/helpers/mail/personalization.rb', line 5 def dynamic_template_data @dynamic_template_data end |
#from ⇒ Object (readonly)
Returns the value of attribute from.
5 6 7 |
# File 'lib/sendgrid/helpers/mail/personalization.rb', line 5 def from @from end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
5 6 7 |
# File 'lib/sendgrid/helpers/mail/personalization.rb', line 5 def headers @headers end |
#send_at ⇒ Object
Returns the value of attribute send_at.
8 9 10 |
# File 'lib/sendgrid/helpers/mail/personalization.rb', line 8 def send_at @send_at end |
#subject ⇒ Object
Returns the value of attribute subject.
8 9 10 |
# File 'lib/sendgrid/helpers/mail/personalization.rb', line 8 def subject @subject end |
#substitutions ⇒ Object (readonly)
Returns the value of attribute substitutions.
5 6 7 |
# File 'lib/sendgrid/helpers/mail/personalization.rb', line 5 def substitutions @substitutions end |
#tos ⇒ Object (readonly)
Returns the value of attribute tos.
5 6 7 |
# File 'lib/sendgrid/helpers/mail/personalization.rb', line 5 def tos @tos end |
Instance Method Details
#add_bcc(bcc) ⇒ Object
39 40 41 42 43 |
# File 'lib/sendgrid/helpers/mail/personalization.rb', line 39 def add_bcc(bcc) raise DuplicatePersonalizationError if duplicate?(bcc) @bccs << bcc.to_json end |
#add_cc(cc) ⇒ Object
33 34 35 36 37 |
# File 'lib/sendgrid/helpers/mail/personalization.rb', line 33 def add_cc(cc) raise DuplicatePersonalizationError if duplicate?(cc) @ccs << cc.to_json end |
#add_custom_arg(custom_arg) ⇒ Object
55 56 57 58 |
# File 'lib/sendgrid/helpers/mail/personalization.rb', line 55 def add_custom_arg(custom_arg) custom_arg = custom_arg.to_json @custom_args = @custom_args.merge(custom_arg['custom_arg']) end |
#add_dynamic_template_data(dynamic_template_data) ⇒ Object
60 61 62 |
# File 'lib/sendgrid/helpers/mail/personalization.rb', line 60 def add_dynamic_template_data(dynamic_template_data) @dynamic_template_data.merge!(dynamic_template_data) end |
#add_from(from) ⇒ Object
29 30 31 |
# File 'lib/sendgrid/helpers/mail/personalization.rb', line 29 def add_from(from) @from = from.to_json end |
#add_header(header) ⇒ Object
45 46 47 48 |
# File 'lib/sendgrid/helpers/mail/personalization.rb', line 45 def add_header(header) header = header.to_json @headers = @headers.merge(header['header']) end |
#add_substitution(substitution) ⇒ Object
50 51 52 53 |
# File 'lib/sendgrid/helpers/mail/personalization.rb', line 50 def add_substitution(substitution) substitution = substitution.to_json @substitutions = @substitutions.merge(substitution['substitution']) end |
#add_to(to) ⇒ Object
23 24 25 26 27 |
# File 'lib/sendgrid/helpers/mail/personalization.rb', line 23 def add_to(to) raise DuplicatePersonalizationError if duplicate?(to) @tos << to.to_json end |
#to_json ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/sendgrid/helpers/mail/personalization.rb', line 64 def to_json(*) { 'to' => tos, 'from' => from, 'cc' => ccs, 'bcc' => bccs, 'subject' => subject, 'headers' => headers, 'substitutions' => substitutions, 'custom_args' => custom_args, 'dynamic_template_data' => dynamic_template_data, 'send_at' => send_at }.delete_if { |_, value| value.to_s.strip == '' || value == [] || value == {} } end |