Class: Bambora::Adapters::MultipartMixedRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/bambora/adapters/multipart_mixed_request.rb

Overview

Creates headers and a body for a multipart/mixed request with a file and a JSON body.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ MultipartMixedRequest

Returns a new instance of MultipartMixedRequest.



10
11
12
# File 'lib/bambora/adapters/multipart_mixed_request.rb', line 10

def initialize(options = {})
  @multiparty = Multiparty.new { |party| party.parts = options[:multipart_args] }
end

Instance Attribute Details

#multipartyObject (readonly)

Returns the value of attribute multiparty.



8
9
10
# File 'lib/bambora/adapters/multipart_mixed_request.rb', line 8

def multiparty
  @multiparty
end

Instance Method Details

#bodyObject



18
19
20
# File 'lib/bambora/adapters/multipart_mixed_request.rb', line 18

def body
  "#{multiparty.body}\r\n"
end

#content_typeObject



14
15
16
# File 'lib/bambora/adapters/multipart_mixed_request.rb', line 14

def content_type
  multiparty.header.sub(/^Content-Type: /, '').strip
end