Sha256: dfdd430ac6a98f537bd86f7ed81877db3fbbbb9227b4a29773469d2499d96c46

Contents?: true

Size: 1.13 KB

Versions: 6

Compression:

Stored size: 1.13 KB

Contents

module CreateSend
  # Represents an email template and associated functionality.
  class Template < CreateSend
    attr_reader :template_id

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

    # Creates a new email template.
    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

    # Gets the details of this email template.
    def details
      response = get "/templates/#{template_id}.json", {}
      Hashie::Mash.new(response)
    end

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

    # Deletes this email template.
    def delete
      response = super "/templates/#{template_id}.json", {}
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
createsend-3.4.0 lib/createsend/template.rb
createsend-3.3.0 lib/createsend/template.rb
createsend-3.2.0 lib/createsend/template.rb
createsend-3.1.1 lib/createsend/template.rb
createsend-3.1.0 lib/createsend/template.rb
createsend-3.0.0 lib/createsend/template.rb