Class: CreateSend::Template

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

Overview

Represents an email template and associated functionality.

Constant Summary

Constants included from CreateSend

USER_AGENT_STRING, VERSION

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(auth, template_id) ⇒ Template

Returns a new instance of Template.



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

def initialize(auth, template_id)
  @template_id = template_id
  super
end

Instance Attribute Details

#template_idObject (readonly)

Returns the value of attribute template_id.



4
5
6
# File 'lib/createsend/template.rb', line 4

def template_id
  @template_id
end

Class Method Details

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

Creates a new email template.



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

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

Instance Method Details

#deleteObject

Deletes this email template.



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

def delete
  super "/templates/#{template_id}.json", {}
end

#detailsObject

Gets the details of this email template.



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

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

#update(name, html_url, zip_url) ⇒ Object

Updates this email template.



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

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