plaid 0.0.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1e4372af14800f04a94b58aeea21befb1802b361
4
+ data.tar.gz: 029382c6b488f86d51946c84d4ac845aa4f6019e
5
+ SHA512:
6
+ metadata.gz: 5c3f2b55fa8fe633347d41897cef634e8b611214cd98b326df6b4c27d64b7ec75a89c64f4a711fdbceebf1f392eabf8ca4a02fabdc6e4d92f3023eb0e0763c50
7
+ data.tar.gz: 6bbdfa7719b2e90a891782c52d1ab72bb37228a825983343b7eda04a52e973e365ab22eff37b1c180473d1b607ddc99e78d58b1ae2fec3d64e999c6f676c649c
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
@@ -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,13 @@
1
+ module Plaidio
2
+ module Configure
3
+ attr_writer :customer_id, :secret
4
+
5
+ KEYS = [:customer_id, :secret]
6
+
7
+ def config
8
+ yield self
9
+ self
10
+ end
11
+
12
+ end
13
+ 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 CHANGED
@@ -1,75 +1,106 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: plaid
3
- version: !ruby/object:Gem::Version
4
- version: 0.0.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
5
  platform: ruby
6
- authors:
7
- - Kyle Maxwell
6
+ authors:
7
+ - Justin Crites
8
+ - Gamble McAdam
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
-
12
- date: 2009-10-22 00:00:00 -07:00
13
- default_executable:
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+ date: 2014-04-10 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
16
57
  name: rspec
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
17
63
  type: :development
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: 1.2.9
24
- version:
25
- description: plaid
26
- email: kyle@kylemaxwell.com
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 API.
71
+ email:
72
+ - justin@guavatext.com
73
+ - rahul@plaid.com
27
74
  executables: []
28
-
29
75
  extensions: []
30
-
31
- extra_rdoc_files:
32
- - LICENSE
33
- - README.rdoc
34
- files:
35
- - .document
36
- - .gitignore
37
- - LICENSE
38
- - README.rdoc
39
- - Rakefile
40
- - VERSION
41
- - lib/plaid.rb
42
- - spec/plaid_spec.rb
43
- - spec/spec.opts
44
- - spec/spec_helper.rb
45
- has_rdoc: true
46
- homepage: http://github.com/fizx/plaid
47
- licenses: []
48
-
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: {}
49
86
  post_install_message:
50
- rdoc_options:
51
- - --charset=UTF-8
52
- require_paths:
87
+ rdoc_options: []
88
+ require_paths:
53
89
  - lib
54
- required_ruby_version: !ruby/object:Gem::Requirement
55
- requirements:
56
- - - ">="
57
- - !ruby/object:Gem::Version
58
- version: "0"
59
- version:
60
- required_rubygems_version: !ruby/object:Gem::Requirement
61
- requirements:
62
- - - ">="
63
- - !ruby/object:Gem::Version
64
- version: "0"
65
- version:
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'
66
100
  requirements: []
67
-
68
101
  rubyforge_project:
69
- rubygems_version: 1.3.5
102
+ rubygems_version: 2.0.3
70
103
  signing_key:
71
- specification_version: 3
72
- summary: plaid
73
- test_files:
74
- - spec/plaid_spec.rb
75
- - spec/spec_helper.rb
104
+ specification_version: 4
105
+ summary: Plaid api gem
106
+ test_files: []
data/.document DELETED
@@ -1,5 +0,0 @@
1
- README.rdoc
2
- lib/**/*.rb
3
- bin/*
4
- features/**/*.feature
5
- LICENSE
data/.gitignore DELETED
@@ -1,21 +0,0 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## PROJECT::GENERAL
17
- coverage
18
- rdoc
19
- pkg
20
-
21
- ## PROJECT::SPECIFIC
data/LICENSE DELETED
@@ -1,20 +0,0 @@
1
- Copyright (c) 2009 Kyle Maxwell
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc DELETED
@@ -1,18 +0,0 @@
1
- = plaid
2
-
3
- Description goes here.
4
-
5
- == Note on Patches/Pull Requests
6
-
7
- * Fork the project.
8
- * Make your feature addition or bug fix.
9
- * Add tests for it. This is important so I don't break it in a
10
- future version unintentionally.
11
- * Commit, do not mess with rakefile, version, or history.
12
- (if you want to have your own version, that is fine but
13
- bump version in a commit by itself I can ignore when I pull)
14
- * Send me a pull request. Bonus points for topic branches.
15
-
16
- == Copyright
17
-
18
- Copyright (c) 2009 Kyle Maxwell. See LICENSE for details.
data/Rakefile DELETED
@@ -1,45 +0,0 @@
1
- require 'rubygems'
2
- require 'rake'
3
-
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "plaid"
8
- gem.summary = "plaid"
9
- gem.description = "plaid"
10
- gem.email = "kyle@kylemaxwell.com"
11
- gem.homepage = "http://github.com/fizx/plaid"
12
- gem.authors = ["Kyle Maxwell"]
13
- gem.add_development_dependency "rspec", ">= 1.2.9"
14
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
- end
16
- Jeweler::GemcutterTasks.new
17
- rescue LoadError
18
- puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
19
- end
20
-
21
- require 'spec/rake/spectask'
22
- Spec::Rake::SpecTask.new(:spec) do |spec|
23
- spec.libs << 'lib' << 'spec'
24
- spec.spec_files = FileList['spec/**/*_spec.rb']
25
- end
26
-
27
- Spec::Rake::SpecTask.new(:rcov) do |spec|
28
- spec.libs << 'lib' << 'spec'
29
- spec.pattern = 'spec/**/*_spec.rb'
30
- spec.rcov = true
31
- end
32
-
33
- task :spec => :check_dependencies
34
-
35
- task :default => :spec
36
-
37
- require 'rake/rdoctask'
38
- Rake::RDocTask.new do |rdoc|
39
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
40
-
41
- rdoc.rdoc_dir = 'rdoc'
42
- rdoc.title = "plaid #{version}"
43
- rdoc.rdoc_files.include('README*')
44
- rdoc.rdoc_files.include('lib/**/*.rb')
45
- end
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.0.0
data/lib/plaid.rb DELETED
File without changes
data/spec/plaid_spec.rb DELETED
@@ -1,7 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe "Plaid" do
4
- it "fails" do
5
- fail "hey buddy, you should probably rename this file and start specing for real"
6
- end
7
- end
data/spec/spec.opts DELETED
@@ -1 +0,0 @@
1
- --color
data/spec/spec_helper.rb DELETED
@@ -1,9 +0,0 @@
1
- $LOAD_PATH.unshift(File.dirname(__FILE__))
2
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
- require 'plaid'
4
- require 'spec'
5
- require 'spec/autorun'
6
-
7
- Spec::Runner.configure do |config|
8
-
9
- end