Class: Mandrill::Templates
- Inherits:
-
Object
- Object
- Mandrill::Templates
- Defined in:
- lib/mandrill/api.rb
Instance Attribute Summary collapse
-
#master ⇒ Object
Returns the value of attribute master.
Instance Method Summary collapse
-
#add(name, from_email = nil, from_name = nil, subject = nil, code = nil, text = nil, publish = true, labels = []) ⇒ Hash
Add a new template.
-
#delete(name) ⇒ Hash
Delete a template.
-
#info(name) ⇒ Hash
Get the information for an existing template.
-
#initialize(master) ⇒ Templates
constructor
A new instance of Templates.
-
#list(label = nil) ⇒ Array
Return a list of all the templates available to this user.
-
#publish(name) ⇒ Hash
Publish the content for the template.
-
#render(template_name, template_content, merge_vars = nil) ⇒ Hash
Inject content and optionally merge fields into a template, returning the HTML that results.
-
#time_series(name) ⇒ Array
Return the recent history (hourly stats for the last 30 days) for a template.
-
#update(name, from_email = nil, from_name = nil, subject = nil, code = nil, text = nil, publish = true, labels = nil) ⇒ Hash
Update the code for an existing template.
Constructor Details
#initialize(master) ⇒ Templates
Returns a new instance of Templates.
7 8 9 |
# File 'lib/mandrill/api.rb', line 7 def initialize(master) @master = master end |
Instance Attribute Details
#master ⇒ Object
Returns the value of attribute master.
5 6 7 |
# File 'lib/mandrill/api.rb', line 5 def master @master end |
Instance Method Details
#add(name, from_email = nil, from_name = nil, subject = nil, code = nil, text = nil, publish = true, labels = []) ⇒ Hash
Add a new template
40 41 42 43 |
# File 'lib/mandrill/api.rb', line 40 def add(name, from_email=nil, from_name=nil, subject=nil, code=nil, text=nil, publish=true, labels=[]) _params = {:name => name, :from_email => from_email, :from_name => from_name, :subject => subject, :code => code, :text => text, :publish => publish, :labels => labels} return @master.call 'templates/add', _params end |
#delete(name) ⇒ Hash
Delete a template
152 153 154 155 |
# File 'lib/mandrill/api.rb', line 152 def delete(name) _params = {:name => name} return @master.call 'templates/delete', _params end |
#info(name) ⇒ Hash
Get the information for an existing template
66 67 68 69 |
# File 'lib/mandrill/api.rb', line 66 def info(name) _params = {:name => name} return @master.call 'templates/info', _params end |
#list(label = nil) ⇒ Array
Return a list of all the templates available to this user
179 180 181 182 |
# File 'lib/mandrill/api.rb', line 179 def list(label=nil) _params = {:label => label} return @master.call 'templates/list', _params end |
#publish(name) ⇒ Hash
Publish the content for the template. Any new messages sent using this template will start using the content that was previously in draft.
126 127 128 129 |
# File 'lib/mandrill/api.rb', line 126 def publish(name) _params = {:name => name} return @master.call 'templates/publish', _params end |
#render(template_name, template_content, merge_vars = nil) ⇒ Hash
Inject content and optionally merge fields into a template, returning the HTML that results
215 216 217 218 |
# File 'lib/mandrill/api.rb', line 215 def render(template_name, template_content, merge_vars=nil) _params = {:template_name => template_name, :template_content => template_content, :merge_vars => merge_vars} return @master.call 'templates/render', _params end |
#time_series(name) ⇒ Array
Return the recent history (hourly stats for the last 30 days) for a template
198 199 200 201 |
# File 'lib/mandrill/api.rb', line 198 def time_series(name) _params = {:name => name} return @master.call 'templates/time-series', _params end |
#update(name, from_email = nil, from_name = nil, subject = nil, code = nil, text = nil, publish = true, labels = nil) ⇒ Hash
Update the code for an existing template. If null is provided for any fields, the values will remain unchanged.
100 101 102 103 |
# File 'lib/mandrill/api.rb', line 100 def update(name, from_email=nil, from_name=nil, subject=nil, code=nil, text=nil, publish=true, labels=nil) _params = {:name => name, :from_email => from_email, :from_name => from_name, :subject => subject, :code => code, :text => text, :publish => publish, :labels => labels} return @master.call 'templates/update', _params end |