capital_one 0.1.0 → 0.2.0
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 +18 -0
- data/lib/capital_one/account.rb +30 -12
- data/lib/capital_one/atm.rb +15 -0
- data/lib/capital_one/bill.rb +45 -10
- data/lib/capital_one/branch.rb +7 -6
- data/lib/capital_one/customer.rb +23 -5
- data/lib/capital_one/deposit.rb +77 -0
- data/lib/capital_one/transaction.rb +47 -6
- data/lib/capital_one/withdrawal.rb +76 -0
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 37266853addb740e2d6e646c3f97aad6e51d7d43
|
4
|
+
data.tar.gz: ce2878b48b6a415b71071b810fdfc73c1b062c2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81a3b93e75eafa60d15067953c6254b13b81b944e17ff5a2f1bb765be72111428e1118971347fd03c9bf4515427f82b6a9762c5e63fa5d74a9b841c1e76a37c2
|
7
|
+
data.tar.gz: eb62295f194a01999924776dc1d2e238af96e833f284815fe0ff8724601490e67fa0394006b523afaf1a468718425d548f8a7b4467e2e66ab9d9956b67ddf30e
|
data/lib/capital_one.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
=begin
|
2
2
|
|
3
|
+
==Capital One API Gem
|
4
|
+
|
3
5
|
This is a gem to wrap the Capital One public API.
|
4
6
|
Visit api.reimaginebanking.com for more details.
|
5
7
|
|
@@ -25,13 +27,29 @@ require 'capital_one/bill'
|
|
25
27
|
require 'capital_one/branch'
|
26
28
|
require 'capital_one/customer'
|
27
29
|
require 'capital_one/transaction'
|
30
|
+
require 'capital_one/withdrawal'
|
31
|
+
require 'capital_one/deposit'
|
28
32
|
|
29
33
|
=begin
|
30
34
|
|
35
|
+
==Important Info
|
36
|
+
|
31
37
|
Depending on the access level/type of API key supplied, some of
|
32
38
|
these methods will return 403 error codes(forbidden). Enterprise level
|
33
39
|
API keys have access to any/all of the GET requests, but nothing else.
|
34
40
|
Customer level API keys have access to GET, POST, PUT, and DELETE, but only
|
35
41
|
for valid accounts which are associated with the customer API key.
|
36
42
|
|
43
|
+
Additionally, some of the GET requests will change in functionality depending on the
|
44
|
+
type of key used. For example, the getAll method in the Customer class returns all customers if
|
45
|
+
the enterprise API key is used. If the customer API key is used, it will only return the customers that
|
46
|
+
the key is associated with.
|
47
|
+
|
48
|
+
For the purposes of this gem, any ID parameters Strings that are 24 hex characters long. Below is an example:
|
49
|
+
5326c07ba520d1066c9ac52b
|
50
|
+
|
51
|
+
You can see the API that this gem wraps at api.reimaginebanking.com
|
52
|
+
|
53
|
+
|
54
|
+
|
37
55
|
=end
|
data/lib/capital_one/account.rb
CHANGED
@@ -13,6 +13,9 @@ class Account
|
|
13
13
|
end
|
14
14
|
|
15
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.
|
16
19
|
|
17
20
|
def self.getAll
|
18
21
|
url = "#{self.urlWithEntity}?&key=#{self.apiKey}"
|
@@ -20,23 +23,32 @@ class Account
|
|
20
23
|
data = JSON.parse(resp.body)
|
21
24
|
end
|
22
25
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
+
#== getAllByType
|
27
|
+
#Gets all accounts of a given type.
|
28
|
+
#=Parameters:
|
29
|
+
#Accepts a string of the account type. 3 possbilities: Credit Card, Savings, Checking.
|
30
|
+
#Returns an array of hashes with the accounts.
|
31
|
+
|
26
32
|
def self.getAllByType(type)
|
27
33
|
url = "#{self.urlWithEntity}?type=#{type}&key=#{self.apiKey}"
|
28
34
|
resp = Net::HTTP.get_response(URI.parse(url))
|
29
35
|
data = JSON.parse(resp.body)
|
30
36
|
end
|
37
|
+
|
38
|
+
#== getOne
|
31
39
|
#Returns the account specified by it's account ID.
|
32
|
-
|
40
|
+
#=Parameters:
|
41
|
+
#Accepts a string of the account ID.
|
42
|
+
#Returns a hash with the account info.
|
33
43
|
def self.getOne(id)
|
34
44
|
url = "#{self.urlWithEntity}/#{id}?key=#{self.apiKey}"
|
35
45
|
resp = Net::HTTP.get_response(URI.parse(url))
|
36
46
|
data = JSON.parse(resp.body)
|
37
47
|
end
|
38
|
-
|
39
|
-
#
|
48
|
+
#== getAllByCustomerId
|
49
|
+
#Returns all accounts associated with a given customer ID
|
50
|
+
#as an array of hashes.
|
51
|
+
|
40
52
|
def self.getAllByCustomerId(customerId)
|
41
53
|
url = "#{self.url}/customers/#{customerId}/accounts?key=#{self.apiKey}"
|
42
54
|
resp = Net::HTTP.get_response(URI.parse(url))
|
@@ -45,8 +57,10 @@ class Account
|
|
45
57
|
|
46
58
|
|
47
59
|
# *** PUT ***
|
48
|
-
|
49
|
-
#
|
60
|
+
#==updateAccount
|
61
|
+
#Updates an account's nickname.
|
62
|
+
#Parameters: AccountID, AccountHash
|
63
|
+
#Returns the http response code.
|
50
64
|
def self.updateAccount(accountId, account)
|
51
65
|
url = "#{self.urlWithEntity}/#{accountId}?key=#{self.apiKey}"
|
52
66
|
uri = URI.parse(url)
|
@@ -60,8 +74,10 @@ class Account
|
|
60
74
|
|
61
75
|
|
62
76
|
# *** POST ***
|
63
|
-
|
64
|
-
#
|
77
|
+
#==createAccount
|
78
|
+
#Creates a new account
|
79
|
+
#Parameters: CustomerID, accountHash
|
80
|
+
#Returns the http response code.
|
65
81
|
def self.createAccount(custID, account)
|
66
82
|
accountToCreate = account.to_json
|
67
83
|
url = "#{self.url}/customers/#{custID}/accounts?key=#{self.apiKey}"
|
@@ -75,8 +91,10 @@ class Account
|
|
75
91
|
|
76
92
|
|
77
93
|
# *** DELETE ***
|
78
|
-
|
79
|
-
#delete a given account
|
94
|
+
#==deleteAccount
|
95
|
+
#delete a given account by accountId.
|
96
|
+
#Parameters: AccountId.
|
97
|
+
#Returns the http response code.
|
80
98
|
def self.deleteAccount(accountId)
|
81
99
|
url = "#{self.urlWithEntity}/#{accountId}?key=#{self.apiKey}"
|
82
100
|
uri = URI.parse(url)
|
data/lib/capital_one/atm.rb
CHANGED
@@ -13,12 +13,27 @@ class Atm
|
|
13
13
|
end
|
14
14
|
|
15
15
|
# *** GET ***
|
16
|
+
#==getAll
|
17
|
+
#Returns all ATMs as an array of hashes.
|
18
|
+
|
16
19
|
def self.getAll
|
17
20
|
url = "#{self.urlWithEntity}?key=#{self.apiKey}"
|
18
21
|
resp = Net::HTTP.get_response(URI.parse(url))
|
19
22
|
data = JSON.parse(resp.body)
|
20
23
|
end
|
24
|
+
|
25
|
+
#==getAllByLocation
|
26
|
+
# Get all ATMs withing a certain radius of a geocoordinate
|
27
|
+
# Returns an array of hashes within the radius of the geocoordinate. Each hash has an ATM.
|
28
|
+
def self.getAllByLocation(lat, lng, rad)
|
29
|
+
url = "#{self.urlWithEntity}?lat=#{lat}&lng=#{lng}&rad=#{rad}&key=#{self.apiKey}"
|
30
|
+
resp = Net::HTTP.get_response(URI.parse(url))
|
31
|
+
data = JSON.parse(resp.body)
|
32
|
+
end
|
21
33
|
|
34
|
+
#==getOne
|
35
|
+
#Parameters: ATMid
|
36
|
+
#Returns the ATM that has the given ID.
|
22
37
|
def self.getOne(id)
|
23
38
|
url = "#{self.urlWithEntity}/#{id}?key=#{self.apiKey}"
|
24
39
|
resp = Net::HTTP.get_response(URI.parse(url))
|
data/lib/capital_one/bill.rb
CHANGED
@@ -18,29 +18,39 @@ class Bill
|
|
18
18
|
|
19
19
|
# *** GET ***
|
20
20
|
|
21
|
-
|
21
|
+
#==getAllByCustomerId
|
22
22
|
# Get all bills for a specific customer
|
23
|
+
#Parameters: customerId
|
24
|
+
#Returns the customer as a hash array.
|
23
25
|
def self.getAllByCustomerId(customerId)
|
24
26
|
url = "#{self.customerBaseUrl}/#{customerId}/bills?key=#{self.apiKey}"
|
25
27
|
response = Net::HTTP.get_response(URI.parse(url))
|
26
28
|
return JSON.parse(response.body)
|
27
29
|
end
|
28
|
-
|
29
|
-
|
30
|
+
|
31
|
+
#==getOneByCustomerIdBillId
|
32
|
+
# Get a specific bill from a specific customer.
|
33
|
+
#Parameters: customerId, BillId
|
34
|
+
#Returns the specified bill as a hash array
|
30
35
|
def self.getOneByCustomerIdBillId(customerId, billId)
|
31
36
|
url = "#{self.customerBaseUrl}/#{customerId}/bills/#{billId}?key=#{self.apiKey}"
|
32
37
|
resp = Net::HTTP.get_response(URI.parse(url))
|
33
38
|
data = JSON.parse(resp.body)
|
34
39
|
end
|
35
|
-
|
40
|
+
|
41
|
+
#==getAllByAccountId
|
36
42
|
#Get all bills for a specific account
|
43
|
+
#Parameters: accountId
|
44
|
+
#Returns an array of hashes containing the bills.
|
37
45
|
def self.getAllByAccountId(accountId)
|
38
46
|
url = "#{self.accountBaseUrl}/#{accountId}/bills?key=#{self.apiKey}"
|
39
47
|
response = Net::HTTP.get_response(URI.parse(url))
|
40
48
|
return JSON.parse(response.body)
|
41
49
|
end
|
42
|
-
|
43
|
-
#
|
50
|
+
#==getOneByAccountIdBillId
|
51
|
+
#Get a specific bill from a specific account
|
52
|
+
#Parameters: AccountId, BillId
|
53
|
+
#Returns a hash array with the bill.
|
44
54
|
def self.getOneByAccountIdBillId(accountId, billId)
|
45
55
|
url ="#{self.accountBaseUrl}/#{accountId}/bills/#{billId}?key=#{self.apiKey}"
|
46
56
|
response = Net::HTTP.get_response(URI.parse(url))
|
@@ -48,8 +58,20 @@ class Bill
|
|
48
58
|
end
|
49
59
|
|
50
60
|
# *** POST ***
|
61
|
+
#==updateBill
|
62
|
+
#Updates an account's nickname by id with given json data.
|
63
|
+
#Parameters: AccountId, BillId, BillJson
|
64
|
+
#Json format is as follows:
|
65
|
+
# {
|
66
|
+
# "status": "",
|
67
|
+
# "payee": "",
|
68
|
+
# "nickname": "",
|
69
|
+
# "payment_date": "",
|
70
|
+
# "recurring_date": 0,
|
71
|
+
# "payment_amount": 0
|
72
|
+
# }
|
73
|
+
#Returns http response code.
|
51
74
|
|
52
|
-
#updates an account's nickname by id with given json data.
|
53
75
|
def self.updateBill(accountId, billId, bill)
|
54
76
|
url = "#{self.accountBaseUrl}/#{accountId}/bills/#{billId}?key=#{self.apiKey}"
|
55
77
|
uri = URI.parse(url)
|
@@ -62,8 +84,19 @@ class Bill
|
|
62
84
|
end
|
63
85
|
|
64
86
|
# *** POST ***
|
65
|
-
|
87
|
+
#==createBill
|
66
88
|
#create a new bill on an associated account ID
|
89
|
+
#Parameters: AccountId, BillJson
|
90
|
+
#Json is as follows:
|
91
|
+
# {
|
92
|
+
# "status": "",
|
93
|
+
# "payee": "",
|
94
|
+
# "nickname": "",
|
95
|
+
# "payment_date": "",
|
96
|
+
# "recurring_date": 0,
|
97
|
+
# "payment_amount": 0
|
98
|
+
# }
|
99
|
+
#Returns http response code.
|
67
100
|
def self.createBill(accountId, bill)
|
68
101
|
url = "#{self.accountBaseUrl}/#{accountId}/bills?key=#{self.apiKey}"
|
69
102
|
uri = URI.parse(url)
|
@@ -76,8 +109,10 @@ class Bill
|
|
76
109
|
|
77
110
|
|
78
111
|
# *** DELETE ***
|
79
|
-
|
80
|
-
#delete a bill by id from a given account
|
112
|
+
#==deleteBill
|
113
|
+
#delete a bill by id from a given account.
|
114
|
+
#Parameters: Accountid, billid.
|
115
|
+
#Returns http response code.
|
81
116
|
def self.deleteBill(accountId, billId)
|
82
117
|
url = "#{self.accountBaseUrl}/#{accountId}/bills/#{billId}?key=#{self.apiKey}"
|
83
118
|
uri = URI.parse(url)
|
data/lib/capital_one/branch.rb
CHANGED
@@ -13,18 +13,19 @@ class Branch
|
|
13
13
|
end
|
14
14
|
|
15
15
|
# *** GET ***
|
16
|
-
|
16
|
+
#==getAll
|
17
17
|
# Get all the branches
|
18
|
-
#
|
18
|
+
#Returns an array of hashes. Each hash is a branch.
|
19
19
|
def self.getAll
|
20
20
|
url = "#{self.urlWithEntity}?key=#{self.apiKey}"
|
21
21
|
resp = Net::HTTP.get_response(URI.parse(url))
|
22
22
|
data = JSON.parse(resp.body)
|
23
|
-
|
24
23
|
end
|
25
|
-
|
26
|
-
|
27
|
-
#
|
24
|
+
|
25
|
+
#==getOne
|
26
|
+
#Get a branch by it's id
|
27
|
+
#Parameters: BranchId
|
28
|
+
#Returns a hash with the specified branch.
|
28
29
|
def self.getOne(id)
|
29
30
|
url = "#{self.urlWithEntity}/#{id}?key=#{self.apiKey}"
|
30
31
|
resp = Net::HTTP.get_response(URI.parse(url))
|
data/lib/capital_one/customer.rb
CHANGED
@@ -17,16 +17,19 @@ class Customer
|
|
17
17
|
end
|
18
18
|
|
19
19
|
# *** GET ***
|
20
|
-
|
21
|
-
#
|
22
|
-
#
|
20
|
+
#==getAll
|
21
|
+
#Gets all customers the API key has acccess to.
|
22
|
+
#Returns an array of hashes.
|
23
23
|
def self.getAll
|
24
24
|
url = "#{self.urlWithEntity}?key=#{self.apiKey}"
|
25
25
|
resp = Net::HTTP.get_response(URI.parse(url))
|
26
26
|
data = JSON.parse(resp.body)
|
27
27
|
return data
|
28
28
|
end
|
29
|
+
|
30
|
+
#==getOne
|
29
31
|
#Gets the specified customer's information.
|
32
|
+
#Parameters
|
30
33
|
#tested - Returns a hash.
|
31
34
|
def self.getOne(custId)
|
32
35
|
url = "#{self.urlWithEntity}/#{custId}?key=#{self.apiKey}"
|
@@ -34,8 +37,10 @@ class Customer
|
|
34
37
|
data = JSON.parse(resp.body)
|
35
38
|
end
|
36
39
|
|
40
|
+
#==getOneByAccountId
|
37
41
|
#Get the customer for the given account.
|
38
|
-
#
|
42
|
+
#Parameters: AccountId
|
43
|
+
#Returns a hash with the specified customer data.
|
39
44
|
def self.getOneByAccountId(accID)
|
40
45
|
url = "#{self.urlWithAcctEntity}/#{accID}/customer?key=#{self.apiKey}"
|
41
46
|
resp = Net::HTTP.get_response(URI.parse(url))
|
@@ -44,7 +49,20 @@ class Customer
|
|
44
49
|
|
45
50
|
|
46
51
|
# *** PUT ***
|
47
|
-
|
52
|
+
#==updateCustomer
|
53
|
+
#Updates a customer by id with given json data.
|
54
|
+
#Parameters: CustomerId, CustomerJson.
|
55
|
+
#Json is as follows:
|
56
|
+
# {
|
57
|
+
# "address": {
|
58
|
+
# "street_number": "",
|
59
|
+
# "street_name": "",
|
60
|
+
# "city": "",
|
61
|
+
# "state": "",
|
62
|
+
# "zip": ""
|
63
|
+
# }
|
64
|
+
# }
|
65
|
+
#Returns http response code.
|
48
66
|
def self.updateCustomer(custID, customer)
|
49
67
|
url = "#{self.urlWithEntity}/#{custID}?key=#{self.apiKey}"
|
50
68
|
uri = URI.parse(url)
|
@@ -0,0 +1,77 @@
|
|
1
|
+
class Deposit
|
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
|
+
#==getAllByAccountId
|
18
|
+
#Get all deposits for a specific account
|
19
|
+
#Returns an array of hashes.
|
20
|
+
#Parameters: AccountID
|
21
|
+
#Returns an array of hashes containing the deposits for that account.
|
22
|
+
def self.getAllByAccountId(accID)
|
23
|
+
url = "#{self.urlWithEntity}/#{accID}/deposits?key=#{self.apiKey}"
|
24
|
+
resp = Net::HTTP.get_response(URI.parse(url))
|
25
|
+
data = JSON.parse(resp.body)
|
26
|
+
return data
|
27
|
+
end
|
28
|
+
|
29
|
+
#==getOneByAccountIdDepositId
|
30
|
+
# Get a specific deposit from a specific account.
|
31
|
+
#Parameters: AccountID, DepositID
|
32
|
+
# Returns a hash with the specified deposit
|
33
|
+
|
34
|
+
def self.getOneByAccountIdDepositId(accID, depositID)
|
35
|
+
url = "#{self.urlWithEntity}/#{accID}/deposits/#{depositID}?key=#{self.apiKey}"
|
36
|
+
resp = Net::HTTP.get_response(URI.parse(url))
|
37
|
+
data = JSON.parse(resp.body)
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
# *** POST ***
|
42
|
+
|
43
|
+
# Create a new deposit into an account
|
44
|
+
#==createDeposit
|
45
|
+
#Creates a new deposit.
|
46
|
+
#Parameters: toAccountId, hashWithDepositData
|
47
|
+
#Returns http response code.
|
48
|
+
def self.createDeposit(toAcc, json)
|
49
|
+
url = "#{self.urlWithEntity}/#{toAcc}/deposits?key=#{self.apiKey}"
|
50
|
+
uri = URI.parse(url)
|
51
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
52
|
+
request = Net::HTTP::Post.new(uri.request_uri, initheader = {'Content-Type' => 'application/json'})
|
53
|
+
request.body = json
|
54
|
+
resp = http.request(request)
|
55
|
+
data = JSON.parse(resp.body)
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
# *** DELETE ***
|
60
|
+
|
61
|
+
#==deleteDeposit
|
62
|
+
#Deletes a specified deposit from a specified account.
|
63
|
+
#Parameters: accountID, depositID
|
64
|
+
#Returns http response code.
|
65
|
+
#=Note:
|
66
|
+
#This does not actually delete the deposit from the database, it only sets it's
|
67
|
+
#status to 'cancelled'
|
68
|
+
def self.deleteDeposit(accID, depositID)
|
69
|
+
url = "#{self.urlWithEntity}/#{accID}/deposits/#{depositID}?key=#{self.apiKey}"
|
70
|
+
uri = URI.parse(url)
|
71
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
72
|
+
key="?key=#{self.apiKey}"
|
73
|
+
request = Net::HTTP::Delete.new(uri.path+key)
|
74
|
+
resp = http.request(request)
|
75
|
+
data = JSON.parse(resp.body)
|
76
|
+
end
|
77
|
+
end
|
@@ -14,9 +14,11 @@ class Transaction
|
|
14
14
|
|
15
15
|
|
16
16
|
# *** GET ***
|
17
|
-
|
18
|
-
#
|
19
|
-
#
|
17
|
+
#==getAllByAccountId
|
18
|
+
#Get all transactions for a specific account where that account is the payer or payee
|
19
|
+
#Returns an array of hashes.
|
20
|
+
#Parameters: AccountID
|
21
|
+
#Returns an array of hashes containing the transactions for that account where that account is the payer or payee.
|
20
22
|
def self.getAllByAccountId(accID)
|
21
23
|
url = "#{self.urlWithEntity}/#{accID}/transactions?key=#{self.apiKey}"
|
22
24
|
resp = Net::HTTP.get_response(URI.parse(url))
|
@@ -24,8 +26,37 @@ class Transaction
|
|
24
26
|
return data
|
25
27
|
end
|
26
28
|
|
27
|
-
#
|
28
|
-
|
29
|
+
# *** GET ***
|
30
|
+
#==getAllByAccountIdPayer
|
31
|
+
#Get all transactions for a specific account where that account is the payer
|
32
|
+
#Returns an array of hashes.
|
33
|
+
#Parameters: AccountID
|
34
|
+
#Returns an array of hashes containing the transactions for that account where that account is the payer.
|
35
|
+
def self.getAllByAccountIdPayer(accID)
|
36
|
+
url = "#{self.urlWithEntity}/#{accID}/transactions?type=payer&key=#{self.apiKey}"
|
37
|
+
resp = Net::HTTP.get_response(URI.parse(url))
|
38
|
+
data = JSON.parse(resp.body)
|
39
|
+
return data
|
40
|
+
end
|
41
|
+
|
42
|
+
# *** GET ***
|
43
|
+
#==getAllByAccountIdPayee
|
44
|
+
#Get all transactions for a specific account where that account is the payee
|
45
|
+
#Returns an array of hashes.
|
46
|
+
#Parameters: AccountID
|
47
|
+
#Returns an array of hashes containing the transactions for that account where that account is the payee.
|
48
|
+
def self.getAllByAccountIdPayee(accID)
|
49
|
+
url = "#{self.urlWithEntity}/#{accID}/transactions?type=payee&key=#{self.apiKey}"
|
50
|
+
resp = Net::HTTP.get_response(URI.parse(url))
|
51
|
+
data = JSON.parse(resp.body)
|
52
|
+
return data
|
53
|
+
end
|
54
|
+
|
55
|
+
#==getOneByAccountIdTransactionId
|
56
|
+
# Get a specific transaction from a specific account.
|
57
|
+
#Parameters: AccountID, TransactionId
|
58
|
+
# Returns a hash with the specified transaction
|
59
|
+
|
29
60
|
def self.getOneByAccountIdTransactionId(accID, tranID)
|
30
61
|
url = "#{self.urlWithEntity}/#{accID}/transactions/#{tranID}?key=#{self.apiKey}"
|
31
62
|
resp = Net::HTTP.get_response(URI.parse(url))
|
@@ -36,6 +67,10 @@ class Transaction
|
|
36
67
|
# *** POST ***
|
37
68
|
|
38
69
|
# Create a new transaction between 2 accounts
|
70
|
+
#==createTransaction
|
71
|
+
#Creates a new transaction.
|
72
|
+
#Parameters: toAccountId, hashWithTransacionData
|
73
|
+
#Returns http response code.
|
39
74
|
def self.createTransaction(toAcc, json)
|
40
75
|
url = "#{self.urlWithEntity}/#{toAcc}/transactions?key=#{self.apiKey}"
|
41
76
|
uri = URI.parse(url)
|
@@ -49,6 +84,13 @@ class Transaction
|
|
49
84
|
|
50
85
|
# *** DELETE ***
|
51
86
|
|
87
|
+
#==deleteTransaction
|
88
|
+
#Deletes a specified transaction from a specified account.
|
89
|
+
#Parameters: AccountID, TransactionID
|
90
|
+
#Returns http response code.
|
91
|
+
#=Note:
|
92
|
+
#This does not actually delete the transaction from the database, it only sets it's
|
93
|
+
#status to 'cancelled'
|
52
94
|
def self.deleteTransaction(accID, transID)
|
53
95
|
url = "#{self.urlWithEntity}/#{accID}/transactions/#{transID}?key=#{self.apiKey}"
|
54
96
|
uri = URI.parse(url)
|
@@ -56,6 +98,5 @@ class Transaction
|
|
56
98
|
key="?key=#{self.apiKey}"
|
57
99
|
request = Net::HTTP::Delete.new(uri.path+key)
|
58
100
|
resp = http.request(request)
|
59
|
-
#data = JSON.parse(resp.body)
|
60
101
|
end
|
61
102
|
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
class Withdrawal
|
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
|
+
#==getAllByAccountId
|
18
|
+
#Get all withdrawals for a specific account
|
19
|
+
#Returns an array of hashes.
|
20
|
+
#Parameters: AccountID
|
21
|
+
#Returns an array of hashes containing the withdrawals for that account.
|
22
|
+
def self.getAllByAccountId(accID)
|
23
|
+
url = "#{self.urlWithEntity}/#{accID}/withdrawals?key=#{self.apiKey}"
|
24
|
+
resp = Net::HTTP.get_response(URI.parse(url))
|
25
|
+
data = JSON.parse(resp.body)
|
26
|
+
return data
|
27
|
+
end
|
28
|
+
|
29
|
+
#==getOneByAccountIdWithdrawalId
|
30
|
+
# Get a specific withdrawal from a specific account.
|
31
|
+
#Parameters: accountID, withdrawalID
|
32
|
+
# Returns a hash with the specified withdrawal
|
33
|
+
|
34
|
+
def self.getOneByAccountIdWithdrawalId(accID, withdrawalID)
|
35
|
+
url = "#{self.urlWithEntity}/#{accID}/withdrawals/#{withdrawalID}?key=#{self.apiKey}"
|
36
|
+
resp = Net::HTTP.get_response(URI.parse(url))
|
37
|
+
data = JSON.parse(resp.body)
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
# *** POST ***
|
42
|
+
|
43
|
+
# Create a new withdrawal into an account
|
44
|
+
#==createWithdrawal
|
45
|
+
#Creates a new withdrawal.
|
46
|
+
#Parameters: toAccountId, hashWithWithdrawalData
|
47
|
+
#Returns http response code.
|
48
|
+
def self.createWithdrawal(toAcc, json)
|
49
|
+
url = "#{self.urlWithEntity}/#{toAcc}/withdrawals?key=#{self.apiKey}"
|
50
|
+
uri = URI.parse(url)
|
51
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
52
|
+
request = Net::HTTP::Post.new(uri.request_uri, initheader = {'Content-Type' => 'application/json'})
|
53
|
+
request.body = json
|
54
|
+
resp = http.request(request)
|
55
|
+
data = JSON.parse(resp.body)
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
# *** DELETE ***
|
60
|
+
|
61
|
+
#==deleteWithdrawal
|
62
|
+
#Deletes a specified withdrawal from a specified account.
|
63
|
+
#Parameters: accountID, withdrawalID
|
64
|
+
#Returns http response code.
|
65
|
+
#=Note:
|
66
|
+
#This does not actually delete the withdrawal from the database, it only sets it's
|
67
|
+
#status to 'cancelled'
|
68
|
+
def self.deleteWithdrawal(accID, withdrawalID)
|
69
|
+
url = "#{self.urlWithEntity}/#{accID}/withdrawals/#{withdrawalID}?key=#{self.apiKey}"
|
70
|
+
uri = URI.parse(url)
|
71
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
72
|
+
key="?key=#{self.apiKey}"
|
73
|
+
request = Net::HTTP::Delete.new(uri.path+key)
|
74
|
+
resp = http.request(request)
|
75
|
+
end
|
76
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capital_one
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shane Besong
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-05-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -123,14 +123,15 @@ files:
|
|
123
123
|
- lib/capital_one/bill.rb
|
124
124
|
- lib/capital_one/branch.rb
|
125
125
|
- lib/capital_one/customer.rb
|
126
|
+
- lib/capital_one/deposit.rb
|
126
127
|
- lib/capital_one/transaction.rb
|
127
128
|
- lib/capital_one/version.rb
|
129
|
+
- lib/capital_one/withdrawal.rb
|
128
130
|
homepage: https://github.com/Shwheelz/capital_one
|
129
131
|
licenses:
|
130
132
|
- MIT
|
131
133
|
metadata:
|
132
|
-
allowed_push_host:
|
133
|
-
rubygems.org, or delete to allow pushes to any server.'
|
134
|
+
allowed_push_host: https://rubygems.org
|
134
135
|
post_install_message:
|
135
136
|
rdoc_options: []
|
136
137
|
require_paths:
|
@@ -147,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
147
148
|
version: '0'
|
148
149
|
requirements: []
|
149
150
|
rubyforge_project:
|
150
|
-
rubygems_version: 2.
|
151
|
+
rubygems_version: 2.4.5
|
151
152
|
signing_key:
|
152
153
|
specification_version: 4
|
153
154
|
summary: Connects to the Capital One API
|