Class: SendGrid::ApiHeader
- Inherits:
-
Object
- Object
- SendGrid::ApiHeader
- Defined in:
- lib/send_grid/api_header.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
- #add_filter_setting(fltr, setting, val) ⇒ Object
- #add_recipients(recipients) ⇒ Object
- #category(cat) ⇒ Object
- #deliver_at(timestamp) ⇒ Object
-
#initialize ⇒ ApiHeader
constructor
A new instance of ApiHeader.
- #substitute(var, val) ⇒ Object
- #template_id(temp_id) ⇒ Object
- #to_json ⇒ Object
- #uniq_args(val) ⇒ Object
Constructor Details
#initialize ⇒ ApiHeader
Returns a new instance of ApiHeader.
4 5 6 |
# File 'lib/send_grid/api_header.rb', line 4 def initialize @data = Hash.new { |h,k| h[k] = Hash.new(&h.default_proc) } end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
2 3 4 |
# File 'lib/send_grid/api_header.rb', line 2 def data @data end |
Instance Method Details
#add_filter_setting(fltr, setting, val) ⇒ Object
25 26 27 |
# File 'lib/send_grid/api_header.rb', line 25 def add_filter_setting(fltr, setting, val) @data[:filters][fltr][:settings][setting] = val end |
#add_recipients(recipients) ⇒ Object
8 9 10 11 |
# File 'lib/send_grid/api_header.rb', line 8 def add_recipients(recipients) @data[:to] = [] unless @data[:to].instance_of?(Array) @data[:to] |= Array.wrap(recipients) end |
#category(cat) ⇒ Object
21 22 23 |
# File 'lib/send_grid/api_header.rb', line 21 def category(cat) @data[:category] = cat end |
#deliver_at(timestamp) ⇒ Object
29 30 31 |
# File 'lib/send_grid/api_header.rb', line 29 def deliver_at() @data[:send_at] = end |
#substitute(var, val) ⇒ Object
13 14 15 |
# File 'lib/send_grid/api_header.rb', line 13 def substitute(var, val) @data[:sub][var] = Array.wrap(val) end |
#template_id(temp_id) ⇒ Object
33 34 35 36 |
# File 'lib/send_grid/api_header.rb', line 33 def template_id(temp_id) add_filter_setting('templates', 'enable', '1') add_filter_setting('templates', 'template_id', temp_id) end |
#to_json ⇒ Object
38 39 40 |
# File 'lib/send_grid/api_header.rb', line 38 def to_json JSON.generate(@data, :array_nl => ' ') end |
#uniq_args(val) ⇒ Object
17 18 19 |
# File 'lib/send_grid/api_header.rb', line 17 def uniq_args(val) @data[:unique_args] = val if val.instance_of?(Hash) end |