capital_one 0.1.0

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: aa8bdefb2ec0e1cbb42ae29b7c16a9a0e5797267
4
+ data.tar.gz: 352fe4394dd839a985f051b4ccbd351c8e7129ae
5
+ SHA512:
6
+ metadata.gz: 1500cda5cd763356625a5c8f0090b0cefa7be14a9053bb67715c33ee84f8aa58aaef5022d998f31fbb72c37222e6a7306aec5f72fc8ba548a6b6289f657de989
7
+ data.tar.gz: 681c0156b3d3bcc8e8e5e1d73fc4e02244a4ecef426195a1f20294ab0c33eb46c764dfa6a0f10261ad1179d1e27993e2f7baed35d449b90213c99b22eb1f3aa8
@@ -0,0 +1,88 @@
1
+ class Account
2
+
3
+ def self.urlWithEntity
4
+ return Config.baseUrl + "/accounts"
5
+ end
6
+
7
+ def self.url
8
+ return Config.baseUrl
9
+ end
10
+
11
+ def self.apiKey
12
+ return Config.apiKey
13
+ end
14
+
15
+ # *** GET ***
16
+
17
+ def self.getAll
18
+ url = "#{self.urlWithEntity}?&key=#{self.apiKey}"
19
+ resp = Net::HTTP.get_response(URI.parse(url))
20
+ data = JSON.parse(resp.body)
21
+ end
22
+
23
+ #Gets all accounts of a given type.
24
+ #Possible arguments are: Savings, Credit Card, or Checking.
25
+ #tested, credit card doesn't work, returns array of hashes.
26
+ def self.getAllByType(type)
27
+ url = "#{self.urlWithEntity}?type=#{type}&key=#{self.apiKey}"
28
+ resp = Net::HTTP.get_response(URI.parse(url))
29
+ data = JSON.parse(resp.body)
30
+ end
31
+ #Returns the account specified by it's account ID.
32
+ #tested - returns a hash with the account info.
33
+ def self.getOne(id)
34
+ url = "#{self.urlWithEntity}/#{id}?key=#{self.apiKey}"
35
+ resp = Net::HTTP.get_response(URI.parse(url))
36
+ data = JSON.parse(resp.body)
37
+ end
38
+ #Gets all accounts associated with a given customer ID.
39
+ #tested - returns an array of hashes.
40
+ def self.getAllByCustomerId(customerId)
41
+ url = "#{self.url}/customers/#{customerId}/accounts?key=#{self.apiKey}"
42
+ resp = Net::HTTP.get_response(URI.parse(url))
43
+ data = JSON.parse(resp.body)
44
+ end
45
+
46
+
47
+ # *** PUT ***
48
+
49
+ #updates an account's nickname by id with given json data.
50
+ def self.updateAccount(accountId, account)
51
+ url = "#{self.urlWithEntity}/#{accountId}?key=#{self.apiKey}"
52
+ uri = URI.parse(url)
53
+ http = Net::HTTP.new(uri.host, uri.port)
54
+ key = "?key=#{self.apiKey}"
55
+ request = Net::HTTP::Put.new(uri.path+key)
56
+ request.set_form_data(account)
57
+ response = http.request(request)
58
+ return JSON.parse(response.body)
59
+ end
60
+
61
+
62
+ # *** POST ***
63
+
64
+ #creates a new account
65
+ def self.createAccount(custID, account)
66
+ accountToCreate = account.to_json
67
+ url = "#{self.url}/customers/#{custID}/accounts?key=#{self.apiKey}"
68
+ uri = URI.parse(url)
69
+ http = Net::HTTP.new(uri.host, uri.port)
70
+ request = Net::HTTP::Post.new(uri.request_uri, initheader = {'Content-Type' =>'application/json'})
71
+ request.body = accountToCreate
72
+ response = http.request(request)
73
+ return JSON.parse(response.body)
74
+ end
75
+
76
+
77
+ # *** DELETE ***
78
+
79
+ #delete a given account with some ID
80
+ def self.deleteAccount(accountId)
81
+ url = "#{self.urlWithEntity}/#{accountId}?key=#{self.apiKey}"
82
+ uri = URI.parse(url)
83
+ http = Net::HTTP.new(uri.host, uri.port)
84
+ key="?key=#{self.apiKey}"
85
+ request = Net::HTTP::Delete.new(uri.path+key)
86
+ response = http.request(request)
87
+ end
88
+ end
@@ -0,0 +1,28 @@
1
+ class Atm
2
+
3
+ def self.urlWithEntity
4
+ return Config.baseUrl + "/atms"
5
+ end
6
+
7
+ def self.url
8
+ return Config.baseUrl
9
+ end
10
+
11
+ def self.apiKey
12
+ return Config.apiKey
13
+ end
14
+
15
+ # *** GET ***
16
+ def self.getAll
17
+ url = "#{self.urlWithEntity}?key=#{self.apiKey}"
18
+ resp = Net::HTTP.get_response(URI.parse(url))
19
+ data = JSON.parse(resp.body)
20
+ end
21
+
22
+ def self.getOne(id)
23
+ url = "#{self.urlWithEntity}/#{id}?key=#{self.apiKey}"
24
+ resp = Net::HTTP.get_response(URI.parse(url))
25
+ data = JSON.parse(resp.body)
26
+ end
27
+ end
28
+
@@ -0,0 +1,89 @@
1
+ class Bill
2
+
3
+ def self.accountBaseUrl
4
+ return Config.baseUrl + "/accounts"
5
+ end
6
+
7
+ def self.customerBaseUrl
8
+ return Config.baseUrl + "/customers"
9
+ end
10
+
11
+ def self.url
12
+ return Config.baseUrl
13
+ end
14
+
15
+ def self.apiKey
16
+ return Config.apiKey
17
+ end
18
+
19
+ # *** GET ***
20
+
21
+ #tested -returns array of hashes
22
+ # Get all bills for a specific customer
23
+ def self.getAllByCustomerId(customerId)
24
+ url = "#{self.customerBaseUrl}/#{customerId}/bills?key=#{self.apiKey}"
25
+ response = Net::HTTP.get_response(URI.parse(url))
26
+ return JSON.parse(response.body)
27
+ end
28
+ #tested - returns array of hashes
29
+ # Get a specific bill
30
+ def self.getOneByCustomerIdBillId(customerId, billId)
31
+ url = "#{self.customerBaseUrl}/#{customerId}/bills/#{billId}?key=#{self.apiKey}"
32
+ resp = Net::HTTP.get_response(URI.parse(url))
33
+ data = JSON.parse(resp.body)
34
+ end
35
+ #tested - returns an array of hashes with the bills for that account in it.
36
+ #Get all bills for a specific account
37
+ def self.getAllByAccountId(accountId)
38
+ url = "#{self.accountBaseUrl}/#{accountId}/bills?key=#{self.apiKey}"
39
+ response = Net::HTTP.get_response(URI.parse(url))
40
+ return JSON.parse(response.body)
41
+ end
42
+
43
+ #get a specific bill from a specific account
44
+ def self.getOneByAccountIdBillId(accountId, billId)
45
+ url ="#{self.accountBaseUrl}/#{accountId}/bills/#{billId}?key=#{self.apiKey}"
46
+ response = Net::HTTP.get_response(URI.parse(url))
47
+ return JSON.parse(response.body)
48
+ end
49
+
50
+ # *** POST ***
51
+
52
+ #updates an account's nickname by id with given json data.
53
+ def self.updateBill(accountId, billId, bill)
54
+ url = "#{self.accountBaseUrl}/#{accountId}/bills/#{billId}?key=#{self.apiKey}"
55
+ uri = URI.parse(url)
56
+ http = Net::HTTP.new(uri.host, uri.port)
57
+ key = "?key=#{self.apiKey}"
58
+ request = Net::HTTP::Put.new(uri.path+key)
59
+ request.set_form_data(bill)
60
+ response = http.request(request)
61
+ return JSON.parse(response.body)
62
+ end
63
+
64
+ # *** POST ***
65
+
66
+ #create a new bill on an associated account ID
67
+ def self.createBill(accountId, bill)
68
+ url = "#{self.accountBaseUrl}/#{accountId}/bills?key=#{self.apiKey}"
69
+ uri = URI.parse(url)
70
+ http = Net::HTTP.new(uri.host, uri.port)
71
+ request = Net::HTTP::Post.new(uri.request_uri, initheader = {'Content-Type' => 'application/json'})
72
+ request.body = bill.to_json
73
+ response = http.request(request)
74
+ return JSON.parse(response.body)
75
+ end
76
+
77
+
78
+ # *** DELETE ***
79
+
80
+ #delete a bill by id from a given account
81
+ def self.deleteBill(accountId, billId)
82
+ url = "#{self.accountBaseUrl}/#{accountId}/bills/#{billId}?key=#{self.apiKey}"
83
+ uri = URI.parse(url)
84
+ http = Net::HTTP.new(uri.host, uri.port)
85
+ key="?key=#{self.apiKey}"
86
+ request = Net::HTTP::Delete.new(uri.path+key)
87
+ response = http.request(request)
88
+ end
89
+ end
@@ -0,0 +1,34 @@
1
+ class Branch
2
+
3
+ def self.url
4
+ return Config.baseUrl
5
+ end
6
+
7
+ def self.urlWithEntity
8
+ return Config.baseUrl + "/branches"
9
+ end
10
+
11
+ def self.apiKey
12
+ return Config.apiKey
13
+ end
14
+
15
+ # *** GET ***
16
+
17
+ # Get all the branches
18
+ #tested - returns an array of hashes. Each hash is a branch.
19
+ def self.getAll
20
+ url = "#{self.urlWithEntity}?key=#{self.apiKey}"
21
+ resp = Net::HTTP.get_response(URI.parse(url))
22
+ data = JSON.parse(resp.body)
23
+
24
+ end
25
+
26
+ # Get a branch by it's id
27
+ #tested - returns a hash with the specified branch.
28
+ def self.getOne(id)
29
+ url = "#{self.urlWithEntity}/#{id}?key=#{self.apiKey}"
30
+ resp = Net::HTTP.get_response(URI.parse(url))
31
+ data = JSON.parse(resp.body)
32
+
33
+ end
34
+ end
@@ -0,0 +1,61 @@
1
+ class Customer
2
+
3
+ def self.urlWithEntity
4
+ return Config.baseUrl + "/customers"
5
+ end
6
+
7
+ def self.urlWithAcctEntity
8
+ return Config.baseUrl + "/accounts"
9
+ end
10
+
11
+ def self.url
12
+ return Config.baseUrl
13
+ end
14
+
15
+ def self.apiKey
16
+ return Config.apiKey
17
+ end
18
+
19
+ # *** GET ***
20
+
21
+ #Returns all customers that the API key used has access to.
22
+ #tested - Returns an array of hashes.
23
+ def self.getAll
24
+ url = "#{self.urlWithEntity}?key=#{self.apiKey}"
25
+ resp = Net::HTTP.get_response(URI.parse(url))
26
+ data = JSON.parse(resp.body)
27
+ return data
28
+ end
29
+ #Gets the specified customer's information.
30
+ #tested - Returns a hash.
31
+ def self.getOne(custId)
32
+ url = "#{self.urlWithEntity}/#{custId}?key=#{self.apiKey}"
33
+ resp = Net::HTTP.get_response(URI.parse(url))
34
+ data = JSON.parse(resp.body)
35
+ end
36
+
37
+ #Get the customer for the given account.
38
+ #tested - Returns a hash with the specified customer data.
39
+ def self.getOneByAccountId(accID)
40
+ url = "#{self.urlWithAcctEntity}/#{accID}/customer?key=#{self.apiKey}"
41
+ resp = Net::HTTP.get_response(URI.parse(url))
42
+ data = JSON.parse(resp.body)
43
+ end
44
+
45
+
46
+ # *** PUT ***
47
+
48
+ def self.updateCustomer(custID, customer)
49
+ url = "#{self.urlWithEntity}/#{custID}?key=#{self.apiKey}"
50
+ uri = URI.parse(url)
51
+ http = Net::HTTP.new(uri.host, uri.port)
52
+ key = "?key=#{self.apiKey}"
53
+ request = Net::HTTP::Put.new(uri.path+key)
54
+ request.set_form_data(customer)
55
+ response = http.request(request)
56
+ return JSON.parse(response.body)
57
+ end
58
+
59
+ #
60
+
61
+ end
@@ -0,0 +1,61 @@
1
+ class Transaction
2
+
3
+ def self.urlWithEntity
4
+ return Config.baseUrl + "/accounts"
5
+ end
6
+
7
+ def self.url
8
+ return Config.baseUrl
9
+ end
10
+
11
+ def self.apiKey
12
+ return Config.apiKey
13
+ end
14
+
15
+
16
+ # *** GET ***
17
+
18
+ # Get all transactions for a specific account
19
+ #tested - Returns an array of hashes.
20
+ def self.getAllByAccountId(accID)
21
+ url = "#{self.urlWithEntity}/#{accID}/transactions?key=#{self.apiKey}"
22
+ resp = Net::HTTP.get_response(URI.parse(url))
23
+ data = JSON.parse(resp.body)
24
+ return data
25
+ end
26
+
27
+ # Get a specific transaction
28
+ # tested - Returns a hash with the specified transaction
29
+ def self.getOneByAccountIdTransactionId(accID, tranID)
30
+ url = "#{self.urlWithEntity}/#{accID}/transactions/#{tranID}?key=#{self.apiKey}"
31
+ resp = Net::HTTP.get_response(URI.parse(url))
32
+ data = JSON.parse(resp.body)
33
+ end
34
+
35
+
36
+ # *** POST ***
37
+
38
+ # Create a new transaction between 2 accounts
39
+ def self.createTransaction(toAcc, json)
40
+ url = "#{self.urlWithEntity}/#{toAcc}/transactions?key=#{self.apiKey}"
41
+ uri = URI.parse(url)
42
+ http = Net::HTTP.new(uri.host, uri.port)
43
+ request = Net::HTTP::Post.new(uri.request_uri, initheader = {'Content-Type' => 'application/json'})
44
+ request.body = json
45
+ resp = http.request(request)
46
+ data = JSON.parse(resp.body)
47
+ end
48
+
49
+
50
+ # *** DELETE ***
51
+
52
+ def self.deleteTransaction(accID, transID)
53
+ url = "#{self.urlWithEntity}/#{accID}/transactions/#{transID}?key=#{self.apiKey}"
54
+ uri = URI.parse(url)
55
+ http = Net::HTTP.new(uri.host, uri.port)
56
+ key="?key=#{self.apiKey}"
57
+ request = Net::HTTP::Delete.new(uri.path+key)
58
+ resp = http.request(request)
59
+ #data = JSON.parse(resp.body)
60
+ end
61
+ end
@@ -0,0 +1,3 @@
1
+ module CapitalOne
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,37 @@
1
+ =begin
2
+
3
+ This is a gem to wrap the Capital One public API.
4
+ Visit api.reimaginebanking.com for more details.
5
+
6
+ =end
7
+
8
+ module Config
9
+ class << self
10
+ attr_accessor :apiKey
11
+
12
+ def baseUrl
13
+ @baseUrl = 'http://api.reimaginebanking.com:80'
14
+ end
15
+ end
16
+ end
17
+
18
+ require 'net/http'
19
+ require 'json'
20
+ require 'uri'
21
+
22
+ require 'capital_one/account'
23
+ require 'capital_one/atm'
24
+ require 'capital_one/bill'
25
+ require 'capital_one/branch'
26
+ require 'capital_one/customer'
27
+ require 'capital_one/transaction'
28
+
29
+ =begin
30
+
31
+ Depending on the access level/type of API key supplied, some of
32
+ these methods will return 403 error codes(forbidden). Enterprise level
33
+ API keys have access to any/all of the GET requests, but nothing else.
34
+ Customer level API keys have access to GET, POST, PUT, and DELETE, but only
35
+ for valid accounts which are associated with the customer API key.
36
+
37
+ =end
metadata ADDED
@@ -0,0 +1,154 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capital_one
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Shane Besong
8
+ - Tom Pazamickas
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2015-04-10 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ~>
19
+ - !ruby/object:Gem::Version
20
+ version: '1.9'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ version: '1.9'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ~>
33
+ - !ruby/object:Gem::Version
34
+ version: '10.0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ~>
40
+ - !ruby/object:Gem::Version
41
+ version: '10.0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: json
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: '3.0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - '>'
68
+ - !ruby/object:Gem::Version
69
+ version: '3.0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: simplecov
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: webmock
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - '>='
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ - !ruby/object:Gem::Dependency
99
+ name: vcr
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - '>='
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ description: Simply require 'capital_one' to work with the API
113
+ email:
114
+ - sfbesong@gmail.com
115
+ - tpazamickas@gmail.com
116
+ executables: []
117
+ extensions: []
118
+ extra_rdoc_files: []
119
+ files:
120
+ - lib/capital_one.rb
121
+ - lib/capital_one/account.rb
122
+ - lib/capital_one/atm.rb
123
+ - lib/capital_one/bill.rb
124
+ - lib/capital_one/branch.rb
125
+ - lib/capital_one/customer.rb
126
+ - lib/capital_one/transaction.rb
127
+ - lib/capital_one/version.rb
128
+ homepage: https://github.com/Shwheelz/capital_one
129
+ licenses:
130
+ - MIT
131
+ metadata:
132
+ allowed_push_host: 'TODO: Set to ''http://mygemserver.com'' to prevent pushes to
133
+ rubygems.org, or delete to allow pushes to any server.'
134
+ post_install_message:
135
+ rdoc_options: []
136
+ require_paths:
137
+ - lib
138
+ required_ruby_version: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - '>='
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ required_rubygems_version: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - '>='
146
+ - !ruby/object:Gem::Version
147
+ version: '0'
148
+ requirements: []
149
+ rubyforge_project:
150
+ rubygems_version: 2.0.14
151
+ signing_key:
152
+ specification_version: 4
153
+ summary: Connects to the Capital One API
154
+ test_files: []