plaid-ruby 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/plaidio.rb +20 -0
- data/lib/plaidio/call.rb +78 -0
- data/lib/plaidio/config.rb +13 -0
- data/lib/plaidio/customer.rb +102 -0
- metadata +106 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 21b2b856cb7d96bd4f0393408f6a46f3dbeb11f0
|
4
|
+
data.tar.gz: b843b3f9ac26067ce369ab7313ad6062ab2ef9a9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 968c1b3d9466c606cf808adda05e9b59d7204547c3bed3e81914452054729c5842beeb625c7cb506e4c8e3b6e5bd03e511fcdd9cfadf7dbc71a9e93d834ab9d5
|
7
|
+
data.tar.gz: 5d8e1c55c5b1c5440828a53b1289bc0d9cab5d9de556f859b60df0650ae7ed9218d11d882ecb003aecb4481814ddd8fc7318be45f8c740cc55abb61a1ee808bc
|
data/lib/plaidio.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'plaidio/config'
|
2
|
+
require 'plaidio/call'
|
3
|
+
require 'plaidio/customer'
|
4
|
+
require 'rest_client'
|
5
|
+
module Plaidio
|
6
|
+
class << self
|
7
|
+
include Plaidio::Configure
|
8
|
+
|
9
|
+
# Defined when a user exists with a unique access_token. Ex: Plaidio.customer.get_transactions
|
10
|
+
def customer
|
11
|
+
@customer = Plaidio::Customer.new
|
12
|
+
end
|
13
|
+
|
14
|
+
# Defined for generic calls without access_tokens required. Ex: Plaidio.call.add_accounts(username,password,type)
|
15
|
+
def call
|
16
|
+
@call = Plaidio::Call.new
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
data/lib/plaidio/call.rb
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
module Plaidio
|
2
|
+
class Call
|
3
|
+
|
4
|
+
BASE_URL = 'https://tartan.plaid.com/'
|
5
|
+
|
6
|
+
# This initializes our instance variables, and sets up a new Customer class.
|
7
|
+
def initialize
|
8
|
+
Plaidio::Configure::KEYS.each do |key|
|
9
|
+
instance_variable_set(:"@#{key}", Plaidio.instance_variable_get(:"@#{key}"))
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def add_account(type,username,password,email)
|
14
|
+
post('/connect',type,username,password,email)
|
15
|
+
return parse_response(@response)
|
16
|
+
end
|
17
|
+
|
18
|
+
def get_place(id)
|
19
|
+
get('/entity',id)
|
20
|
+
return parse_place(@response)
|
21
|
+
end
|
22
|
+
protected
|
23
|
+
|
24
|
+
def parse_response(response)
|
25
|
+
case response.code
|
26
|
+
when 200
|
27
|
+
@parsed_response = Hash.new
|
28
|
+
@parsed_response[:code] = response.code
|
29
|
+
response = JSON.parse(response)
|
30
|
+
@parsed_response[:access_token] = response["access_token"]
|
31
|
+
@parsed_response[:accounts] = response["accounts"]
|
32
|
+
@parsed_response[:transactions] = response["transactions"]
|
33
|
+
return @parsed_response
|
34
|
+
when 201
|
35
|
+
@parsed_response = Hash.new
|
36
|
+
@parsed_response[:code] = response.code
|
37
|
+
response = JSON.parse(response)
|
38
|
+
@parsed_response = Hash.new
|
39
|
+
@parsed_response[:type] = response["type"]
|
40
|
+
@parsed_response[:access_token] = response["access_token"]
|
41
|
+
@parsed_response[:mfa_info] = response["mfa_info"]
|
42
|
+
return @parsed_response
|
43
|
+
else
|
44
|
+
@parsed_response = Hash.new
|
45
|
+
@parsed_response[:code] = response.code
|
46
|
+
@parsed_response[:message] = response
|
47
|
+
return @parsed_response
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def parse_place(response)
|
52
|
+
@parsed_response = Hash.new
|
53
|
+
@parsed_response[:code] = response.code
|
54
|
+
response = JSON.parse(response)["entity"]
|
55
|
+
@parsed_response[:category] = response["category"]
|
56
|
+
@parsed_response[:name] = response["name"]
|
57
|
+
@parsed_response[:id] = response["_id"]
|
58
|
+
@parsed_response[:phone] = response["meta"]["contact"]["telephone"]
|
59
|
+
@parsed_response[:location] = response["meta"]["location"]
|
60
|
+
return @parsed_response
|
61
|
+
end
|
62
|
+
|
63
|
+
private
|
64
|
+
|
65
|
+
def post(path,type,username,password,email)
|
66
|
+
url = BASE_URL + path
|
67
|
+
@response = RestClient.post url, client_id: self.instance_variable_get(:'@customer_id') ,secret: self.instance_variable_get(:'@secret'), type: type , credentials: {username: username, password: password} , email: email
|
68
|
+
return @response
|
69
|
+
end
|
70
|
+
|
71
|
+
def get(path,id)
|
72
|
+
url = BASE_URL + path
|
73
|
+
@response = RestClient.get(url, params: {entity_id: id})
|
74
|
+
return @response
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
module Plaidio
|
2
|
+
# This is used when a customer needs to be defined by the plaid access token.
|
3
|
+
# Abstracting as a class makes it easier since we wont have to redefine the access_token over and over.
|
4
|
+
class Customer
|
5
|
+
|
6
|
+
BASE_URL = 'https://tartan.plaid.com'
|
7
|
+
|
8
|
+
# This initializes our instance variables, and sets up a new Customer class.
|
9
|
+
def initialize
|
10
|
+
Plaidio::Configure::KEYS.each do |key|
|
11
|
+
instance_variable_set(:"@#{key}", Plaidio.instance_variable_get(:"@#{key}"))
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def mfa_step(access_token,code)
|
16
|
+
@mfa = code
|
17
|
+
post("/connect/step", access_token, mfa: @mfa)
|
18
|
+
return parse_response(@response,1)
|
19
|
+
end
|
20
|
+
|
21
|
+
def get_transactions(access_token)
|
22
|
+
get('/connect', access_token)
|
23
|
+
return parse_response(@response,2)
|
24
|
+
end
|
25
|
+
|
26
|
+
def delete_account(access_token)
|
27
|
+
delete('/connect', access_token)
|
28
|
+
return parse_response(@response,3)
|
29
|
+
end
|
30
|
+
|
31
|
+
protected
|
32
|
+
|
33
|
+
def parse_response(response,method)
|
34
|
+
case method
|
35
|
+
when 1
|
36
|
+
case response.code
|
37
|
+
when 200
|
38
|
+
@parsed_response = Hash.new
|
39
|
+
@parsed_response[:code] = response.code
|
40
|
+
response = JSON.parse(response)
|
41
|
+
@parsed_response[:access_token] = response["access_token"]
|
42
|
+
@parsed_response[:accounts] = response["accounts"]
|
43
|
+
@parsed_response[:transactions] = response["transactions"]
|
44
|
+
return @parsed_response
|
45
|
+
else
|
46
|
+
@parsed_response = Hash.new
|
47
|
+
@parsed_response[:code] = response.code
|
48
|
+
@parsed_response[:message] = response
|
49
|
+
return @parsed_response
|
50
|
+
end
|
51
|
+
when 2
|
52
|
+
case response.code
|
53
|
+
when 200
|
54
|
+
@parsed_response = Hash.new
|
55
|
+
@parsed_response[:code] = response.code
|
56
|
+
response = JSON.parse(response)
|
57
|
+
@parsed_response[:transactions] = response["transactions"]
|
58
|
+
return @parsed_response
|
59
|
+
else
|
60
|
+
@parsed_response = Hash.new
|
61
|
+
@parsed_response[:code] = response.code
|
62
|
+
@parsed_response[:message] = response
|
63
|
+
return @parsed_response
|
64
|
+
end
|
65
|
+
when 3
|
66
|
+
case response.code
|
67
|
+
when 200
|
68
|
+
@parsed_response = Hash.new
|
69
|
+
@parsed_response[:code] = response.code
|
70
|
+
response = JSON.parse(response)
|
71
|
+
@parsed_response[:message] = response
|
72
|
+
return @parsed_response
|
73
|
+
else
|
74
|
+
@parsed_response = Hash.new
|
75
|
+
@parsed_response[:code] = response.code
|
76
|
+
@parsed_response[:message] = response
|
77
|
+
return @parsed_response
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
private
|
83
|
+
|
84
|
+
def get(path,access_token,options={})
|
85
|
+
url = BASE_URL + path
|
86
|
+
@response = RestClient.get(url, params: {client_id: self.instance_variable_get(:'@customer_id'), secret: self.instance_variable_get(:'@secret'), access_token: access_token})
|
87
|
+
return @response
|
88
|
+
end
|
89
|
+
|
90
|
+
def post(path,access_token,options={})
|
91
|
+
url = BASE_URL + path
|
92
|
+
@response = RestClient.post url, client_id: self.instance_variable_get(:'@customer_id') , secret: self.instance_variable_get(:'@secret'), access_token: access_token, mfa: @mfa
|
93
|
+
return @response
|
94
|
+
end
|
95
|
+
|
96
|
+
def delete(path,access_token,options={})
|
97
|
+
url = BASE_URL + path
|
98
|
+
@response = RestClient.delete(url, params: {client_id: self.instance_variable_get(:'@customer_id'), secret: self.instance_variable_get(:'@secret'), access_token: access_token})
|
99
|
+
return @response
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: plaid-ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Justin Crites
|
8
|
+
- Gamble McAdam
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-02-19 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rest-client
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - '>='
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - '>='
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: json
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rake
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - '>='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rspec
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
description: A simple to use ruby wrapper for Plaid.io API.
|
71
|
+
email:
|
72
|
+
- justin@guavatext.com
|
73
|
+
- rahul@plaid.com
|
74
|
+
executables: []
|
75
|
+
extensions: []
|
76
|
+
extra_rdoc_files: []
|
77
|
+
files:
|
78
|
+
- lib/plaidio.rb
|
79
|
+
- lib/plaidio/config.rb
|
80
|
+
- lib/plaidio/call.rb
|
81
|
+
- lib/plaidio/customer.rb
|
82
|
+
homepage: https://github.com/j4ustin/plaidio
|
83
|
+
licenses:
|
84
|
+
- MIT
|
85
|
+
metadata: {}
|
86
|
+
post_install_message:
|
87
|
+
rdoc_options: []
|
88
|
+
require_paths:
|
89
|
+
- lib
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - '>='
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
requirements: []
|
101
|
+
rubyforge_project:
|
102
|
+
rubygems_version: 2.0.3
|
103
|
+
signing_key:
|
104
|
+
specification_version: 4
|
105
|
+
summary: Plaid.io api gem
|
106
|
+
test_files: []
|