Sha256: 1a443ba562e243337ec646ae905e5633348fb489e5cd6161a95d6a6d6ddf5765

Contents?: true

Size: 1.11 KB

Versions: 13

Compression:

Stored size: 1.11 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 }
      put "/templates/#{template_id}.json", options
    end

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

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
createsend-6.1.1 lib/createsend/template.rb
createsend-sendowlfork-6.1.0.pre.hashie5 lib/createsend/template.rb
createsend-6.1.0 lib/createsend/template.rb
createsend-6.0.0 lib/createsend/template.rb
createsend-5.1.1 lib/createsend/template.rb
createsend-5.1.0 lib/createsend/template.rb
createsend-5.0.0 lib/createsend/template.rb
createsend-4.1.2 lib/createsend/template.rb
createsend-4.1.1 lib/createsend/template.rb
createsend-4.1.0 lib/createsend/template.rb
createsend-4.0.2 lib/createsend/template.rb
createsend-4.0.1 lib/createsend/template.rb
createsend-4.0.0 lib/createsend/template.rb