Sha256: 79f4425e9f98e7eda9079877a865de4cd5a1a144e5f6488496eb021aba2060fe

Contents?: true

Size: 1.29 KB

Versions: 11

Compression:

Stored size: 1.29 KB

Contents

require 'emaildirect'
require 'json'

module EmailDirect
  # Represents a creative folder and associated functionality
  class CreativeFolder
    class << self
      def all(options = {})
        response = EmailDirect.get '/Creatives/Folders', :query => options
        Hashie::Mash.new(response)
      end

      def create(name, parent_id = nil)
        uri = '/Creatives/Folders'
        uri << "/#{parent_id}" if parent_id
        response = EmailDirect.post uri, :body => name.to_json
        Hashie::Mash.new(response)
      end
    end

    attr_reader :folder_id

    def initialize(folder_id)
      @folder_id = folder_id
    end

    def details
      response = get
      Hashie::Mash.new(response)
    end

    def templates(options = {})
      response = get 'Templates', options
      Hashie::Mash.new(response)
    end

    def update(name)
      response = EmailDirect.put uri_for, :body => name.to_json
      Hashie::Mash.new(response)
    end

    def delete
      response = EmailDirect.delete uri_for, {}
      Hashie::Mash.new(response)
    end

    private

    def get(action = nil, options = {})
      EmailDirect.get uri_for(action), :query => options
    end

    def uri_for(action = nil)
      action = "/#{action}" if action
      "/Creatives/Folders/#{folder_id}#{action}"
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
emaildirect-2.0.0 lib/emaildirect/creative_folder.rb
emaildirect-1.3.4 lib/emaildirect/creative_folder.rb
emaildirect-1.3.3 lib/emaildirect/creative_folder.rb
emaildirect-1.3.2 lib/emaildirect/creative_folder.rb
emaildirect-1.3.1 lib/emaildirect/creative_folder.rb
emaildirect-1.3.0 lib/emaildirect/creative_folder.rb
emaildirect-1.2.1 lib/emaildirect/creative_folder.rb
emaildirect-1.2.0 lib/emaildirect/creative_folder.rb
emaildirect-1.1.0 lib/emaildirect/creative_folder.rb
emaildirect-1.0.1 lib/emaildirect/creative_folder.rb
emaildirect-1.0.0 lib/emaildirect/creative_folder.rb