lib/plaid/connection.rb in plaid-1.5.3 vs lib/plaid/connection.rb in plaid-1.6.0
- old
+ new
@@ -7,50 +7,57 @@
class << self
# API: semi-private
def post(path, options = {})
uri = build_uri(path)
options.merge!(client_id: Plaid.customer_id, secret: Plaid.secret)
- res = Net::HTTP.post_form(uri,options)
+ http = Net::HTTP.new(uri.host, uri.port)
+ http.use_ssl = true
+ request = Net::HTTP::Post.new(uri.path)
+ request.set_form_data(options)
+ res = http.request(request)
parse_response(res)
end
# API: semi-private
def get(path, id = nil)
uri = build_uri(path,id)
- res = Net::HTTP.get(uri)
- parse_get_response(res)
+ http = Net::HTTP.new(uri.host, uri.port)
+ http.use_ssl = true
+ request = Net::HTTP::Get.new(uri.path)
+ res = http.request(request)
+ parse_get_response(res.body)
end
# API: semi-private
def secure_get(path, access_token, options = {})
uri = build_uri(path)
options.merge!({access_token:access_token})
- req = Net::HTTP::Get.new(uri)
+ req = Net::HTTP::Get.new(uri.path)
req.body = URI.encode_www_form(options) if options
req.content_type = 'application/x-www-form-urlencoded'
- res = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => uri.scheme == 'https') { |http| http.request(req) }
+ res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(req) }
parse_response(res)
end
# API: semi-private
def patch(path, options = {})
uri = build_uri(path)
options.merge!(client_id: Plaid.customer_id, secret: Plaid.secret)
- req = Net::HTTP::Patch.new(uri)
+ req = Net::HTTP::Patch.new(uri.path)
req.body = URI.encode_www_form(options) if options
req.content_type = 'application/x-www-form-urlencoded'
- res = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => uri.scheme == 'https') { |http| http.request(req) }
+ res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(req) }
parse_response(res)
end
# API: semi-private
def delete(path, options = {})
uri = build_uri(path)
options.merge!(client_id: Plaid.customer_id, secret: Plaid.secret)
- req = Net::HTTP::Delete.new(uri)
+ req = Net::HTTP::Delete.new(uri.path)
req.body = URI.encode_www_form(options) if options
req.content_type = 'application/x-www-form-urlencoded'
- Net::HTTP.start(uri.hostname, uri.port, :use_ssl => uri.scheme == 'https') { |http| http.request(req) }
+ Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(req) }
end
protected
# API: semi-private