Class: SendGrid::ApiHeader

Inherits:
Object
  • Object
show all
Defined in:
lib/send_grid/api_header.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeApiHeader


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

#dataObject (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(timestamp)
  @data[:send_at] = timestamp
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

#to_jsonObject


33
34
35
# File 'lib/send_grid/api_header.rb', line 33

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