regaliator 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +16 -0
- data/.ruby-version +1 -0
- data/Gemfile +4 -0
- data/Guardfile +36 -0
- data/LICENSE.txt +22 -0
- data/README.md +116 -0
- data/Rakefile +11 -0
- data/lib/regaliator/api_version_error.rb +7 -0
- data/lib/regaliator/client.rb +9 -0
- data/lib/regaliator/configuration.rb +25 -0
- data/lib/regaliator/endpoint.rb +17 -0
- data/lib/regaliator/request.rb +100 -0
- data/lib/regaliator/response.rb +40 -0
- data/lib/regaliator/v15/account.rb +11 -0
- data/lib/regaliator/v15/bill.rb +23 -0
- data/lib/regaliator/v15/biller.rb +15 -0
- data/lib/regaliator/v15/client.rb +32 -0
- data/lib/regaliator/v15/rate.rb +15 -0
- data/lib/regaliator/v15/transaction.rb +23 -0
- data/lib/regaliator/v15.rb +7 -0
- data/lib/regaliator/v30/account.rb +11 -0
- data/lib/regaliator/v30/bill.rb +35 -0
- data/lib/regaliator/v30/biller.rb +19 -0
- data/lib/regaliator/v30/client.rb +32 -0
- data/lib/regaliator/v30/rate.rb +15 -0
- data/lib/regaliator/v30/transaction.rb +11 -0
- data/lib/regaliator/v30.rb +7 -0
- data/lib/regaliator/v31.rb +14 -0
- data/lib/regaliator/version.rb +3 -0
- data/lib/regaliator.rb +59 -0
- data/regaliator.gemspec +34 -0
- data/test/fixtures/vcr_cassettes/V31/account/failed_info.yml +48 -0
- data/test/fixtures/vcr_cassettes/V31/account/successful_info.yml +50 -0
- data/test/fixtures/vcr_cassettes/V31/bill/create.yml +52 -0
- data/test/fixtures/vcr_cassettes/V31/bill/list.yml +71 -0
- data/test/fixtures/vcr_cassettes/V31/bill/pay.yml +52 -0
- data/test/fixtures/vcr_cassettes/V31/bill/refresh.yml +52 -0
- data/test/fixtures/vcr_cassettes/V31/bill/show.yml +51 -0
- data/test/fixtures/vcr_cassettes/V31/bill/update.yml +53 -0
- data/test/fixtures/vcr_cassettes/V31/bill/xdata.yml +51 -0
- data/test/fixtures/vcr_cassettes/V31/biller/credentials.yml +256 -0
- data/test/fixtures/vcr_cassettes/V31/biller/topups.yml +209 -0
- data/test/fixtures/vcr_cassettes/V31/biller/utilities.yml +611 -0
- data/test/fixtures/vcr_cassettes/V31/rate/history.yml +50 -0
- data/test/fixtures/vcr_cassettes/V31/rate/list.yml +50 -0
- data/test/fixtures/vcr_cassettes/V31/transaction/list.yml +52 -0
- data/test/fixtures/vcr_cassettes/V31/transaction/search.yml +52 -0
- data/test/fixtures/vcr_cassettes/v15/account/failed_info.yml +50 -0
- data/test/fixtures/vcr_cassettes/v15/account/successful_info.yml +52 -0
- data/test/fixtures/vcr_cassettes/v15/bill/check.yml +52 -0
- data/test/fixtures/vcr_cassettes/v15/bill/consult.yml +52 -0
- data/test/fixtures/vcr_cassettes/v15/bill/index.yml +176 -0
- data/test/fixtures/vcr_cassettes/v15/bill/pay.yml +52 -0
- data/test/fixtures/vcr_cassettes/v15/biller/topups.yml +212 -0
- data/test/fixtures/vcr_cassettes/v15/biller/utilities.yml +611 -0
- data/test/fixtures/vcr_cassettes/v15/rate/history.yml +52 -0
- data/test/fixtures/vcr_cassettes/v15/rate/list.yml +52 -0
- data/test/fixtures/vcr_cassettes/v15/transaction/cancel.yml +52 -0
- data/test/fixtures/vcr_cassettes/v15/transaction/list.yml +54 -0
- data/test/fixtures/vcr_cassettes/v15/transaction/pay.yml +52 -0
- data/test/fixtures/vcr_cassettes/v15/transaction/reverse.yml +52 -0
- data/test/fixtures/vcr_cassettes/v15/transaction/search.yml +54 -0
- data/test/fixtures/vcr_cassettes/v30/account/failed_info.yml +48 -0
- data/test/fixtures/vcr_cassettes/v30/account/successful_info.yml +50 -0
- data/test/fixtures/vcr_cassettes/v30/bill/create.yml +56 -0
- data/test/fixtures/vcr_cassettes/v30/bill/list.yml +54 -0
- data/test/fixtures/vcr_cassettes/v30/bill/pay.yml +56 -0
- data/test/fixtures/vcr_cassettes/v30/bill/refresh.yml +56 -0
- data/test/fixtures/vcr_cassettes/v30/bill/show.yml +55 -0
- data/test/fixtures/vcr_cassettes/v30/bill/update.yml +57 -0
- data/test/fixtures/vcr_cassettes/v30/bill/xdata.yml +50 -0
- data/test/fixtures/vcr_cassettes/v30/biller/credentials.yml +54 -0
- data/test/fixtures/vcr_cassettes/v30/biller/topups.yml +54 -0
- data/test/fixtures/vcr_cassettes/v30/biller/utilities.yml +54 -0
- data/test/fixtures/vcr_cassettes/v30/rate/history.yml +54 -0
- data/test/fixtures/vcr_cassettes/v30/rate/list.yml +54 -0
- data/test/fixtures/vcr_cassettes/v30/transaction/list.yml +56 -0
- data/test/fixtures/vcr_cassettes/v30/transaction/search.yml +56 -0
- data/test/regaliator/api_version_error_test.rb +14 -0
- data/test/regaliator/client_test.rb +19 -0
- data/test/regaliator/configuration_test.rb +115 -0
- data/test/regaliator/endpoint_test.rb +19 -0
- data/test/regaliator/v15/account_test.rb +37 -0
- data/test/regaliator/v15/bill_test.rb +67 -0
- data/test/regaliator/v15/biller_test.rb +35 -0
- data/test/regaliator/v15/client_test.rb +23 -0
- data/test/regaliator/v15/rate_test.rb +35 -0
- data/test/regaliator/v15/transaction_test.rb +62 -0
- data/test/regaliator/v15_test.rb +10 -0
- data/test/regaliator/v30/account_test.rb +37 -0
- data/test/regaliator/v30/bill_test.rb +80 -0
- data/test/regaliator/v30/biller_test.rb +44 -0
- data/test/regaliator/v30/client_test.rb +23 -0
- data/test/regaliator/v30/rate_test.rb +35 -0
- data/test/regaliator/v30/transaction_test.rb +35 -0
- data/test/regaliator/v30_test.rb +10 -0
- data/test/regaliator/v31/account_test.rb +37 -0
- data/test/regaliator/v31/bill_test.rb +84 -0
- data/test/regaliator/v31/biller_test.rb +44 -0
- data/test/regaliator/v31/client_test.rb +23 -0
- data/test/regaliator/v31/rate_test.rb +35 -0
- data/test/regaliator/v31/transaction_test.rb +35 -0
- data/test/regaliator/v31_test.rb +10 -0
- data/test/regaliator/version_test.rb +10 -0
- data/test/regaliator_test.rb +66 -0
- data/test/test_helper.rb +26 -0
- metadata +394 -0
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Regaliator
|
4
|
+
module V15
|
5
|
+
class AccountTest < Minitest::Test
|
6
|
+
def setup
|
7
|
+
@config = Configuration.new.tap do |config|
|
8
|
+
config.version = API_VERSION
|
9
|
+
config.api_key = 'testing'
|
10
|
+
config.secret_key = 'testing'
|
11
|
+
config.host = 'api.regalii.dev'
|
12
|
+
config.use_ssl = false
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_successful_info
|
17
|
+
VCR.use_cassette('v15/account/successful_info') do |cassette|
|
18
|
+
response = Regaliator.new(@config).account.info
|
19
|
+
|
20
|
+
assert response.success?
|
21
|
+
assert_equal extract_hsh(cassette), response.data
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_failed_info
|
26
|
+
@config.secret_key = 'bogus'
|
27
|
+
|
28
|
+
VCR.use_cassette('v15/account/failed_info') do |cassette|
|
29
|
+
response = Regaliator.new(@config).account.info
|
30
|
+
|
31
|
+
refute response.success?
|
32
|
+
assert_equal extract_hsh(cassette), response.data
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Regaliator
|
4
|
+
module V15
|
5
|
+
class BillTest < Minitest::Test
|
6
|
+
def setup
|
7
|
+
@config = Configuration.new.tap do |config|
|
8
|
+
config.version = API_VERSION
|
9
|
+
config.api_key = 'testing'
|
10
|
+
config.secret_key = 'testing'
|
11
|
+
config.host = 'api.regalii.dev'
|
12
|
+
config.use_ssl = false
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_index
|
17
|
+
VCR.use_cassette('v15/bill/index') do |cassette|
|
18
|
+
response = Regaliator.new(@config).bill.index
|
19
|
+
|
20
|
+
assert response.success?
|
21
|
+
assert_equal extract_hsh(cassette), response.data
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_consult
|
26
|
+
VCR.use_cassette('v15/bill/consult') do |cassette|
|
27
|
+
response = Regaliator.new(@config).bill.consult(
|
28
|
+
biller_id: 14,
|
29
|
+
account_number: '6463060086',
|
30
|
+
user_id: 12981
|
31
|
+
)
|
32
|
+
|
33
|
+
assert response.success?
|
34
|
+
assert_equal extract_hsh(cassette), response.data
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_pay
|
39
|
+
VCR.use_cassette('v15/bill/pay') do |cassette|
|
40
|
+
response = Regaliator.new(@config).bill.pay(
|
41
|
+
biller_id: 14,
|
42
|
+
account_number: '6463060086',
|
43
|
+
user_id: 12981,
|
44
|
+
amount: 99,
|
45
|
+
currency: 'DOP'
|
46
|
+
)
|
47
|
+
|
48
|
+
assert response.success?
|
49
|
+
assert_equal extract_hsh(cassette), response.data
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_check
|
54
|
+
VCR.use_cassette('v15/bill/check') do |cassette|
|
55
|
+
response = Regaliator.new(@config).bill.check(
|
56
|
+
biller_id: 9,
|
57
|
+
account_number: '6463060086',
|
58
|
+
amount: 50
|
59
|
+
)
|
60
|
+
|
61
|
+
assert response.success?
|
62
|
+
assert_equal extract_hsh(cassette), response.data
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Regaliator
|
4
|
+
module V15
|
5
|
+
class BillerTest < Minitest::Test
|
6
|
+
def setup
|
7
|
+
@config = Configuration.new.tap do |config|
|
8
|
+
config.version = API_VERSION
|
9
|
+
config.api_key = 'testing'
|
10
|
+
config.secret_key = 'testing'
|
11
|
+
config.host = 'api.regalii.dev'
|
12
|
+
config.use_ssl = false
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_list_topups
|
17
|
+
VCR.use_cassette('v15/biller/topups') do |cassette|
|
18
|
+
response = Regaliator.new(@config).biller.topups
|
19
|
+
|
20
|
+
assert response.success?
|
21
|
+
assert_equal extract_hsh(cassette), response.data
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_list_utilities
|
26
|
+
VCR.use_cassette('v15/biller/utilities') do |cassette|
|
27
|
+
response = Regaliator.new(@config).biller.utilities
|
28
|
+
|
29
|
+
assert response.success?
|
30
|
+
assert_equal extract_hsh(cassette), response.data
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Regaliator
|
4
|
+
module V15
|
5
|
+
class ClientTest < Minitest::Test
|
6
|
+
def setup
|
7
|
+
@config = Configuration.new
|
8
|
+
@subject = Client.new(@config)
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_versioned_client_inherits_from_client
|
12
|
+
assert_operator V15::Client, :<, Regaliator::Client
|
13
|
+
end
|
14
|
+
|
15
|
+
%i(account bill biller rate transaction).each do |endpoint|
|
16
|
+
define_method("test_#{endpoint}_method_returns_#{endpoint}_instance") do
|
17
|
+
klass = "::Regaliator::V15::#{endpoint.capitalize}"
|
18
|
+
assert_instance_of Kernel.const_get(klass), @subject.send(endpoint)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Regaliator
|
4
|
+
module V15
|
5
|
+
class RateTest < Minitest::Test
|
6
|
+
def setup
|
7
|
+
@config = Configuration.new.tap do |config|
|
8
|
+
config.version = API_VERSION
|
9
|
+
config.api_key = 'testing'
|
10
|
+
config.secret_key = 'testing'
|
11
|
+
config.host = 'api.regalii.dev'
|
12
|
+
config.use_ssl = false
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_list
|
17
|
+
VCR.use_cassette('v15/rate/list') do |cassette|
|
18
|
+
response = Regaliator.new(@config).rate.list
|
19
|
+
|
20
|
+
assert response.success?
|
21
|
+
assert_equal extract_hsh(cassette), response.data
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_history
|
26
|
+
VCR.use_cassette('v15/rate/history') do |cassette|
|
27
|
+
response = Regaliator.new(@config).rate.history
|
28
|
+
|
29
|
+
assert response.success?
|
30
|
+
assert_equal extract_hsh(cassette), response.data
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Regaliator
|
4
|
+
module V15
|
5
|
+
class TransactionTest < Minitest::Test
|
6
|
+
def setup
|
7
|
+
@config = Configuration.new.tap do |config|
|
8
|
+
config.version = API_VERSION
|
9
|
+
config.api_key = 'testing'
|
10
|
+
config.secret_key = 'testing'
|
11
|
+
config.host = 'api.regalii.dev'
|
12
|
+
config.use_ssl = false
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_list
|
17
|
+
VCR.use_cassette('v15/transaction/list') do |cassette|
|
18
|
+
response = Regaliator.new(@config).transaction.list
|
19
|
+
|
20
|
+
assert response.success?
|
21
|
+
assert_equal extract_hsh(cassette), response.data
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_with_search
|
26
|
+
VCR.use_cassette('v15/transaction/search') do |cassette|
|
27
|
+
response = Regaliator.new(@config).transaction.list('q[id_eq]' => 1)
|
28
|
+
|
29
|
+
assert response.success?
|
30
|
+
assert_equal extract_hsh(cassette), response.data
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_pay
|
35
|
+
VCR.use_cassette('v15/transaction/pay') do |cassette|
|
36
|
+
response = Regaliator.new(@config).transaction.pay(id: 1)
|
37
|
+
|
38
|
+
assert response.success?
|
39
|
+
assert_equal extract_hsh(cassette), response.data
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_reverse
|
44
|
+
VCR.use_cassette('v15/transaction/reverse') do |cassette|
|
45
|
+
response = Regaliator.new(@config).transaction.reverse(id: 1)
|
46
|
+
|
47
|
+
assert response.success?
|
48
|
+
assert_equal extract_hsh(cassette), response.data
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_cancel
|
53
|
+
VCR.use_cassette('v15/transaction/cancel') do |cassette|
|
54
|
+
response = Regaliator.new(@config).transaction.cancel(id: 1)
|
55
|
+
|
56
|
+
assert response.success?
|
57
|
+
assert_equal extract_hsh(cassette), response.data
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Regaliator
|
4
|
+
module V30
|
5
|
+
class AccountTest < Minitest::Test
|
6
|
+
def setup
|
7
|
+
@config = Configuration.new.tap do |config|
|
8
|
+
config.version = API_VERSION
|
9
|
+
config.api_key = 'testing'
|
10
|
+
config.secret_key = 'testing'
|
11
|
+
config.host = 'api.regalii.dev'
|
12
|
+
config.use_ssl = false
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_successful_info
|
17
|
+
VCR.use_cassette('v30/account/successful_info') do |cassette|
|
18
|
+
response = Regaliator.new(@config).account.info
|
19
|
+
|
20
|
+
assert response.success?
|
21
|
+
assert_equal extract_hsh(cassette), response.data
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_failed_info
|
26
|
+
@config.secret_key = 'bogus'
|
27
|
+
|
28
|
+
VCR.use_cassette('v30/account/failed_info') do |cassette|
|
29
|
+
response = Regaliator.new(@config).account.info
|
30
|
+
|
31
|
+
refute response.success?
|
32
|
+
assert_equal extract_hsh(cassette), response.data
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Regaliator
|
4
|
+
module V30
|
5
|
+
class BillTest < Minitest::Test
|
6
|
+
def setup
|
7
|
+
@config = Configuration.new.tap do |config|
|
8
|
+
config.version = API_VERSION
|
9
|
+
config.api_key = 'api-key'
|
10
|
+
config.secret_key = 'secret-key'
|
11
|
+
config.host = 'api.regalii.dev'
|
12
|
+
config.use_ssl = false
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_create
|
17
|
+
VCR.use_cassette('v30/bill/create') do |cassette|
|
18
|
+
response = Regaliator.new(@config).bill.create(biller_id: 2, account_number: '8081969')
|
19
|
+
|
20
|
+
assert response.success?
|
21
|
+
assert_equal extract_hsh(cassette), response.data
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_update
|
26
|
+
VCR.use_cassette('v30/bill/update') do |cassette|
|
27
|
+
response = Regaliator.new(@config).bill.update(5, name_on_account: 'Test name')
|
28
|
+
|
29
|
+
assert response.success?
|
30
|
+
assert_equal extract_hsh(cassette), response.data
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_show
|
35
|
+
VCR.use_cassette('v30/bill/show') do |cassette|
|
36
|
+
response = Regaliator.new(@config).bill.show(5)
|
37
|
+
|
38
|
+
assert response.success?
|
39
|
+
assert_equal extract_hsh(cassette), response.data
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_xdata
|
44
|
+
VCR.use_cassette('v30/bill/xdata') do |cassette|
|
45
|
+
response = Regaliator.new(@config).bill.xdata(674101)
|
46
|
+
|
47
|
+
assert response.success?
|
48
|
+
assert_equal extract_hsh(cassette), response.data
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_refresh
|
53
|
+
VCR.use_cassette('v30/bill/refresh') do |cassette|
|
54
|
+
response = Regaliator.new(@config).bill.refresh(5)
|
55
|
+
|
56
|
+
assert response.success?
|
57
|
+
assert_equal extract_hsh(cassette), response.data
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_pay
|
62
|
+
VCR.use_cassette('v30/bill/pay') do |cassette|
|
63
|
+
response = Regaliator.new(@config).bill.pay(5, amount: 758.0, currency: 'RD')
|
64
|
+
|
65
|
+
assert response.success?
|
66
|
+
assert_equal extract_hsh(cassette), response.data
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_list
|
71
|
+
VCR.use_cassette('v30/bill/list') do
|
72
|
+
response = Regaliator.new(@config).bill.list
|
73
|
+
|
74
|
+
assert response.success?
|
75
|
+
assert_equal response.data['bills'].size, 1
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Regaliator
|
4
|
+
module V30
|
5
|
+
class BillerTest < Minitest::Test
|
6
|
+
def setup
|
7
|
+
@config = Configuration.new.tap do |config|
|
8
|
+
config.version = API_VERSION
|
9
|
+
config.api_key = 'api-key'
|
10
|
+
config.secret_key = 'secret-key'
|
11
|
+
config.host = 'api.regalii.dev'
|
12
|
+
config.use_ssl = false
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_list_credentials
|
17
|
+
VCR.use_cassette('v30/biller/credentials') do |cassette|
|
18
|
+
response = Regaliator.new(@config).biller.credentials
|
19
|
+
|
20
|
+
assert response.success?
|
21
|
+
assert_equal extract_hsh(cassette), response.data
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_list_topups
|
26
|
+
VCR.use_cassette('v30/biller/topups') do |cassette|
|
27
|
+
response = Regaliator.new(@config).biller.topups
|
28
|
+
|
29
|
+
assert response.success?
|
30
|
+
assert_equal extract_hsh(cassette), response.data
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_list_utilities
|
35
|
+
VCR.use_cassette('v30/biller/utilities') do |cassette|
|
36
|
+
response = Regaliator.new(@config).biller.utilities
|
37
|
+
|
38
|
+
assert response.success?
|
39
|
+
assert_equal extract_hsh(cassette), response.data
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Regaliator
|
4
|
+
module V30
|
5
|
+
class ClientTest < Minitest::Test
|
6
|
+
def setup
|
7
|
+
@config = Configuration.new
|
8
|
+
@subject = Client.new(@config)
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_versioned_client_inherits_from_client
|
12
|
+
assert_operator V30::Client, :<, Regaliator::Client
|
13
|
+
end
|
14
|
+
|
15
|
+
%i(account bill biller rate transaction).each do |endpoint|
|
16
|
+
define_method("test_#{endpoint}_method_returns_#{endpoint}_instance") do
|
17
|
+
klass = "::Regaliator::V30::#{endpoint.capitalize}"
|
18
|
+
assert_instance_of Kernel.const_get(klass), @subject.send(endpoint)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Regaliator
|
4
|
+
module V30
|
5
|
+
class RateTest < Minitest::Test
|
6
|
+
def setup
|
7
|
+
@config = Configuration.new.tap do |config|
|
8
|
+
config.version = API_VERSION
|
9
|
+
config.api_key = 'api-key'
|
10
|
+
config.secret_key = 'secret-key'
|
11
|
+
config.host = 'api.regalii.dev'
|
12
|
+
config.use_ssl = false
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_list
|
17
|
+
VCR.use_cassette('v30/rate/list') do |cassette|
|
18
|
+
response = Regaliator.new(@config).rate.list
|
19
|
+
|
20
|
+
assert response.success?
|
21
|
+
assert_equal extract_hsh(cassette), response.data
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_history
|
26
|
+
VCR.use_cassette('v30/rate/history') do |cassette|
|
27
|
+
response = Regaliator.new(@config).rate.history
|
28
|
+
|
29
|
+
assert response.success?
|
30
|
+
assert_equal extract_hsh(cassette), response.data
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Regaliator
|
4
|
+
module V30
|
5
|
+
class TransactionTest < Minitest::Test
|
6
|
+
def setup
|
7
|
+
@config = Configuration.new.tap do |config|
|
8
|
+
config.version = API_VERSION
|
9
|
+
config.api_key = 'api-key'
|
10
|
+
config.secret_key = 'secret-key'
|
11
|
+
config.host = 'api.regalii.dev'
|
12
|
+
config.use_ssl = false
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_list
|
17
|
+
VCR.use_cassette('v30/transaction/list') do |cassette|
|
18
|
+
response = Regaliator.new(@config).transaction.list
|
19
|
+
|
20
|
+
assert response.success?
|
21
|
+
assert_equal extract_hsh(cassette), response.data
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_with_search
|
26
|
+
VCR.use_cassette('v30/transaction/search') do |cassette|
|
27
|
+
response = Regaliator.new(@config).transaction.list('q[id_eq]' => 1)
|
28
|
+
|
29
|
+
assert response.success?
|
30
|
+
assert_equal extract_hsh(cassette), response.data
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Regaliator
|
4
|
+
module V31
|
5
|
+
class AccountTest < Minitest::Test
|
6
|
+
def setup
|
7
|
+
@config = Configuration.new.tap do |config|
|
8
|
+
config.version = API_VERSION
|
9
|
+
config.api_key = 'testing'
|
10
|
+
config.secret_key = 'testing'
|
11
|
+
config.host = 'api.regalii.dev'
|
12
|
+
config.use_ssl = false
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_successful_info
|
17
|
+
VCR.use_cassette('V31/account/successful_info') do |cassette|
|
18
|
+
response = Regaliator.new(@config).account.info
|
19
|
+
|
20
|
+
assert response.success?
|
21
|
+
assert_equal extract_hsh(cassette), response.data
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_failed_info
|
26
|
+
@config.secret_key = 'bogus'
|
27
|
+
|
28
|
+
VCR.use_cassette('V31/account/failed_info') do |cassette|
|
29
|
+
response = Regaliator.new(@config).account.info
|
30
|
+
|
31
|
+
refute response.success?
|
32
|
+
assert_equal extract_hsh(cassette), response.data
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Regaliator
|
4
|
+
module V31
|
5
|
+
class BillTest < Minitest::Test
|
6
|
+
def setup
|
7
|
+
@config = Configuration.new.tap do |config|
|
8
|
+
config.version = API_VERSION
|
9
|
+
config.api_key = 'testing'
|
10
|
+
config.secret_key = 'testing'
|
11
|
+
config.host = 'api.regalii.dev'
|
12
|
+
config.use_ssl = false
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_create
|
17
|
+
VCR.use_cassette('V31/bill/create') do |cassette|
|
18
|
+
response = Regaliator.new(@config).bill.create(biller_id: 2, account_number: '8081969')
|
19
|
+
|
20
|
+
assert response.success?
|
21
|
+
assert_equal extract_hsh(cassette), response.data
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_update
|
26
|
+
VCR.use_cassette('V31/bill/update') do |cassette|
|
27
|
+
response = Regaliator.new(@config).bill.update(695109, name_on_account: 'Test name')
|
28
|
+
|
29
|
+
assert response.success?
|
30
|
+
assert_equal extract_hsh(cassette), response.data
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_show
|
35
|
+
VCR.use_cassette('V31/bill/show') do |cassette|
|
36
|
+
response = Regaliator.new(@config).bill.show(695109)
|
37
|
+
|
38
|
+
assert response.success?
|
39
|
+
assert_equal extract_hsh(cassette), response.data
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_xdata
|
44
|
+
VCR.use_cassette('V31/bill/xdata') do |cassette|
|
45
|
+
response = Regaliator.new(@config).bill.xdata(695109)
|
46
|
+
|
47
|
+
assert response.success?
|
48
|
+
assert_equal extract_hsh(cassette), response.data
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_refresh
|
53
|
+
VCR.use_cassette('V31/bill/refresh') do |cassette|
|
54
|
+
response = Regaliator.new(@config).bill.refresh(695109)
|
55
|
+
|
56
|
+
assert response.success?
|
57
|
+
assert_equal extract_hsh(cassette), response.data
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_pay
|
62
|
+
VCR.use_cassette('V31/bill/pay') do |cassette|
|
63
|
+
response = Regaliator.new(@config).bill.pay(695109,
|
64
|
+
amount: 758.0,
|
65
|
+
currency: 'RD',
|
66
|
+
user_id: 12981
|
67
|
+
)
|
68
|
+
|
69
|
+
assert response.success?
|
70
|
+
assert_equal extract_hsh(cassette), response.data
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_list
|
75
|
+
VCR.use_cassette('V31/bill/list') do
|
76
|
+
response = Regaliator.new(@config).bill.list
|
77
|
+
|
78
|
+
assert response.success?
|
79
|
+
assert_equal 100, response.data['bills'].size
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|