watson-ruby
watson-ruby copied to clipboard
Add :data_format to use set_form_data vs json body? [lib/watson/remote.rb]
filename : lib/watson/remote.rb line # : 88 tag : review md5 : 88fbf45c55d9c0d76128faaf1de92dc8
# [review] - Add :data_format to use set_form_data vs json body?
# For now, use Hash or Array, this is to differentiate between
# putting post data in body vs putting it in the form
# If a POST method, :data is present, and is a Hash, fill request body with data
if opts[:method].upcase == "POST" && opts[:data] && opts[:data].is_a?(Hash)
_req.body = opts[:data].to_json
end
# If a POST method, :data is present, and is an Array, use set_form_data
if opts[:method].upcase == "POST" && opts[:data] && opts[:data].is_a?(Array)
_req.set_form_data(opts[:data][0])
end
# Make HTTP request
_resp = _http.request(_req)