capital_one 0.4.1 → 0.4.3
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 +4 -4
- data/lib/capital_one.rb +57 -57
- data/lib/capital_one/account.rb +116 -116
- data/lib/capital_one/atm.rb +73 -49
- data/lib/capital_one/bill.rb +124 -123
- data/lib/capital_one/branch.rb +36 -36
- data/lib/capital_one/customer.rb +112 -112
- data/lib/capital_one/deposit.rb +109 -109
- data/lib/capital_one/merchant.rb +117 -117
- data/lib/capital_one/purchase.rb +106 -106
- data/lib/capital_one/transfer.rb +92 -92
- data/lib/capital_one/version.rb +3 -3
- data/lib/capital_one/withdrawal.rb +107 -107
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79386ee43f71bc66ddc6118b14528281dd7c360e
|
4
|
+
data.tar.gz: b6c3ccba8d425dd184f318d8f6607640e7489f76
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b974823364bc825d07363091c26861fdf74ae03ac07912b96e566a7232d521e145f85a7635d3810e2e623fe0c095e84c45f49f661000871a144ac220868bd45
|
7
|
+
data.tar.gz: 46b5436b17ec21d48a4a698d99cef85426459010feac6a03434b83c9566090aeeb27e9e72aeec0efb26bde45c5c0fc94140f3ad5c22b4049c51891cd38ddeb03
|
data/lib/capital_one.rb
CHANGED
@@ -1,58 +1,58 @@
|
|
1
|
-
=begin
|
2
|
-
|
3
|
-
==Capital One API Gem
|
4
|
-
|
5
|
-
This is a gem to wrap the Capital One public API.
|
6
|
-
Visit api.reimaginebanking.com for more details.
|
7
|
-
|
8
|
-
=end
|
9
|
-
|
10
|
-
module Config
|
11
|
-
class << self
|
12
|
-
attr_accessor :apiKey
|
13
|
-
|
14
|
-
def baseUrl
|
15
|
-
@baseUrl = 'http://api.reimaginebanking.com:80'
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
require 'net/http'
|
21
|
-
require 'json'
|
22
|
-
require 'uri'
|
23
|
-
|
24
|
-
require 'capital_one/account'
|
25
|
-
require 'capital_one/atm'
|
26
|
-
require 'capital_one/bill'
|
27
|
-
require 'capital_one/branch'
|
28
|
-
require 'capital_one/customer'
|
29
|
-
require 'capital_one/deposit'
|
30
|
-
require 'capital_one/merchant'
|
31
|
-
require 'capital_one/purchase'
|
32
|
-
require 'capital_one/transfer'
|
33
|
-
require 'capital_one/withdrawal'
|
34
|
-
|
35
|
-
|
36
|
-
=begin
|
37
|
-
|
38
|
-
==Important Info
|
39
|
-
|
40
|
-
Depending on the access level/type of API key supplied, some of
|
41
|
-
these methods will return 403 error codes(forbidden). Enterprise level
|
42
|
-
API keys have access to any/all of the GET requests, but nothing else.
|
43
|
-
Customer level API keys have access to GET, POST, PUT, and DELETE, but only
|
44
|
-
for valid accounts which are associated with the customer API key.
|
45
|
-
|
46
|
-
Additionally, some of the GET requests will change in functionality depending on the
|
47
|
-
type of key used. For example, the getAll method in the Customer class returns all customers if
|
48
|
-
the enterprise API key is used. If the customer API key is used, it will only return the customers that
|
49
|
-
the key is associated with.
|
50
|
-
|
51
|
-
For the purposes of this gem, any ID parameters Strings that are 24 hex characters long. Below is an example:
|
52
|
-
5326c07ba520d1066c9ac52b
|
53
|
-
|
54
|
-
You can see the API that this gem wraps at api.reimaginebanking.com
|
55
|
-
|
56
|
-
|
57
|
-
|
1
|
+
=begin
|
2
|
+
|
3
|
+
==Capital One API Gem
|
4
|
+
|
5
|
+
This is a gem to wrap the Capital One public API.
|
6
|
+
Visit api.reimaginebanking.com for more details.
|
7
|
+
|
8
|
+
=end
|
9
|
+
|
10
|
+
module Config
|
11
|
+
class << self
|
12
|
+
attr_accessor :apiKey
|
13
|
+
|
14
|
+
def baseUrl
|
15
|
+
@baseUrl = 'http://api.reimaginebanking.com:80'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
require 'net/http'
|
21
|
+
require 'json'
|
22
|
+
require 'uri'
|
23
|
+
|
24
|
+
require 'capital_one/account'
|
25
|
+
require 'capital_one/atm'
|
26
|
+
require 'capital_one/bill'
|
27
|
+
require 'capital_one/branch'
|
28
|
+
require 'capital_one/customer'
|
29
|
+
require 'capital_one/deposit'
|
30
|
+
require 'capital_one/merchant'
|
31
|
+
require 'capital_one/purchase'
|
32
|
+
require 'capital_one/transfer'
|
33
|
+
require 'capital_one/withdrawal'
|
34
|
+
|
35
|
+
|
36
|
+
=begin
|
37
|
+
|
38
|
+
==Important Info
|
39
|
+
|
40
|
+
Depending on the access level/type of API key supplied, some of
|
41
|
+
these methods will return 403 error codes(forbidden). Enterprise level
|
42
|
+
API keys have access to any/all of the GET requests, but nothing else.
|
43
|
+
Customer level API keys have access to GET, POST, PUT, and DELETE, but only
|
44
|
+
for valid accounts which are associated with the customer API key.
|
45
|
+
|
46
|
+
Additionally, some of the GET requests will change in functionality depending on the
|
47
|
+
type of key used. For example, the getAll method in the Customer class returns all customers if
|
48
|
+
the enterprise API key is used. If the customer API key is used, it will only return the customers that
|
49
|
+
the key is associated with.
|
50
|
+
|
51
|
+
For the purposes of this gem, any ID parameters Strings that are 24 hex characters long. Below is an example:
|
52
|
+
5326c07ba520d1066c9ac52b
|
53
|
+
|
54
|
+
You can see the API that this gem wraps at api.reimaginebanking.com
|
55
|
+
|
56
|
+
|
57
|
+
|
58
58
|
=end
|
data/lib/capital_one/account.rb
CHANGED
@@ -1,116 +1,116 @@
|
|
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
|
-
#= getAll
|
17
|
-
# Returns an array of hashes getting all the customers.
|
18
|
-
# Each index in the array is the hash of an individual customer.
|
19
|
-
|
20
|
-
def self.getAll
|
21
|
-
url = "#{self.urlWithEntity}?&key=#{self.apiKey}"
|
22
|
-
resp = Net::HTTP.get_response(URI.parse(url))
|
23
|
-
data = JSON.parse(resp.body)
|
24
|
-
end
|
25
|
-
|
26
|
-
#== getAllByType
|
27
|
-
# Gets all accounts of a given type.
|
28
|
-
#= Parameters: type
|
29
|
-
# Accepts a string of the account type. 3 possbilities: Credit Card, Savings, Checking.
|
30
|
-
# Returns an array of hashes with the accounts.
|
31
|
-
|
32
|
-
def self.getAllByType(type)
|
33
|
-
url = "#{self.urlWithEntity}?type=#{type}&key=#{self.apiKey}"
|
34
|
-
resp = Net::HTTP.get_response(URI.parse(url))
|
35
|
-
data = JSON.parse(resp.body)
|
36
|
-
end
|
37
|
-
|
38
|
-
|
39
|
-
#== getOne
|
40
|
-
# Returns the account specified by its account ID.
|
41
|
-
#= Parameters: AccountId
|
42
|
-
# Accepts a string of the account ID.
|
43
|
-
# Returns a hash with the account info.
|
44
|
-
def self.getOne(id)
|
45
|
-
url = "#{self.urlWithEntity}/#{id}?key=#{self.apiKey}"
|
46
|
-
resp = Net::HTTP.get_response(URI.parse(url))
|
47
|
-
data = JSON.parse(resp.body)
|
48
|
-
end
|
49
|
-
|
50
|
-
#== getAllByCustomerId
|
51
|
-
# Returns all accounts associated with a given customer ID as an array of hashes.
|
52
|
-
#= Parameters: CustomerId
|
53
|
-
# Accepts a string of the customer ID
|
54
|
-
|
55
|
-
def self.getAllByCustomerId(customerId)
|
56
|
-
url = "#{self.url}/customers/#{customerId}/accounts?key=#{self.apiKey}"
|
57
|
-
resp = Net::HTTP.get_response(URI.parse(url))
|
58
|
-
data = JSON.parse(resp.body)
|
59
|
-
end
|
60
|
-
|
61
|
-
|
62
|
-
# *** PUT ***
|
63
|
-
|
64
|
-
#==updateAccount
|
65
|
-
# Updates an account's nickname.
|
66
|
-
#= Parameters: AccountID, AccountHash
|
67
|
-
# Returns the http response code.
|
68
|
-
|
69
|
-
def self.updateAccount(accountId, account)
|
70
|
-
accountToUpdate = account.to_json
|
71
|
-
url = "#{self.urlWithEntity}/#{accountId}?key=#{self.apiKey}"
|
72
|
-
uri = URI.parse(url)
|
73
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
74
|
-
key = "?key=#{self.apiKey}"
|
75
|
-
request = Net::HTTP::Put.new(uri.path+key, initheader = {'Content-Type' =>'application/json'})
|
76
|
-
request.body = accountToUpdate
|
77
|
-
response = http.request(request)
|
78
|
-
return JSON.parse(response.body)
|
79
|
-
end
|
80
|
-
|
81
|
-
|
82
|
-
# *** POST ***
|
83
|
-
|
84
|
-
#== createAccount
|
85
|
-
# Creates a new account
|
86
|
-
# Parameters: CustomerID, accountHash
|
87
|
-
# Returns the http response code.
|
88
|
-
|
89
|
-
def self.createAccount(custID, account)
|
90
|
-
accountToCreate = account.to_json
|
91
|
-
url = "#{self.url}/customers/#{custID}/accounts?key=#{self.apiKey}"
|
92
|
-
uri = URI.parse(url)
|
93
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
94
|
-
request = Net::HTTP::Post.new(uri.request_uri, initheader = {'Content-Type' =>'application/json'})
|
95
|
-
request.body = accountToCreate
|
96
|
-
response = http.request(request)
|
97
|
-
return JSON.parse(response.body)
|
98
|
-
end
|
99
|
-
|
100
|
-
|
101
|
-
# *** DELETE ***
|
102
|
-
|
103
|
-
#== deleteAccount
|
104
|
-
# delete a given account by accountId.
|
105
|
-
# Parameters: AccountId.
|
106
|
-
# Returns the http response code.
|
107
|
-
|
108
|
-
def self.deleteAccount(accountId)
|
109
|
-
url = "#{self.urlWithEntity}/#{accountId}?key=#{self.apiKey}"
|
110
|
-
uri = URI.parse(url)
|
111
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
112
|
-
key="?key=#{self.apiKey}"
|
113
|
-
request = Net::HTTP::Delete.new(uri.path+key)
|
114
|
-
response = http.request(request)
|
115
|
-
end
|
116
|
-
end
|
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
|
+
#= getAll
|
17
|
+
# Returns an array of hashes getting all the customers.
|
18
|
+
# Each index in the array is the hash of an individual customer.
|
19
|
+
|
20
|
+
def self.getAll
|
21
|
+
url = "#{self.urlWithEntity}?&key=#{self.apiKey}"
|
22
|
+
resp = Net::HTTP.get_response(URI.parse(url))
|
23
|
+
data = JSON.parse(resp.body)
|
24
|
+
end
|
25
|
+
|
26
|
+
#== getAllByType
|
27
|
+
# Gets all accounts of a given type.
|
28
|
+
#= Parameters: type
|
29
|
+
# Accepts a string of the account type. 3 possbilities: Credit Card, Savings, Checking.
|
30
|
+
# Returns an array of hashes with the accounts.
|
31
|
+
|
32
|
+
def self.getAllByType(type)
|
33
|
+
url = "#{self.urlWithEntity}?type=#{type}&key=#{self.apiKey}"
|
34
|
+
resp = Net::HTTP.get_response(URI.parse(url))
|
35
|
+
data = JSON.parse(resp.body)
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
#== getOne
|
40
|
+
# Returns the account specified by its account ID.
|
41
|
+
#= Parameters: AccountId
|
42
|
+
# Accepts a string of the account ID.
|
43
|
+
# Returns a hash with the account info.
|
44
|
+
def self.getOne(id)
|
45
|
+
url = "#{self.urlWithEntity}/#{id}?key=#{self.apiKey}"
|
46
|
+
resp = Net::HTTP.get_response(URI.parse(url))
|
47
|
+
data = JSON.parse(resp.body)
|
48
|
+
end
|
49
|
+
|
50
|
+
#== getAllByCustomerId
|
51
|
+
# Returns all accounts associated with a given customer ID as an array of hashes.
|
52
|
+
#= Parameters: CustomerId
|
53
|
+
# Accepts a string of the customer ID
|
54
|
+
|
55
|
+
def self.getAllByCustomerId(customerId)
|
56
|
+
url = "#{self.url}/customers/#{customerId}/accounts?key=#{self.apiKey}"
|
57
|
+
resp = Net::HTTP.get_response(URI.parse(url))
|
58
|
+
data = JSON.parse(resp.body)
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
# *** PUT ***
|
63
|
+
|
64
|
+
#==updateAccount
|
65
|
+
# Updates an account's nickname.
|
66
|
+
#= Parameters: AccountID, AccountHash
|
67
|
+
# Returns the http response code.
|
68
|
+
|
69
|
+
def self.updateAccount(accountId, account)
|
70
|
+
accountToUpdate = account.to_json
|
71
|
+
url = "#{self.urlWithEntity}/#{accountId}?key=#{self.apiKey}"
|
72
|
+
uri = URI.parse(url)
|
73
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
74
|
+
key = "?key=#{self.apiKey}"
|
75
|
+
request = Net::HTTP::Put.new(uri.path+key, initheader = {'Content-Type' =>'application/json'})
|
76
|
+
request.body = accountToUpdate
|
77
|
+
response = http.request(request)
|
78
|
+
return JSON.parse(response.body)
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
# *** POST ***
|
83
|
+
|
84
|
+
#== createAccount
|
85
|
+
# Creates a new account
|
86
|
+
# Parameters: CustomerID, accountHash
|
87
|
+
# Returns the http response code.
|
88
|
+
|
89
|
+
def self.createAccount(custID, account)
|
90
|
+
accountToCreate = account.to_json
|
91
|
+
url = "#{self.url}/customers/#{custID}/accounts?key=#{self.apiKey}"
|
92
|
+
uri = URI.parse(url)
|
93
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
94
|
+
request = Net::HTTP::Post.new(uri.request_uri, initheader = {'Content-Type' =>'application/json'})
|
95
|
+
request.body = accountToCreate
|
96
|
+
response = http.request(request)
|
97
|
+
return JSON.parse(response.body)
|
98
|
+
end
|
99
|
+
|
100
|
+
|
101
|
+
# *** DELETE ***
|
102
|
+
|
103
|
+
#== deleteAccount
|
104
|
+
# delete a given account by accountId.
|
105
|
+
# Parameters: AccountId.
|
106
|
+
# Returns the http response code.
|
107
|
+
|
108
|
+
def self.deleteAccount(accountId)
|
109
|
+
url = "#{self.urlWithEntity}/#{accountId}?key=#{self.apiKey}"
|
110
|
+
uri = URI.parse(url)
|
111
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
112
|
+
key="?key=#{self.apiKey}"
|
113
|
+
request = Net::HTTP::Delete.new(uri.path+key)
|
114
|
+
response = http.request(request)
|
115
|
+
end
|
116
|
+
end
|
data/lib/capital_one/atm.rb
CHANGED
@@ -1,49 +1,73 @@
|
|
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
|
-
|
17
|
-
#==getAll
|
18
|
-
# Returns all ATMs as
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
# Returns
|
31
|
-
|
32
|
-
def self.
|
33
|
-
url = "#{self.urlWithEntity}?
|
34
|
-
resp = Net::HTTP.get_response(URI.parse(url))
|
35
|
-
data = JSON.parse(resp.body)
|
36
|
-
end
|
37
|
-
|
38
|
-
#==
|
39
|
-
#
|
40
|
-
|
41
|
-
#
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
end
|
49
|
-
|
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
|
+
|
17
|
+
#==getAll
|
18
|
+
# Returns all ATMs as a hash (first page only)
|
19
|
+
# Pagination was implemented to break up the size of the hash
|
20
|
+
|
21
|
+
def self.getAll
|
22
|
+
url = "#{self.urlWithEntity}?key=#{self.apiKey}"
|
23
|
+
resp = Net::HTTP.get_response(URI.parse(url))
|
24
|
+
data = JSON.parse(resp.body)
|
25
|
+
end
|
26
|
+
|
27
|
+
#==getAllWithPage
|
28
|
+
# Returns all ATMs for a given response page
|
29
|
+
#= Parameters: page as an integer
|
30
|
+
# Returns a hash of ATM details
|
31
|
+
|
32
|
+
def self.getAllWithPage(page)
|
33
|
+
url = "#{self.urlWithEntity}?key=#{self.apiKey}&page=#{page}"
|
34
|
+
resp = Net::HTTP.get_response(URI.parse(url))
|
35
|
+
data = JSON.parse(resp.body)
|
36
|
+
end
|
37
|
+
|
38
|
+
#==getAllByLocation
|
39
|
+
# Get all ATMs withing a certain radius of a geocoordinate
|
40
|
+
#= Paremeters: latitude, longitude, radius
|
41
|
+
# Accepts lat, lng, and rad as floats
|
42
|
+
# Returns an array of hashes within the radius of the geocoordinate. Each hash has an ATM.
|
43
|
+
|
44
|
+
def self.getAllByLocation(lat, lng, rad)
|
45
|
+
url = "#{self.urlWithEntity}?lat=#{lat}&lng=#{lng}&rad=#{rad}&key=#{self.apiKey}"
|
46
|
+
resp = Net::HTTP.get_response(URI.parse(url))
|
47
|
+
data = JSON.parse(resp.body)
|
48
|
+
end
|
49
|
+
|
50
|
+
#==getAllByLocationWithPage
|
51
|
+
# Returns all ATMs within a certain radius for a given response page
|
52
|
+
#= Parameters: lat, lng, and rad as floats; page as int
|
53
|
+
# Returns a hash of ATM details
|
54
|
+
|
55
|
+
def self.getAllByLocationWithPage(lat, lng, rad, page)
|
56
|
+
url = "#{self.urlWithEntity}?lat=#{lat}&lng=#{lng}&rad=#{rad}&key=#{self.apiKey}&page=#{page}"
|
57
|
+
resp = Net::HTTP.get_response(URI.parse(url))
|
58
|
+
data = JSON.parse(resp.body)
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
#==getOne
|
63
|
+
# Gets one ATM for a given ID
|
64
|
+
# Parameters: AtmId
|
65
|
+
# Returns the ATM that has the given ID.
|
66
|
+
|
67
|
+
def self.getOne(id)
|
68
|
+
url = "#{self.urlWithEntity}/#{id}?key=#{self.apiKey}"
|
69
|
+
resp = Net::HTTP.get_response(URI.parse(url))
|
70
|
+
data = JSON.parse(resp.body)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|