Sha256: 1fd40a5e9d790dec5b30a8c471d98e61006a3985edbc535829cd346b9bdd88e9

Contents?: true

Size: 993 Bytes

Versions: 1

Compression:

Stored size: 993 Bytes

Contents

require 'createsend'
require 'json'

class Template
  attr_reader :template_id

  def initialize(template_id)
    @template_id = template_id
  end

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

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

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
createsend-0.0.1 lib/template.rb