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
data/lib/capital_one/deposit.rb
CHANGED
@@ -1,110 +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
|
-
# 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
|
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
|
110
110
|
end
|
data/lib/capital_one/merchant.rb
CHANGED
@@ -1,118 +1,118 @@
|
|
1
|
-
class Merchant
|
2
|
-
|
3
|
-
def self.urlWithEntity
|
4
|
-
return Config.baseUrl + "/merchants"
|
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 Merchants as an array of hashes
|
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
|
-
return data
|
24
|
-
end
|
25
|
-
|
26
|
-
#==getAllByLocation
|
27
|
-
# Returns all Merchants within a given location range
|
28
|
-
#= Parameters: Latitude, Longitude, Radius
|
29
|
-
# Accepts lat, lng, and rad as floats
|
30
|
-
# Returns an array of hashes
|
31
|
-
|
32
|
-
def self.getAllByLocation(lat, lng, rad)
|
33
|
-
url = "#{self.urlWithEntity}?lat=#{lat}&lng=#{lng}&rad=#{rad}&key=#{self.apiKey}"
|
34
|
-
resp = Net::HTTP.get_response(URI.parse(url))
|
35
|
-
data = JSON.parse(resp.body)
|
36
|
-
return data
|
37
|
-
end
|
38
|
-
|
39
|
-
#==getOne
|
40
|
-
# Returns a single merchant for a given ID
|
41
|
-
#= Parameters: MerchantId
|
42
|
-
# Returns a hash
|
43
|
-
|
44
|
-
def self.getOne(merchId)
|
45
|
-
url = "#{self.urlWithEntity}/#{merchId}?key=#{self.apiKey}"
|
46
|
-
resp = Net::HTTP.get_response(URI.parse(url))
|
47
|
-
data = JSON.parse(resp.body)
|
48
|
-
return data
|
49
|
-
end
|
50
|
-
|
51
|
-
# *** PUT ***
|
52
|
-
|
53
|
-
#==updateMerchant
|
54
|
-
# Updates an existing Merchant
|
55
|
-
#= Parameters: MerchantId, MerchantHash
|
56
|
-
# MerchantHash format is as follows:
|
57
|
-
# {
|
58
|
-
# "name": "string",
|
59
|
-
# "address": {
|
60
|
-
# "street_number": "string",
|
61
|
-
# "street_name": "string",
|
62
|
-
# "city": "string",
|
63
|
-
# "state": "string",
|
64
|
-
# "zip": "string",
|
65
|
-
# },
|
66
|
-
# "geocode": {
|
67
|
-
# "lat": 0,
|
68
|
-
# "lng": 0,
|
69
|
-
# }
|
70
|
-
# }
|
71
|
-
# Returns http response code
|
72
|
-
|
73
|
-
def self.updateMerchant(merchId, merchant)
|
74
|
-
merchantToUpdate = merchant.to_json
|
75
|
-
url = "#{self.urlWithEntity}/#{merchId}?key=#{self.apiKey}"
|
76
|
-
uri = URI.parse(url)
|
77
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
78
|
-
key = "?key=#{self.apiKey}"
|
79
|
-
request = Net::HTTP::Put.new(uri.path+key, initheader = {'Content-Type' =>'application/json'})
|
80
|
-
request.body = merchantToUpdate
|
81
|
-
response = http.request(request)
|
82
|
-
return JSON.parse(response.body)
|
83
|
-
end
|
84
|
-
|
85
|
-
# *** POST ***
|
86
|
-
|
87
|
-
#==createMerchant
|
88
|
-
# Creates a new Merchant
|
89
|
-
#= Parameters: MerchantHash
|
90
|
-
# MerchantHash format is as follows:
|
91
|
-
# {
|
92
|
-
# "name": "string",
|
93
|
-
# "address": {
|
94
|
-
# "street_number": "string",
|
95
|
-
# "street_name": "string",
|
96
|
-
# "city": "string",
|
97
|
-
# "state": "string",
|
98
|
-
# "zip": "string",
|
99
|
-
# },
|
100
|
-
# "geocode": {
|
101
|
-
# "lat": 0,
|
102
|
-
# "lng": 0,
|
103
|
-
# }
|
104
|
-
# }
|
105
|
-
# Returns http response code
|
106
|
-
|
107
|
-
def self.createMerchant(merchant)
|
108
|
-
merchantToCreate = merchant.to_json
|
109
|
-
url = "#{self.urlWithEntity}/?key=#{self.apiKey}"
|
110
|
-
uri = URI.parse(url)
|
111
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
112
|
-
request = Net::HTTP::Post.new(uri.request_uri, initheader = {'Content-Type' => 'application/json'})
|
113
|
-
request.body = merchantToCreate
|
114
|
-
resp = http.request(request)
|
115
|
-
data = JSON.parse(resp.body)
|
116
|
-
end
|
117
|
-
|
1
|
+
class Merchant
|
2
|
+
|
3
|
+
def self.urlWithEntity
|
4
|
+
return Config.baseUrl + "/merchants"
|
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 Merchants as an array of hashes
|
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
|
+
return data
|
24
|
+
end
|
25
|
+
|
26
|
+
#==getAllByLocation
|
27
|
+
# Returns all Merchants within a given location range
|
28
|
+
#= Parameters: Latitude, Longitude, Radius
|
29
|
+
# Accepts lat, lng, and rad as floats
|
30
|
+
# Returns an array of hashes
|
31
|
+
|
32
|
+
def self.getAllByLocation(lat, lng, rad)
|
33
|
+
url = "#{self.urlWithEntity}?lat=#{lat}&lng=#{lng}&rad=#{rad}&key=#{self.apiKey}"
|
34
|
+
resp = Net::HTTP.get_response(URI.parse(url))
|
35
|
+
data = JSON.parse(resp.body)
|
36
|
+
return data
|
37
|
+
end
|
38
|
+
|
39
|
+
#==getOne
|
40
|
+
# Returns a single merchant for a given ID
|
41
|
+
#= Parameters: MerchantId
|
42
|
+
# Returns a hash
|
43
|
+
|
44
|
+
def self.getOne(merchId)
|
45
|
+
url = "#{self.urlWithEntity}/#{merchId}?key=#{self.apiKey}"
|
46
|
+
resp = Net::HTTP.get_response(URI.parse(url))
|
47
|
+
data = JSON.parse(resp.body)
|
48
|
+
return data
|
49
|
+
end
|
50
|
+
|
51
|
+
# *** PUT ***
|
52
|
+
|
53
|
+
#==updateMerchant
|
54
|
+
# Updates an existing Merchant
|
55
|
+
#= Parameters: MerchantId, MerchantHash
|
56
|
+
# MerchantHash format is as follows:
|
57
|
+
# {
|
58
|
+
# "name": "string",
|
59
|
+
# "address": {
|
60
|
+
# "street_number": "string",
|
61
|
+
# "street_name": "string",
|
62
|
+
# "city": "string",
|
63
|
+
# "state": "string",
|
64
|
+
# "zip": "string",
|
65
|
+
# },
|
66
|
+
# "geocode": {
|
67
|
+
# "lat": 0,
|
68
|
+
# "lng": 0,
|
69
|
+
# }
|
70
|
+
# }
|
71
|
+
# Returns http response code
|
72
|
+
|
73
|
+
def self.updateMerchant(merchId, merchant)
|
74
|
+
merchantToUpdate = merchant.to_json
|
75
|
+
url = "#{self.urlWithEntity}/#{merchId}?key=#{self.apiKey}"
|
76
|
+
uri = URI.parse(url)
|
77
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
78
|
+
key = "?key=#{self.apiKey}"
|
79
|
+
request = Net::HTTP::Put.new(uri.path+key, initheader = {'Content-Type' =>'application/json'})
|
80
|
+
request.body = merchantToUpdate
|
81
|
+
response = http.request(request)
|
82
|
+
return JSON.parse(response.body)
|
83
|
+
end
|
84
|
+
|
85
|
+
# *** POST ***
|
86
|
+
|
87
|
+
#==createMerchant
|
88
|
+
# Creates a new Merchant
|
89
|
+
#= Parameters: MerchantHash
|
90
|
+
# MerchantHash format is as follows:
|
91
|
+
# {
|
92
|
+
# "name": "string",
|
93
|
+
# "address": {
|
94
|
+
# "street_number": "string",
|
95
|
+
# "street_name": "string",
|
96
|
+
# "city": "string",
|
97
|
+
# "state": "string",
|
98
|
+
# "zip": "string",
|
99
|
+
# },
|
100
|
+
# "geocode": {
|
101
|
+
# "lat": 0,
|
102
|
+
# "lng": 0,
|
103
|
+
# }
|
104
|
+
# }
|
105
|
+
# Returns http response code
|
106
|
+
|
107
|
+
def self.createMerchant(merchant)
|
108
|
+
merchantToCreate = merchant.to_json
|
109
|
+
url = "#{self.urlWithEntity}/?key=#{self.apiKey}"
|
110
|
+
uri = URI.parse(url)
|
111
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
112
|
+
request = Net::HTTP::Post.new(uri.request_uri, initheader = {'Content-Type' => 'application/json'})
|
113
|
+
request.body = merchantToCreate
|
114
|
+
resp = http.request(request)
|
115
|
+
data = JSON.parse(resp.body)
|
116
|
+
end
|
117
|
+
|
118
118
|
end
|