Class: CreateSend::Template

Inherits:
Object
  • Object
show all
Defined in:
lib/createsend/template.rb

Overview

Represents an email template and associated functionality.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(template_id) ⇒ Template

Returns a new instance of Template.



9
10
11
# File 'lib/createsend/template.rb', line 9

def initialize(template_id)
  @template_id = template_id
end

Instance Attribute Details

#template_idObject (readonly)

Returns the value of attribute template_id.



7
8
9
# File 'lib/createsend/template.rb', line 7

def template_id
  @template_id
end

Class Method Details

.create(client_id, name, html_url, zip_url) ⇒ Object

Creates a new email template.



14
15
16
17
18
19
20
21
# File 'lib/createsend/template.rb', line 14

def self.create(client_id, name, html_url, zip_url)
  options = { :body => {
    :Name => name,
    :HtmlPageURL => html_url,
    :ZipFileURL => zip_url }.to_json }
  response = CreateSend.post "/templates/#{client_id}.json", options
  response.parsed_response
end

Instance Method Details

#deleteObject

Deletes this email template.



39
40
41
# File 'lib/createsend/template.rb', line 39

def delete
  response = CreateSend.delete "/templates/#{template_id}.json", {}
end

#detailsObject

Gets the details of this email template.



24
25
26
27
# File 'lib/createsend/template.rb', line 24

def details
  response = CreateSend.get "/templates/#{template_id}.json", {}
  Hashie::Mash.new(response)
end

#update(name, html_url, zip_url) ⇒ Object

Updates this email template.



30
31
32
33
34
35
36
# File 'lib/createsend/template.rb', line 30

def update(name, html_url, zip_url)
  options = { :body => {
    :Name => name,
    :HtmlPageURL => html_url,
    :ZipFileURL => zip_url }.to_json }
  response = CreateSend.put "/templates/#{template_id}.json", options
end