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) ⇒ 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 ⇒ 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) ⇒ 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) ⇒ Hash
Add a new template
36 37 38 39 |
# File 'lib/mandrill/api.rb', line 36 def add(name, from_email=nil, from_name=nil, subject=nil, code=nil, text=nil, publish=true) _params = {:name => name, :from_email => from_email, :from_name => from_name, :subject => subject, :code => code, :text => text, :publish => publish} return @master.call 'templates/add', _params end |
#delete(name) ⇒ Hash
Delete a template
138 139 140 141 |
# File 'lib/mandrill/api.rb', line 138 def delete(name) _params = {:name => name} return @master.call 'templates/delete', _params end |
#info(name) ⇒ Hash
Get the information for an existing template
60 61 62 63 |
# File 'lib/mandrill/api.rb', line 60 def info(name) _params = {:name => name} return @master.call 'templates/info', _params end |
#list ⇒ Array
Return a list of all the templates available to this user
162 163 164 165 |
# File 'lib/mandrill/api.rb', line 162 def list() _params = {} 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.
114 115 116 117 |
# File 'lib/mandrill/api.rb', line 114 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
198 199 200 201 |
# File 'lib/mandrill/api.rb', line 198 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
181 182 183 184 |
# File 'lib/mandrill/api.rb', line 181 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) ⇒ Hash
Update the code for an existing template. If null is provided for any fields, the values will remain unchanged.
90 91 92 93 |
# File 'lib/mandrill/api.rb', line 90 def update(name, from_email=nil, from_name=nil, subject=nil, code=nil, text=nil, publish=true) _params = {:name => name, :from_email => from_email, :from_name => from_name, :subject => subject, :code => code, :text => text, :publish => publish} return @master.call 'templates/update', _params end |