capital_one 0.3.0 → 0.4.0

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: cbc2f9909981e3e6c28c5ffedaf019df1b8c8331
4
- data.tar.gz: 3324bd1688e85d433110080cec4144850fa5ea6a
3
+ metadata.gz: db36793ee044270553fdf245f7d1f362f2611a82
4
+ data.tar.gz: 07c1c5ce42f21642dab1a46752a8e1a0f45f266a
5
5
  SHA512:
6
- metadata.gz: 4a19f6ee7e419509ae32fce8b96128585886fb257c4bc81f9a217400cc07efe9e66add806674a1e5a69aff3de3f94a28af3bbbf160d03d5182763c6642755a2b
7
- data.tar.gz: c9d75359a81e350be15e5497d5dfda449330d0ab2f6f6d3c5eb8e540666759291a4401585401313032fa3f0baaa67e8872aa37fde8959f1947aa02ad5c0a4239
6
+ metadata.gz: 19efc14f69d99863956df6fc596d80798049a260948f431e7ee1017b6ff5cdb5818bc1704619510c0bd934aa7f85f164c2835c61b3a5cc95d39fafdab217d056
7
+ data.tar.gz: 63fffc1566312deec7e8e9b4eefcd6f632a796471a4a124223adbdb8ed928ffe82538e2d9697bf1a601c32962c911df19d1fb315cd5a3b700da32409f86f2b63
data/lib/capital_one.rb CHANGED
@@ -1,55 +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/transaction'
30
- require 'capital_one/withdrawal'
31
- require 'capital_one/deposit'
32
-
33
- =begin
34
-
35
- ==Important Info
36
-
37
- Depending on the access level/type of API key supplied, some of
38
- these methods will return 403 error codes(forbidden). Enterprise level
39
- API keys have access to any/all of the GET requests, but nothing else.
40
- Customer level API keys have access to GET, POST, PUT, and DELETE, but only
41
- for valid accounts which are associated with the customer API key.
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
-
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.nessiebanking.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
+
55
58
  =end
@@ -1,107 +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:
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
- #== getOne
39
- #Returns the account specified by it's account ID.
40
- #=Parameters:
41
- #Accepts a string of the account ID.
42
- #Returns a hash with the account info.
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
- #== getAllByCustomerId
49
- #Returns all accounts associated with a given customer ID
50
- #as an array of hashes.
51
-
52
- def self.getAllByCustomerId(customerId)
53
- url = "#{self.url}/customers/#{customerId}/accounts?key=#{self.apiKey}"
54
- resp = Net::HTTP.get_response(URI.parse(url))
55
- data = JSON.parse(resp.body)
56
- end
57
-
58
-
59
- # *** PUT ***
60
- #==updateAccount
61
- #Updates an account's nickname.
62
- #Parameters: AccountID, AccountHash
63
- #Returns the http response code.
64
- def self.updateAccount(accountId, account)
65
- accountToUpdate = account.to_json
66
- url = "#{self.urlWithEntity}/#{accountId}?key=#{self.apiKey}"
67
- uri = URI.parse(url)
68
- http = Net::HTTP.new(uri.host, uri.port)
69
- key = "?key=#{self.apiKey}"
70
- request = Net::HTTP::Put.new(uri.path+key, initheader = {'Content-Type' =>'application/json'})
71
- request.body = accountToUpdate
72
- response = http.request(request)
73
- return JSON.parse(response.body)
74
- end
75
-
76
-
77
- # *** POST ***
78
- #==createAccount
79
- #Creates a new account
80
- #Parameters: CustomerID, accountHash
81
- #Returns the http response code.
82
- def self.createAccount(custID, account)
83
- accountToCreate = account.to_json
84
- url = "#{self.url}/customers/#{custID}/accounts?key=#{self.apiKey}"
85
- uri = URI.parse(url)
86
- http = Net::HTTP.new(uri.host, uri.port)
87
- request = Net::HTTP::Post.new(uri.request_uri, initheader = {'Content-Type' =>'application/json'})
88
- request.body = accountToCreate
89
- response = http.request(request)
90
- return JSON.parse(response.body)
91
- end
92
-
93
-
94
- # *** DELETE ***
95
- #==deleteAccount
96
- #delete a given account by accountId.
97
- #Parameters: AccountId.
98
- #Returns the http response code.
99
- def self.deleteAccount(accountId)
100
- url = "#{self.urlWithEntity}/#{accountId}?key=#{self.apiKey}"
101
- uri = URI.parse(url)
102
- http = Net::HTTP.new(uri.host, uri.port)
103
- key="?key=#{self.apiKey}"
104
- request = Net::HTTP::Delete.new(uri.path+key)
105
- response = http.request(request)
106
- end
107
- 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,43 +1,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
- #==getAll
17
- #Returns all ATMs as an array of hashes.
18
-
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
- 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
33
-
34
- #==getOne
35
- #Parameters: ATMid
36
- #Returns the ATM that has the given ID.
37
- def self.getOne(id)
38
- url = "#{self.urlWithEntity}/#{id}?key=#{self.apiKey}"
39
- resp = Net::HTTP.get_response(URI.parse(url))
40
- data = JSON.parse(resp.body)
41
- end
42
- end
43
-
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,125 +1,124 @@
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.url
12
- return Config.baseUrl
13
- end
14
-
15
- def self.apiKey
16
- return Config.apiKey
17
- end
18
-
19
- # *** GET ***
20
-
21
- #==getAllByCustomerId
22
- # Get all bills for a specific customer
23
- #Parameters: customerId
24
- #Returns the customer as a hash array.
25
- def self.getAllByCustomerId(customerId)
26
- url = "#{self.customerBaseUrl}/#{customerId}/bills?key=#{self.apiKey}"
27
- response = Net::HTTP.get_response(URI.parse(url))
28
- return JSON.parse(response.body)
29
- end
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
35
- def self.getOneByCustomerIdBillId(customerId, billId)
36
- url = "#{self.customerBaseUrl}/#{customerId}/bills/#{billId}?key=#{self.apiKey}"
37
- resp = Net::HTTP.get_response(URI.parse(url))
38
- data = JSON.parse(resp.body)
39
- end
40
-
41
- #==getAllByAccountId
42
- #Get all bills for a specific account
43
- #Parameters: accountId
44
- #Returns an array of hashes containing the bills.
45
- def self.getAllByAccountId(accountId)
46
- url = "#{self.accountBaseUrl}/#{accountId}/bills?key=#{self.apiKey}"
47
- response = Net::HTTP.get_response(URI.parse(url))
48
- return JSON.parse(response.body)
49
- end
50
- #==getOneByAccountIdBillId
51
- #Get a specific bill from a specific account
52
- #Parameters: AccountId, BillId
53
- #Returns a hash array with the bill.
54
- def self.getOneByAccountIdBillId(accountId, billId)
55
- url ="#{self.accountBaseUrl}/#{accountId}/bills/#{billId}?key=#{self.apiKey}"
56
- response = Net::HTTP.get_response(URI.parse(url))
57
- return JSON.parse(response.body)
58
- end
59
-
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.
74
-
75
- def self.updateBill(accountId, billId, bill)
76
- billToUpdate = bill.to_json
77
- url = "#{self.accountBaseUrl}/#{accountId}/bills/#{billId}?key=#{self.apiKey}"
78
- uri = URI.parse(url)
79
- http = Net::HTTP.new(uri.host, uri.port)
80
- key = "?key=#{self.apiKey}"
81
- request = Net::HTTP::Put.new(uri.path+key, initheader = {'Content-Type' =>'application/json'})
82
- request.body = billToUpdate
83
- response = http.request(request)
84
- return JSON.parse(response.body)
85
- end
86
-
87
- # *** POST ***
88
- #==createBill
89
- #create a new bill on an associated account ID
90
- #Parameters: AccountId, BillJson
91
- #Json is as follows:
92
- # {
93
- # "status": "",
94
- # "payee": "",
95
- # "nickname": "",
96
- # "payment_date": "",
97
- # "recurring_date": 0,
98
- # "payment_amount": 0
99
- # }
100
- #Returns http response code.
101
- def self.createBill(accountId, bill)
102
- url = "#{self.accountBaseUrl}/#{accountId}/bills?key=#{self.apiKey}"
103
- uri = URI.parse(url)
104
- http = Net::HTTP.new(uri.host, uri.port)
105
- request = Net::HTTP::Post.new(uri.request_uri, initheader = {'Content-Type' => 'application/json'})
106
- request.body = bill.to_json
107
- response = http.request(request)
108
- return JSON.parse(response.body)
109
- end
110
-
111
-
112
- # *** DELETE ***
113
- #==deleteBill
114
- #delete a bill by id from a given account.
115
- #Parameters: Accountid, billid.
116
- #Returns http response code.
117
- def self.deleteBill(accountId, billId)
118
- url = "#{self.accountBaseUrl}/#{accountId}/bills/#{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
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
125
124
  end