class Medidata::API::MultipartPost
Constants
- EOL
Public Class Methods
new()
click to toggle source
# File lib/medidata/api/http.rb, line 318 def initialize @params = Array.new end
Public Instance Methods
build(bounday)
click to toggle source
# File lib/medidata/api/http.rb, line 334 def build(bounday) body = @params.map{|p| "--#{bounday}#{EOL}" << p}.join "" body << "#{EOL}--#{bounday}--#{EOL}" end
with_binary(key:, value:)
click to toggle source
# File lib/medidata/api/http.rb, line 326 def with_binary(key:, value:) @params << multipart_binary(key, value) end
with_file(key:, value:, filename:, mime_type:)
click to toggle source
# File lib/medidata/api/http.rb, line 330 def with_file(key:, value:, filename:, mime_type:) @params << multipart_file(key, value, filename, mime_type) end
with_text(key:, value:)
click to toggle source
# File lib/medidata/api/http.rb, line 322 def with_text(key:, value:) @params << multipart_text(key, value) end
Private Instance Methods
multipart_binary(key, value)
click to toggle source
# File lib/medidata/api/http.rb, line 355 def multipart_binary(key, value) "Content-Disposition: form-data; name=\"#{key}\"#{EOL}" << "Content-Transfer-Encoding: binary#{EOL}" << "Content-Type: application/octet-stream#{EOL}" << EOL << "#{value}" << EOL end
multipart_file(key, value, filename, mime_type)
click to toggle source
# File lib/medidata/api/http.rb, line 348 def multipart_file(key, value, filename, mime_type) "Content-Disposition: form-data; name=\"#{key}\"; filename=\"#{filename}\"#{EOL}" << "Content-Type: #{mime_type}#{EOL}" << EOL << "#{value}" << EOL end
multipart_text(key, value)
click to toggle source
# File lib/medidata/api/http.rb, line 341 def multipart_text(key, value) "Content-Disposition: form-data; name=\"#{key}\"" << EOL << EOL << "#{value}" << EOL end