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.
@@ -1,124 +1,125 @@
1
- class Bill
2
-
3
- def self.accountBaseUrl
4
- return Config.baseUrl + "/accounts"
5
- end
6
-
7
- def self.customerBaseUrl
8
- return Config.baseUrl + "/customers"
9
- end
10
-
11
- def self.urlWithEntity
12
- return Config.baseUrl + "/bills"
13
- end
14
-
15
- def self.url
16
- return Config.baseUrl
17
- end
18
-
19
- def self.apiKey
20
- return Config.apiKey
21
- end
22
-
23
- # *** GET ***
24
-
25
- #==getAllByAccountId
26
- # Get all bills for a specific account
27
- # Parameters: accountId
28
- # Returns an array of hashes containing the bills.
29
-
30
- def self.getAllByAccountId(accountId)
31
- url = "#{self.accountBaseUrl}/#{accountId}/bills?key=#{self.apiKey}"
32
- response = Net::HTTP.get_response(URI.parse(url))
33
- return JSON.parse(response.body)
34
- end
35
-
36
- #==getAllByCustomerId
37
- # Get all bills for a specific customer
38
- # Parameters: customerId
39
- # Returns the customer as a hash array.
40
-
41
- def self.getAllByCustomerId(customerId)
42
- url = "#{self.customerBaseUrl}/#{customerId}/bills?key=#{self.apiKey}"
43
- response = Net::HTTP.get_response(URI.parse(url))
44
- return JSON.parse(response.body)
45
- end
46
-
47
- #==getOne
48
- # Gets one bill for a specific billId
49
- # Parameters: billId
50
- # Returns a hash with the bill data
51
-
52
- def self.getOne(id)
53
- url = "#{self.urlWithEntity}/#{id}?key=#{self.apiKey}"
54
- response = Net::HTTP.get_response(URI.parse(url))
55
- return JSON.parse(response.body)
56
- end
57
-
58
- # *** POST ***
59
-
60
- #==updateBill
61
- # Updates an account's information by id with given json data.
62
- # Parameters: BillId, BillJson
63
- # Json format is as follows:
64
- # {
65
- # "status": "",
66
- # "payee": "",
67
- # "nickname": "",
68
- # "payment_date": "",
69
- # "recurring_date": 0,
70
- # "payment_amount": 0
71
- # }
72
- # Returns http response code.
73
-
74
- def self.updateBill(billId, bill)
75
- billToUpdate = bill.to_json
76
- url = "#{self.urlWithEntity}/#{billId}?key=#{self.apiKey}"
77
- uri = URI.parse(url)
78
- http = Net::HTTP.new(uri.host, uri.port)
79
- key = "?key=#{self.apiKey}"
80
- request = Net::HTTP::Put.new(uri.path+key, initheader = {'Content-Type' =>'application/json'})
81
- request.body = billToUpdate
82
- response = http.request(request)
83
- return JSON.parse(response.body)
84
- end
85
-
86
- #==createBill
87
- # create a new bill on an associated account ID
88
- # Parameters: AccountId, BillJson
89
- # Json is as follows:
90
- # {
91
- # "status": "",
92
- # "payee": "",
93
- # "nickname": "",
94
- # "payment_date": "",
95
- # "recurring_date": 0,
96
- # "payment_amount": 0
97
- # }
98
- # Returns http response code.
99
-
100
- def self.createBill(accountId, bill)
101
- url = "#{self.accountBaseUrl}/#{accountId}/bills?key=#{self.apiKey}"
102
- uri = URI.parse(url)
103
- http = Net::HTTP.new(uri.host, uri.port)
104
- request = Net::HTTP::Post.new(uri.request_uri, initheader = {'Content-Type' => 'application/json'})
105
- request.body = bill.to_json
106
- response = http.request(request)
107
- return JSON.parse(response.body)
108
- end
109
-
110
-
111
- # *** DELETE ***
112
- #==deleteBill
113
- # delete a bill by its id
114
- # Parameters: BillId
115
- # Returns http response code
116
- def self.deleteBill(billId)
117
- url = "#{self.urlWithEntity}/#{billId}?key=#{self.apiKey}"
118
- uri = URI.parse(url)
119
- http = Net::HTTP.new(uri.host, uri.port)
120
- key="?key=#{self.apiKey}"
121
- request = Net::HTTP::Delete.new(uri.path+key)
122
- response = http.request(request)
123
- end
1
+ class Bill
2
+
3
+ def self.accountBaseUrl
4
+ return Config.baseUrl + "/accounts"
5
+ end
6
+
7
+ def self.customerBaseUrl
8
+ return Config.baseUrl + "/customers"
9
+ end
10
+
11
+ def self.urlWithEntity
12
+ return Config.baseUrl + "/bills"
13
+ end
14
+
15
+ def self.url
16
+ return Config.baseUrl
17
+ end
18
+
19
+ def self.apiKey
20
+ return Config.apiKey
21
+ end
22
+
23
+ # *** GET ***
24
+
25
+ #==getAllByAccountId
26
+ # Get all bills for a specific account
27
+ # Parameters: accountId
28
+ # Returns an array of hashes containing the bills.
29
+
30
+ def self.getAllByAccountId(accountId)
31
+ url = "#{self.accountBaseUrl}/#{accountId}/bills?key=#{self.apiKey}"
32
+ response = Net::HTTP.get_response(URI.parse(url))
33
+ return JSON.parse(response.body)
34
+ end
35
+
36
+ #==getAllByCustomerId
37
+ # Get all bills for a specific customer
38
+ # Parameters: customerId
39
+ # Returns the customer as a hash array.
40
+
41
+ def self.getAllByCustomerId(customerId)
42
+ url = "#{self.customerBaseUrl}/#{customerId}/bills?key=#{self.apiKey}"
43
+ response = Net::HTTP.get_response(URI.parse(url))
44
+ return JSON.parse(response.body)
45
+ end
46
+
47
+ #==getOne
48
+ # Gets one bill for a specific billId
49
+ # Parameters: billId
50
+ # Returns a hash with the bill data
51
+
52
+ def self.getOne(id)
53
+ url = "#{self.urlWithEntity}/#{id}?key=#{self.apiKey}"
54
+ response = Net::HTTP.get_response(URI.parse(url))
55
+ return JSON.parse(response.body)
56
+ end
57
+
58
+ # *** POST ***
59
+
60
+ #==updateBill
61
+ # Updates an account's information by id with given json data.
62
+ # Parameters: BillId, BillJson
63
+ # Json format is as follows:
64
+ # {
65
+ # "status": "",
66
+ # "payee": "",
67
+ # "nickname": "",
68
+ # "payment_date": "",
69
+ # "recurring_date": 0,
70
+ # "payment_amount": 0
71
+ # }
72
+ # Returns http response code.
73
+
74
+ def self.updateBill(billId, bill)
75
+ billToUpdate = bill.to_json
76
+ url = "#{self.urlWithEntity}/#{billId}?key=#{self.apiKey}"
77
+ uri = URI.parse(url)
78
+ http = Net::HTTP.new(uri.host, uri.port)
79
+ key = "?key=#{self.apiKey}"
80
+ request = Net::HTTP::Put.new(uri.path+key, initheader = {'Content-Type' =>'application/json'})
81
+ request.body = billToUpdate
82
+ response = http.request(request)
83
+ return JSON.parse(response.body)
84
+ end
85
+
86
+ #==createBill
87
+ # create a new bill on an associated account ID
88
+ # Parameters: AccountId, BillJson
89
+ # Json is as follows:
90
+ # {
91
+ # "status": "",
92
+ # "payee": "",
93
+ # "nickname": "",
94
+ # "payment_date": "",
95
+ # "recurring_date": 0,
96
+ # "payment_amount": 0
97
+ # }
98
+ # Returns http response code.
99
+
100
+ def self.createBill(accountId, bill)
101
+ url = "#{self.accountBaseUrl}/#{accountId}/bills?key=#{self.apiKey}"
102
+ uri = URI.parse(url)
103
+ http = Net::HTTP.new(uri.host, uri.port)
104
+ request = Net::HTTP::Post.new(uri.request_uri, initheader = {'Content-Type' => 'application/json'})
105
+ request.body = bill.to_json
106
+ response = http.request(request)
107
+ return JSON.parse(response.body)
108
+ end
109
+
110
+
111
+ # *** DELETE ***
112
+ #==deleteBill
113
+ # delete a bill by its id
114
+ # Parameters: BillId
115
+ # Returns http response code
116
+
117
+ def self.deleteBill(billId)
118
+ url = "#{self.urlWithEntity}/#{billId}?key=#{self.apiKey}"
119
+ uri = URI.parse(url)
120
+ http = Net::HTTP.new(uri.host, uri.port)
121
+ key="?key=#{self.apiKey}"
122
+ request = Net::HTTP::Delete.new(uri.path+key)
123
+ response = http.request(request)
124
+ end
124
125
  end
@@ -1,37 +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
- #==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
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
37
37
  end
@@ -1,113 +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
- #== 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
-
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
+
113
113
  end