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 +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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db36793ee044270553fdf245f7d1f362f2611a82
|
4
|
+
data.tar.gz: 07c1c5ce42f21642dab1a46752a8e1a0f45f266a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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/
|
30
|
-
require 'capital_one/
|
31
|
-
require 'capital_one/
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
the
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
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
|
data/lib/capital_one/account.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
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
|
data/lib/capital_one/atm.rb
CHANGED
@@ -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
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
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
|
+
|
data/lib/capital_one/bill.rb
CHANGED
@@ -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.
|
12
|
-
return Config.baseUrl
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.
|
16
|
-
return Config.
|
17
|
-
end
|
18
|
-
|
19
|
-
|
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
|
-
|
80
|
-
key =
|
81
|
-
request
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
#
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
request =
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
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
|