Class: OldPlaid::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/old_plaid/connection.rb

Class Method Summary collapse

Class Method Details

.delete(path, options = {}) ⇒ Object

API: semi-private



53
54
55
56
57
58
59
60
# File 'lib/old_plaid/connection.rb', line 53

def delete(path, options = {})
  uri = build_uri(path)
  options.merge!(client_id: OldPlaid.customer_id, secret: OldPlaid.secret)
  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: true) { |http| http.request(req) }
end

.get(path, id = nil) ⇒ Object

API: semi-private



21
22
23
24
25
26
27
28
# File 'lib/old_plaid/connection.rb', line 21

def get(path, id = nil)
  uri = build_uri(path,id)
  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

.patch(path, options = {}) ⇒ Object

API: semi-private



42
43
44
45
46
47
48
49
50
# File 'lib/old_plaid/connection.rb', line 42

def patch(path, options = {})
  uri = build_uri(path)
  options.merge!(client_id: OldPlaid.customer_id, secret: OldPlaid.secret)
  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: true) { |http| http.request(req) }
  parse_response(res)
end

.post(path, options = {}) ⇒ Object

API: semi-private



9
10
11
12
13
14
15
16
17
18
# File 'lib/old_plaid/connection.rb', line 9

def post(path, options = {})
  uri = build_uri(path)
  options.merge!(client_id: OldPlaid.customer_id, secret: OldPlaid.secret)
  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

.secure_get(path, access_token, options = {}) ⇒ Object

API: semi-private



31
32
33
34
35
36
37
38
39
# File 'lib/old_plaid/connection.rb', line 31

def secure_get(path, access_token, options = {})
  uri = build_uri(path)
  options.merge!({access_token:access_token, client_id: OldPlaid.customer_id, secret: OldPlaid.secret})
  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: true) { |http| http.request(req) }
  parse_response(res)
end