Class: EmailDirect::ImageFile

Inherits:
Object
  • Object
show all
Defined in:
lib/emaildirect/image_file.rb

Overview

Represents a image file and associated functionality

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_path) ⇒ ImageFile

Returns a new instance of ImageFile.



26
27
28
# File 'lib/emaildirect/image_file.rb', line 26

def initialize(file_path)
  @file_path = file_path
end

Instance Attribute Details

#file_pathObject (readonly)

Returns the value of attribute file_path.



24
25
26
# File 'lib/emaildirect/image_file.rb', line 24

def file_path
  @file_path
end

Class Method Details

.create_from_file(file_name, local_path, options = {}) ⇒ Object



14
15
16
17
# File 'lib/emaildirect/image_file.rb', line 14

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

.create_from_url(url, options = {}) ⇒ Object



8
9
10
11
12
# File 'lib/emaildirect/image_file.rb', line 8

def create_from_url(url, options = {})
  options.merge! :URL => url
  response = EmailDirect.post uri, :body => options.to_json
  Hashie::Mash.new(response)
end

.uriObject



19
20
21
# File 'lib/emaildirect/image_file.rb', line 19

def uri
  '/ImageLibrary'
end

Instance Method Details

#deleteObject



35
36
37
# File 'lib/emaildirect/image_file.rb', line 35

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

#detailsObject



30
31
32
33
# File 'lib/emaildirect/image_file.rb', line 30

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