Sha256: 183019ed920ab7e6203bc2a42299d2ba289d88caa32626ac53f790a85773135d

Contents?: true

Size: 980 Bytes

Versions: 11

Compression:

Stored size: 980 Bytes

Contents

require 'emaildirect'
require 'json'

module EmailDirect
  # Represents a image file and associated functionality
  class ImageFile
    class << self
      def create_from_url(url, options = {})
        options.merge! :URL => url
        response = EmailDirect.post uri, :body => options.to_json
        Hashie::Mash.new(response)
      end

      def create_from_file(file_name, local_path, options = {})
        options.merge! :FileName => file_name
        EmailDirect.post '/ImageUpload', :query => options, :body => File.read(local_path)
      end

      def uri
        '/ImageLibrary'
      end
    end

    attr_reader :file_path

    def initialize(file_path)
      @file_path = file_path
    end

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

    def delete
      EmailDirect.delete self.class.uri, query
    end

    private

    def query
      { :query => { :File => file_path } }
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

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