capital_one 0.3.0 → 0.4.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 +57 -54
- data/lib/capital_one/account.rb +116 -107
- data/lib/capital_one/atm.rb +49 -43
- data/lib/capital_one/bill.rb +123 -124
- data/lib/capital_one/branch.rb +36 -34
- data/lib/capital_one/customer.rb +112 -79
- data/lib/capital_one/deposit.rb +109 -76
- data/lib/capital_one/merchant.rb +118 -0
- data/lib/capital_one/purchase.rb +107 -0
- data/lib/capital_one/transfer.rb +93 -0
- data/lib/capital_one/version.rb +3 -3
- data/lib/capital_one/withdrawal.rb +107 -76
- metadata +7 -5
- data/lib/capital_one/transaction.rb +0 -103
data/lib/capital_one/branch.rb
CHANGED
@@ -1,35 +1,37 @@
|
|
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
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
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
|
+
#==getAll
|
18
|
+
# Gets all branches
|
19
|
+
# Returns an array of Hashes with the branch data
|
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
|
+
#==getOne
|
28
|
+
# Gets one branch for a given ID
|
29
|
+
#= Parameters: AtmId
|
30
|
+
# Returns a hash with the ATM data
|
31
|
+
|
32
|
+
def self.getOne(id)
|
33
|
+
url = "#{self.urlWithEntity}/#{id}?key=#{self.apiKey}"
|
34
|
+
resp = Net::HTTP.get_response(URI.parse(url))
|
35
|
+
data = JSON.parse(resp.body)
|
36
|
+
end
|
35
37
|
end
|
data/lib/capital_one/customer.rb
CHANGED
@@ -1,80 +1,113 @@
|
|
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
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
#
|
55
|
-
|
56
|
-
|
57
|
-
#
|
58
|
-
|
59
|
-
#
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
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
|
+
#== getAll
|
22
|
+
# Gets all customers the API key has acccess to.
|
23
|
+
# Returns an array of hashes.
|
24
|
+
|
25
|
+
def self.getAll
|
26
|
+
url = "#{self.urlWithEntity}?key=#{self.apiKey}"
|
27
|
+
resp = Net::HTTP.get_response(URI.parse(url))
|
28
|
+
data = JSON.parse(resp.body)
|
29
|
+
return data
|
30
|
+
end
|
31
|
+
|
32
|
+
#== getOne
|
33
|
+
# Gets the specified customer's information.
|
34
|
+
#= Parameters: CustomerId
|
35
|
+
# Returns a Hash with the customer data
|
36
|
+
|
37
|
+
def self.getOne(custId)
|
38
|
+
url = "#{self.urlWithEntity}/#{custId}?key=#{self.apiKey}"
|
39
|
+
resp = Net::HTTP.get_response(URI.parse(url))
|
40
|
+
data = JSON.parse(resp.body)
|
41
|
+
end
|
42
|
+
|
43
|
+
#== getOneByAccountId
|
44
|
+
# Get the customer for the given account.
|
45
|
+
#= Parameters: AccountId
|
46
|
+
# Returns a hash with the specified customer data.
|
47
|
+
|
48
|
+
def self.getOneByAccountId(accID)
|
49
|
+
url = "#{self.urlWithAcctEntity}/#{accID}/customer?key=#{self.apiKey}"
|
50
|
+
resp = Net::HTTP.get_response(URI.parse(url))
|
51
|
+
data = JSON.parse(resp.body)
|
52
|
+
end
|
53
|
+
|
54
|
+
# *** POST ***
|
55
|
+
|
56
|
+
#==createCustomer
|
57
|
+
# Creates a new customer with the given json data
|
58
|
+
#= Parameters: CustomerHash
|
59
|
+
# JSON is as follows:
|
60
|
+
# {
|
61
|
+
# "first_name": "string",
|
62
|
+
# "last_name": "string",
|
63
|
+
# "address": {
|
64
|
+
# "street_number": "string",
|
65
|
+
# "street_name": "",
|
66
|
+
# "city": "",
|
67
|
+
# "state": "",
|
68
|
+
# "zip": ""
|
69
|
+
# }
|
70
|
+
# }
|
71
|
+
# Returns http response code
|
72
|
+
|
73
|
+
def self.createCustomer(customer)
|
74
|
+
url = "#{self.urlWithEntity}?key=#{self.apiKey}"
|
75
|
+
uri = URI.parse(url)
|
76
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
77
|
+
request = Net::HTTP::Post.new(uri.request_uri, initheader = {'Content-Type' =>'application/json'})
|
78
|
+
request.body = customer.to_json
|
79
|
+
response = http.request(request)
|
80
|
+
return JSON.parse(response.body)
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
# *** PUT ***
|
85
|
+
|
86
|
+
#== updateCustomer
|
87
|
+
# Updates a customer by id with given json data.
|
88
|
+
#= Parameters: CustomerId, CustomerHash.
|
89
|
+
# Json is as follows:
|
90
|
+
# {
|
91
|
+
# "address": {
|
92
|
+
# "street_number": "",
|
93
|
+
# "street_name": "",
|
94
|
+
# "city": "",
|
95
|
+
# "state": "",
|
96
|
+
# "zip": ""
|
97
|
+
# }
|
98
|
+
# }
|
99
|
+
# Returns http response code.
|
100
|
+
|
101
|
+
def self.updateCustomer(custID, customer)
|
102
|
+
customerToUpdate = customer.to_json
|
103
|
+
url = "#{self.urlWithEntity}/#{custID}?key=#{self.apiKey}"
|
104
|
+
uri = URI.parse(url)
|
105
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
106
|
+
key = "?key=#{self.apiKey}"
|
107
|
+
request = Net::HTTP::Put.new(uri.path+key, initheader = {'Content-Type' =>'application/json'})
|
108
|
+
request.body = customerToUpdate
|
109
|
+
response = http.request(request)
|
110
|
+
return JSON.parse(response.body)
|
111
|
+
end
|
112
|
+
|
80
113
|
end
|
data/lib/capital_one/deposit.rb
CHANGED
@@ -1,77 +1,110 @@
|
|
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
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
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
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
def self.
|
35
|
-
url = "#{self.
|
36
|
-
resp = Net::HTTP.get_response(URI.parse(url))
|
37
|
-
data = JSON.parse(resp.body)
|
38
|
-
end
|
39
|
-
|
40
|
-
|
41
|
-
# *** POST ***
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
#
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
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
|
+
#= Parameters: AccountID
|
20
|
+
# Returns an array of hashes containing the deposits for that account.
|
21
|
+
|
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
|
+
|
30
|
+
#==getOne
|
31
|
+
# Returns a deposit for a given ID
|
32
|
+
#= Parameters: DepositId
|
33
|
+
# Returns a hash with the deposit data
|
34
|
+
def self.getOne(id)
|
35
|
+
url = "#{self.url}/deposits/#{id}?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
|
+
#==createDeposit
|
44
|
+
# Creates a new deposit.
|
45
|
+
# Parameters: toAccountId, DepositHash
|
46
|
+
# DepositHash is formatted as follows:
|
47
|
+
# {
|
48
|
+
# "medium": "balance",
|
49
|
+
# "transaction_date": "string",
|
50
|
+
# "status": "pending",
|
51
|
+
# "amount": 0,
|
52
|
+
# "description": "string"
|
53
|
+
# }
|
54
|
+
# Returns http response code.
|
55
|
+
|
56
|
+
def self.createDeposit(toAcc, deposit)
|
57
|
+
depositToCreate = deposit.to_json
|
58
|
+
url = "#{self.urlWithEntity}/#{toAcc}/deposits?key=#{self.apiKey}"
|
59
|
+
uri = URI.parse(url)
|
60
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
61
|
+
request = Net::HTTP::Post.new(uri.request_uri, initheader = {'Content-Type' => 'application/json'})
|
62
|
+
request.body = depositToCreate
|
63
|
+
resp = http.request(request)
|
64
|
+
data = JSON.parse(resp.body)
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
# *** PUT ***
|
69
|
+
|
70
|
+
#==updateDeposit
|
71
|
+
# Updates an existing deposit
|
72
|
+
#= Parameters: DepositId, DepositHash
|
73
|
+
# DepositHash is formatted as follows:
|
74
|
+
# {
|
75
|
+
# "medium": "balance",
|
76
|
+
# "transaction_date": "string",
|
77
|
+
# "status": "pending",
|
78
|
+
# "amount": 0,
|
79
|
+
# "description": "string"
|
80
|
+
# }
|
81
|
+
# Returns http response code
|
82
|
+
|
83
|
+
def self.updateDeposit(id, deposit)
|
84
|
+
depositToUpdate = deposit.to_json
|
85
|
+
url = "#{self.url}/deposits/#{id}?key=#{self.apiKey}"
|
86
|
+
uri = URI.parse(url)
|
87
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
88
|
+
key = "?key=#{self.apiKey}"
|
89
|
+
request = Net::HTTP::Put.new(uri.path+key, initheader = {'Content-Type' =>'application/json'})
|
90
|
+
request.body = depositToUpdate
|
91
|
+
response = http.request(request)
|
92
|
+
return JSON.parse(response.body)
|
93
|
+
end
|
94
|
+
|
95
|
+
# *** DELETE ***
|
96
|
+
|
97
|
+
#==deleteDeposit
|
98
|
+
# Deletes an existing deposit
|
99
|
+
#= Parameters: DepositId
|
100
|
+
# Returns http response code
|
101
|
+
|
102
|
+
def self.deleteDeposit(id)
|
103
|
+
url = "#{self.url}/deposits/#{id}?key=#{self.apiKey}"
|
104
|
+
uri = URI.parse(url)
|
105
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
106
|
+
key="?key=#{self.apiKey}"
|
107
|
+
request = Net::HTTP::Delete.new(uri.path+key)
|
108
|
+
resp = http.request(request)
|
109
|
+
end
|
77
110
|
end
|