Class: InterFAX::Outbound::Delivery

Inherits:
Object
  • Object
show all
Defined in:
lib/interfax/outbound/delivery.rb

Constant Summary collapse

VALID_KEYS =
[:faxNumber, :contact, :postponeTime, :retriesToPerform, :csid, :pageHeader, :reference, :replyAddress, :pageSize, :fitToPage, :pageOrientation, :resolution, :rendering]
BOUNDARY =
"43e578690a6d14bf1d776cd55e7d7e29"
HEADERS =
{
  "Content-Type" => "multipart/mixed; boundary=#{BOUNDARY}"
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Delivery

Returns a new instance of Delivery.



10
11
12
# File 'lib/interfax/outbound/delivery.rb', line 10

def initialize client
  self.client = client
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



2
3
4
# File 'lib/interfax/outbound/delivery.rb', line 2

def client
  @client
end

#fax_numberObject

Returns the value of attribute fax_number.



2
3
4
# File 'lib/interfax/outbound/delivery.rb', line 2

def fax_number
  @fax_number
end

#filesObject

Returns the value of attribute files.



2
3
4
# File 'lib/interfax/outbound/delivery.rb', line 2

def files
  @files
end

#paramsObject

Returns the value of attribute params.



2
3
4
# File 'lib/interfax/outbound/delivery.rb', line 2

def params
  @params
end

Instance Method Details

#deliver(params) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/interfax/outbound/delivery.rb', line 14

def deliver params
  params, files = validate_params(params)

  file_objects = generate_file_objects(files)
  body = body_for(file_objects)

  result = client.post('/outbound/faxes', params, VALID_KEYS, HEADERS, body)
  InterFAX::Outbound::Fax.new(client: client, id: result.split('/').last)
end