Sha256: 3a7bc7c1d8fedb4c77d5d63716f49be95cb77683f0cd8f2526075c302369ac2d

Contents?: true

Size: 1.12 KB

Versions: 11

Compression:

Stored size: 1.12 KB

Contents

require 'emaildirect'
require 'json'

module EmailDirect
  # Represents a image folder and associated functionality
  class ImageFolder
    class << self
      def all(options = {})
        response = EmailDirect.get uri, :query => options
        Hashie::Mash.new(response)
      end

      def create(name, folder_path = nil)
        options = { :body => name.to_json }
        options[:query] = { :Folder => folder_path } if folder_path
        response = EmailDirect.post uri, options
        Hashie::Mash.new(response)
      end

      def uri
        '/ImageLibrary/Folders'
      end
    end

    attr_reader :folder_path

    def initialize(folder_path)
      @folder_path = folder_path
    end

    def details
      response = EmailDirect.get self.class.uri, query
      Hashie::Mash.new(response)
    end

    def files
      response = EmailDirect.get '/ImageLibrary/Files', query
      Hashie::Mash.new(response)
    end

    def delete
      response = EmailDirect.delete self.class.uri, query
      Hashie::Mash.new(response)
    end

    private

    def query
      { :query => { :Folder => folder_path } }
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

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