capital_one 0.4.1 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5a1bd14810b458fc3a3033b8ba909952facf6717
4
- data.tar.gz: 39126cc9a598c20fb9357d7e748b506d324f4b68
3
+ metadata.gz: 79386ee43f71bc66ddc6118b14528281dd7c360e
4
+ data.tar.gz: b6c3ccba8d425dd184f318d8f6607640e7489f76
5
5
  SHA512:
6
- metadata.gz: 153b3846c5ac03b829a45d491046ae0090c9735864553763b7ece73329b812dd0e681d2583e98e0358502f94eebdd9c7940dca86c6eae8c75d6353ade435c2e5
7
- data.tar.gz: 0e9129dd776a4a46577f1c0043c59ae3d8be0851f180f8e4d399398554e06ba769f675d613a5215af6204d99b600fdd523675700d9d7798f7e3565e3fd2c9b5b
6
+ metadata.gz: 8b974823364bc825d07363091c26861fdf74ae03ac07912b96e566a7232d521e145f85a7635d3810e2e623fe0c095e84c45f49f661000871a144ac220868bd45
7
+ data.tar.gz: 46b5436b17ec21d48a4a698d99cef85426459010feac6a03434b83c9566090aeeb27e9e72aeec0efb26bde45c5c0fc94140f3ad5c22b4049c51891cd38ddeb03
@@ -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
@@ -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
@@ -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 an array of hashes.
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
- #==getAllByLocation
27
- # Get all ATMs withing a certain radius of a geocoordinate
28
- #= Paremeters: latitude, longitude, radius
29
- # Accepts lat, lng, and rad as floats
30
- # Returns an array of hashes within the radius of the geocoordinate. Each hash has an ATM.
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
- end
37
-
38
- #==getOne
39
- # Gets one ATM for a given ID
40
- # Parameters: AtmId
41
- # Returns the ATM that has the given ID.
42
-
43
- def self.getOne(id)
44
- url = "#{self.urlWithEntity}/#{id}?key=#{self.apiKey}"
45
- resp = Net::HTTP.get_response(URI.parse(url))
46
- data = JSON.parse(resp.body)
47
- end
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
+