class SendGrid::ApiHeader
Attributes
data[R]
Public Class Methods
new()
click to toggle source
# File lib/send_grid/api_header.rb, line 4 def initialize @data = Hash.new { |h,k| h[k] = Hash.new(&h.default_proc) } end
Public Instance Methods
add_filter_setting(fltr, setting, val)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# File lib/send_grid/api_header.rb, line 21 def category(cat) @data[:category] = cat end
deliver_at(timestamp)
click to toggle source
# File lib/send_grid/api_header.rb, line 29 def deliver_at(timestamp) @data[:send_at] = timestamp end
substitute(var, val)
click to toggle source
# File lib/send_grid/api_header.rb, line 13 def substitute(var, val) @data[:sub][var] = Array.wrap(val) end
template_id(temp_id)
click to toggle source
# 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()
click to toggle source
# File lib/send_grid/api_header.rb, line 38 def to_json JSON.generate(@data, :array_nl => ' ') end
uniq_args(val)
click to toggle source
# File lib/send_grid/api_header.rb, line 17 def uniq_args(val) @data[:unique_args] = val if val.instance_of?(Hash) end