ebanx 1.3.1 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +4 -1
- data/CONTRIBUTORS +2 -1
- data/README.md +12 -3
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/ebanx.gemspec +1 -1
- data/lib/ebanx.rb +36 -9
- data/lib/ebanx/command/cancel.rb +1 -1
- data/lib/ebanx/command/capture.rb +1 -1
- data/lib/ebanx/command/command.rb +18 -4
- data/lib/ebanx/command/create_merchant_settlement_request.rb +1 -1
- data/lib/ebanx/command/direct.rb +1 -1
- data/lib/ebanx/command/document_balance.rb +1 -1
- data/lib/ebanx/command/edit_merchant_integration_properties.rb +1 -1
- data/lib/ebanx/command/exchange.rb +1 -1
- data/lib/ebanx/command/get_currency_rates.rb +16 -0
- data/lib/ebanx/command/get_merchant_amount_balance_by_country.rb +2 -2
- data/lib/ebanx/command/get_merchant_integration_properties.rb +1 -1
- data/lib/ebanx/command/get_merchant_settlement_extract.rb +2 -2
- data/lib/ebanx/command/get_merchant_settlement_info.rb +1 -1
- data/lib/ebanx/command/get_merchant_settlement_report.rb +16 -0
- data/lib/ebanx/command/get_merchant_settlement_statement.rb +17 -0
- data/lib/ebanx/command/payout_balance.rb +14 -0
- data/lib/ebanx/command/payout_bank_details.rb +14 -0
- data/lib/ebanx/command/payout_banks.rb +14 -0
- data/lib/ebanx/command/payout_cancel.rb +16 -0
- data/lib/ebanx/command/payout_commit.rb +16 -0
- data/lib/ebanx/command/payout_create.rb +24 -0
- data/lib/ebanx/command/payout_retrieve.rb +16 -0
- data/lib/ebanx/command/payout_search.rb +17 -0
- data/lib/ebanx/command/payout_simulate.rb +18 -0
- data/lib/ebanx/command/print.rb +1 -1
- data/lib/ebanx/command/query.rb +1 -1
- data/lib/ebanx/command/refund.rb +1 -1
- data/lib/ebanx/command/refund_or_cancel.rb +1 -1
- data/lib/ebanx/command/request.rb +5 -1
- data/lib/ebanx/command/resend_payment_notification.rb +16 -0
- data/lib/ebanx/command/token.rb +1 -1
- data/lib/ebanx/command/transfer_cancel.rb +16 -0
- data/lib/ebanx/command/transfer_commit.rb +16 -0
- data/lib/ebanx/command/transfer_create.rb +16 -0
- data/lib/ebanx/command/transfer_retrieve.rb +16 -0
- data/lib/ebanx/command/transfer_search.rb +17 -0
- data/lib/ebanx/command/zipcode.rb +1 -1
- data/lib/ebanx/dig.rb +24 -0
- data/lib/ebanx/exception/ebanx_api_exception.rb +9 -0
- data/lib/ebanx/version.rb +1 -1
- data/test/ebanx/cancel_command_test.rb +1 -1
- data/test/ebanx/cancel_payout_command_test.rb +7 -0
- data/test/ebanx/cancel_transfer_command_test.rb +7 -0
- data/test/ebanx/commit_payout_command_test.rb +7 -0
- data/test/ebanx/commit_transfer_command_test.rb +7 -0
- data/test/ebanx/create_merchant_settlement_request_command_test.rb +1 -1
- data/test/ebanx/create_payout_command_test.rb +7 -0
- data/test/ebanx/create_transfer_command_test.rb +12 -0
- data/test/ebanx/direct_command_test.rb +1 -1
- data/test/ebanx/edit_merchant_integration_properties_command_test.rb +1 -1
- data/test/ebanx/get_currency_rates_command_test.rb +16 -0
- data/test/ebanx/get_merchant_amount_balance_by_country_command_test.rb +1 -1
- data/test/ebanx/get_merchant_integration_properties_command_test.rb +1 -1
- data/test/ebanx/get_merchant_settlement_extract_command_test.rb +1 -1
- data/test/ebanx/get_merchant_settlement_info_command_test.rb +1 -1
- data/test/ebanx/get_merchant_settlement_report_command_test.rb +10 -0
- data/test/ebanx/get_merchant_settlement_statement_command_test.rb +10 -0
- data/test/ebanx/payout_bank_details_command_test.rb +8 -0
- data/test/ebanx/payout_banks_command_test.rb +8 -0
- data/test/ebanx/request_command_test.rb +1 -1
- data/test/ebanx/resend_payment_notification_command_test.rb +41 -0
- data/test/ebanx/retrieve_payout_command_test.rb +7 -0
- data/test/ebanx/retrieve_transfer_command_test.rb +7 -0
- data/test/ebanx/search_payout_command_test.rb +7 -0
- data/test/ebanx/search_transfer_command_test.rb +7 -0
- data/test/ebanx/simulate_payout_command_test.rb +13 -0
- data/test/ebanx/zipcode_command_test.rb +1 -1
- data/test/test_helper.rb +3 -3
- metadata +59 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 78377be804e97bc892238ba52fbb5c760dc32ed4
|
|
4
|
+
data.tar.gz: d69594b94e9a241a78dfcf5bdf2702c9b25dc6a6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ac1d9850eb55b10958699f8af45dd48ba06e3da85d9da120ee2fd02819aeb9a716518c304427eac7aab0aee6a799864fae78d23532e72b35a05c22f3d6c90a94
|
|
7
|
+
data.tar.gz: ec59c619a7b7876c8c50c6191231cb7e68fa35491939bda433d85a8d8770c3044eee40964748dee85683424084a5e8651ae9e15e88acc29025deb54e2f63cd65
|
data/.travis.yml
CHANGED
data/CONTRIBUTORS
CHANGED
data/README.md
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# EBANX Ruby gem [](https://travis-ci.org/ebanx-integration/ebanx-ruby) [](https://codeclimate.com/github/ebanx-integration/ebanx-ruby) [](https://codeclimate.com/github/ebanx-integration/ebanx-ruby/coverage)
|
|
2
|
+
|
|
2
3
|
Gem to communicate with EBANX.
|
|
3
4
|
|
|
4
5
|
Documentation: https://developers.ebanx.com/
|
|
@@ -18,9 +19,17 @@ Or install it yourself as:
|
|
|
18
19
|
|
|
19
20
|
## Usage
|
|
20
21
|
|
|
22
|
+
#### Auth
|
|
23
|
+
```ruby
|
|
24
|
+
Ebanx.tap do |e|
|
|
25
|
+
e.integration_key = '<<< Your integration key >>>'
|
|
26
|
+
e.test_mode = true
|
|
27
|
+
end
|
|
28
|
+
```
|
|
29
|
+
|
|
21
30
|
#### Create a new Boleto using Direct API
|
|
22
31
|
```ruby
|
|
23
|
-
response =
|
|
32
|
+
response = Ebanx.do_direct(
|
|
24
33
|
operation: 'request',
|
|
25
34
|
mode: 'full',
|
|
26
35
|
payment: {
|
|
@@ -42,7 +51,7 @@ response = ebanx.do_direct {
|
|
|
42
51
|
phone_number: '6130001111',
|
|
43
52
|
due_date: (Time.now + 86400).strftime('%d/%m/%Y')
|
|
44
53
|
}
|
|
45
|
-
|
|
54
|
+
)
|
|
46
55
|
|
|
47
56
|
```
|
|
48
57
|
|
|
@@ -59,4 +68,4 @@ rake test
|
|
|
59
68
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
60
69
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
61
70
|
4. Push to the branch (`git push origin my-new-feature`)
|
|
62
|
-
5. Create new Pull Request
|
|
71
|
+
5. Create new Pull Request
|
data/Rakefile
CHANGED
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.3.
|
|
1
|
+
1.3.2
|
data/ebanx.gemspec
CHANGED
|
@@ -23,6 +23,6 @@ Gem::Specification.new do |spec|
|
|
|
23
23
|
spec.add_development_dependency "minitest"
|
|
24
24
|
spec.add_development_dependency "codeclimate-test-reporter"
|
|
25
25
|
|
|
26
|
-
spec.add_dependency 'rest-client', '~>
|
|
26
|
+
spec.add_dependency 'rest-client' , '~> 2.0.2'
|
|
27
27
|
spec.add_dependency 'json'
|
|
28
28
|
end
|
data/lib/ebanx.rb
CHANGED
|
@@ -2,6 +2,7 @@ require 'rest-client'
|
|
|
2
2
|
require 'json'
|
|
3
3
|
|
|
4
4
|
require_relative 'ebanx/version'
|
|
5
|
+
require_relative 'ebanx/dig'
|
|
5
6
|
require_relative 'ebanx/response'
|
|
6
7
|
require_relative 'ebanx/command/command'
|
|
7
8
|
require_relative 'ebanx/command/cancel'
|
|
@@ -11,18 +12,37 @@ require_relative 'ebanx/command/document_balance'
|
|
|
11
12
|
require_relative 'ebanx/command/due_date'
|
|
12
13
|
require_relative 'ebanx/command/exchange'
|
|
13
14
|
require_relative 'ebanx/command/print'
|
|
15
|
+
require_relative 'ebanx/command/get_currency_rates'
|
|
14
16
|
require_relative 'ebanx/command/get_merchant_integration_properties'
|
|
15
17
|
require_relative 'ebanx/command/edit_merchant_integration_properties'
|
|
16
18
|
require_relative 'ebanx/command/query'
|
|
17
19
|
require_relative 'ebanx/command/refund'
|
|
18
20
|
require_relative 'ebanx/command/refund_or_cancel'
|
|
19
21
|
require_relative 'ebanx/command/get_merchant_settlement_info'
|
|
22
|
+
require_relative 'ebanx/command/get_merchant_settlement_report'
|
|
23
|
+
require_relative 'ebanx/command/get_merchant_settlement_statement'
|
|
20
24
|
require_relative 'ebanx/command/get_merchant_settlement_extract'
|
|
21
25
|
require_relative 'ebanx/command/create_merchant_settlement_request'
|
|
22
26
|
require_relative 'ebanx/command/get_merchant_amount_balance_by_country'
|
|
23
27
|
require_relative 'ebanx/command/request'
|
|
28
|
+
require_relative 'ebanx/command/resend_payment_notification'
|
|
24
29
|
require_relative 'ebanx/command/token'
|
|
25
30
|
require_relative 'ebanx/command/zipcode'
|
|
31
|
+
require_relative 'ebanx/command/payout_create'
|
|
32
|
+
require_relative 'ebanx/command/payout_commit'
|
|
33
|
+
require_relative 'ebanx/command/payout_cancel'
|
|
34
|
+
require_relative 'ebanx/command/payout_retrieve'
|
|
35
|
+
require_relative 'ebanx/command/payout_search'
|
|
36
|
+
require_relative 'ebanx/command/payout_simulate'
|
|
37
|
+
require_relative 'ebanx/command/payout_balance'
|
|
38
|
+
require_relative 'ebanx/command/payout_banks'
|
|
39
|
+
require_relative 'ebanx/command/payout_bank_details'
|
|
40
|
+
require_relative 'ebanx/command/transfer_create'
|
|
41
|
+
require_relative 'ebanx/command/transfer_cancel'
|
|
42
|
+
require_relative 'ebanx/command/transfer_commit'
|
|
43
|
+
require_relative 'ebanx/command/transfer_retrieve'
|
|
44
|
+
require_relative 'ebanx/command/transfer_search'
|
|
45
|
+
require_relative 'ebanx/exception/ebanx_api_exception'
|
|
26
46
|
|
|
27
47
|
module Ebanx
|
|
28
48
|
@test_mode = false
|
|
@@ -42,16 +62,18 @@ module Ebanx
|
|
|
42
62
|
protected
|
|
43
63
|
def self.run_command(method, params)
|
|
44
64
|
klass = get_command_class method
|
|
65
|
+
required_params = klass.instance_method(:initialize).parameters.size
|
|
45
66
|
|
|
46
|
-
raise ArgumentError if !params[0] || params[0].length == 0
|
|
67
|
+
raise ArgumentError if (!params[0] || params[0].length == 0) && required_params != 0
|
|
47
68
|
|
|
48
|
-
command = klass.new merge_default_params(klass, params)
|
|
69
|
+
command = required_params == 0 ? klass.new : klass.new(merge_default_params(klass, params))
|
|
49
70
|
command.valid?
|
|
50
71
|
|
|
51
72
|
request command
|
|
52
73
|
end
|
|
53
74
|
|
|
54
75
|
def self.merge_default_params(command, params)
|
|
76
|
+
return params if params.empty?
|
|
55
77
|
params = params[0].merge integration_key: @integration_key
|
|
56
78
|
|
|
57
79
|
if command.name =~ /Direct$/
|
|
@@ -64,13 +86,18 @@ module Ebanx
|
|
|
64
86
|
def self.request(command)
|
|
65
87
|
uri = Ebanx::base_uri + command.request_action
|
|
66
88
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
89
|
+
begin
|
|
90
|
+
case command.request_method
|
|
91
|
+
when :post
|
|
92
|
+
response = RestClient::Request.execute(:method => :post, content_type: command.response_type, :url => uri, :payload => command.params, :timeout => nil, :open_timeout => nil)
|
|
93
|
+
when :get
|
|
94
|
+
response = RestClient.get uri, params: command.params
|
|
95
|
+
else
|
|
96
|
+
raise ArgumentError "Request method #{command.request_method.to_s} is not supported."
|
|
97
|
+
end
|
|
98
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
99
|
+
message = (JSON.parse(e.response)['message'] rescue nil) || e.message
|
|
100
|
+
raise EbanxApiException.new(message, e.response, e.http_code)
|
|
74
101
|
end
|
|
75
102
|
|
|
76
103
|
Ebanx::Response.new response, command.response_type
|
data/lib/ebanx/command/cancel.rb
CHANGED
|
@@ -23,18 +23,32 @@ module Ebanx
|
|
|
23
23
|
raise NotImplementedError
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
-
def validate_presence(
|
|
27
|
-
raise ArgumentError unless @params.
|
|
26
|
+
def validate_presence(*names)
|
|
27
|
+
raise ArgumentError.new("Missing argument #{names}") unless @params.dig *names
|
|
28
28
|
true
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
+
def validate_with_callback(names, callback)
|
|
32
|
+
callback.call(@params.dig(*names), @params)
|
|
33
|
+
end
|
|
34
|
+
|
|
31
35
|
def validate_presence_or(name1, name2)
|
|
32
36
|
unless @params.include?(name1) || @params.include?(name2)
|
|
33
|
-
raise ArgumentError
|
|
37
|
+
raise ArgumentError.new("Missing argument, obligatory #{name1} or #{name2}")
|
|
34
38
|
end
|
|
35
39
|
|
|
36
40
|
true
|
|
37
41
|
end
|
|
42
|
+
|
|
43
|
+
def validate_presence_either(args)
|
|
44
|
+
args.each do |arg|
|
|
45
|
+
if @params.include?(arg)
|
|
46
|
+
return true
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
raise ArgumentError.new("Missing all arguments: #{args.join(", ")}.")
|
|
51
|
+
end
|
|
38
52
|
end
|
|
39
53
|
end
|
|
40
|
-
end
|
|
54
|
+
end
|
data/lib/ebanx/command/direct.rb
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module Ebanx
|
|
2
|
+
module Command
|
|
3
|
+
class GetCurrencyRates < Command
|
|
4
|
+
def initialize(params)
|
|
5
|
+
@params = params
|
|
6
|
+
@request_method = :get
|
|
7
|
+
@request_action = 'exchange/getCurrencyRates'
|
|
8
|
+
@response_type = :json
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def validate
|
|
12
|
+
validate_presence :currency_codes
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -3,7 +3,7 @@ module Ebanx
|
|
|
3
3
|
class GetMerchantAmountBalanceByCountry < Command
|
|
4
4
|
def initialize(params)
|
|
5
5
|
@params = params
|
|
6
|
-
@request_method = :
|
|
6
|
+
@request_method = :post
|
|
7
7
|
@request_action = 'merchantSettlement/getAmountBalanceByCountry'
|
|
8
8
|
@response_type = :json
|
|
9
9
|
end
|
|
@@ -13,4 +13,4 @@ module Ebanx
|
|
|
13
13
|
end
|
|
14
14
|
end
|
|
15
15
|
end
|
|
16
|
-
end
|
|
16
|
+
end
|
|
@@ -3,7 +3,7 @@ module Ebanx
|
|
|
3
3
|
class GetMerchantSettlementExtract < Command
|
|
4
4
|
def initialize(params)
|
|
5
5
|
@params = params
|
|
6
|
-
@request_method = :
|
|
6
|
+
@request_method = :post
|
|
7
7
|
@request_action = 'merchantSettlement/getExtract'
|
|
8
8
|
@response_type = :json
|
|
9
9
|
end
|
|
@@ -17,4 +17,4 @@ module Ebanx
|
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
|
-
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module Ebanx
|
|
2
|
+
module Command
|
|
3
|
+
class GetMerchantSettlementReport < Command
|
|
4
|
+
def initialize(params)
|
|
5
|
+
@params = params
|
|
6
|
+
@request_method = :get
|
|
7
|
+
@request_action = 'merchantSettlement/getReport'
|
|
8
|
+
@response_type = :json
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def validate
|
|
12
|
+
validate_presence :settlement_id
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Ebanx
|
|
2
|
+
module Command
|
|
3
|
+
class GetMerchantSettlementStatement < Command
|
|
4
|
+
def initialize(params)
|
|
5
|
+
@params = params
|
|
6
|
+
@request_method = :get
|
|
7
|
+
@request_action = 'merchantSettlement/getStatement'
|
|
8
|
+
@response_type = :json
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def validate
|
|
12
|
+
validate_presence :start_date
|
|
13
|
+
validate_presence :end_date
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module Ebanx
|
|
2
|
+
module Command
|
|
3
|
+
class PayoutCancel < Command
|
|
4
|
+
def initialize(params)
|
|
5
|
+
@params = params
|
|
6
|
+
@request_method = :post
|
|
7
|
+
@request_action = 'payout/cancel'
|
|
8
|
+
@response_type = :json
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def validate
|
|
12
|
+
validate_presence_or :external_reference, :uid
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module Ebanx
|
|
2
|
+
module Command
|
|
3
|
+
class PayoutCommit < Command
|
|
4
|
+
def initialize(params)
|
|
5
|
+
@params = params
|
|
6
|
+
@request_method = :post
|
|
7
|
+
@request_action = 'payout/commit'
|
|
8
|
+
@response_type = :json
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def validate
|
|
12
|
+
validate_presence_or :external_reference, :uid
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module Ebanx
|
|
2
|
+
module Command
|
|
3
|
+
class PayoutCreate < Command
|
|
4
|
+
def initialize(params)
|
|
5
|
+
@params = params
|
|
6
|
+
@request_method = :post
|
|
7
|
+
@request_action = 'payout/create'
|
|
8
|
+
@response_type = :json
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def validate
|
|
12
|
+
validate_presence :external_reference
|
|
13
|
+
validate_presence :country
|
|
14
|
+
validate_presence :amount
|
|
15
|
+
validate_presence :currency_code
|
|
16
|
+
validate_presence :payee
|
|
17
|
+
validate_presence :payee, :name
|
|
18
|
+
validate_presence :payee, :email
|
|
19
|
+
validate_with_callback [:payee, :document], -> (value, object) {(object[:country] == 'mx' || !value.nil?) or raise ArgumentError.new("Missing argument [:payee, :document]")}
|
|
20
|
+
validate_with_callback [:payee, :document_type], -> (value, object) {(object[:country] == 'mx' || !value.nil?) or raise ArgumentError.new("Missing argument [:payee, :document_type]")}
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module Ebanx
|
|
2
|
+
module Command
|
|
3
|
+
class PayoutRetrieve < Command
|
|
4
|
+
def initialize(params)
|
|
5
|
+
@params = params
|
|
6
|
+
@request_method = :post
|
|
7
|
+
@request_action = 'payout/retrieve'
|
|
8
|
+
@response_type = :json
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def validate
|
|
12
|
+
validate_presence_or :external_reference, :uid
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Ebanx
|
|
2
|
+
module Command
|
|
3
|
+
class PayoutSearch < Command
|
|
4
|
+
def initialize(params)
|
|
5
|
+
@params = params
|
|
6
|
+
@request_method = :post
|
|
7
|
+
@request_action = 'payout/search'
|
|
8
|
+
@response_type = :json
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def validate
|
|
12
|
+
validate_presence :date_from
|
|
13
|
+
validate_presence :date_to
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module Ebanx
|
|
2
|
+
module Command
|
|
3
|
+
class PayoutSimulate < Command
|
|
4
|
+
def initialize(params)
|
|
5
|
+
@params = params
|
|
6
|
+
@request_method = :post
|
|
7
|
+
@request_action = 'payout/simulate'
|
|
8
|
+
@response_type = :json
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def validate
|
|
12
|
+
validate_presence :country
|
|
13
|
+
validate_presence :amount
|
|
14
|
+
validate_presence :currency_code
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
data/lib/ebanx/command/print.rb
CHANGED
data/lib/ebanx/command/query.rb
CHANGED
data/lib/ebanx/command/refund.rb
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module Ebanx
|
|
2
|
+
module Command
|
|
3
|
+
class ResendPaymentNotification < Command
|
|
4
|
+
def initialize(params)
|
|
5
|
+
@params = params
|
|
6
|
+
@request_method = :post
|
|
7
|
+
@request_action = 'everest/resendNotification'
|
|
8
|
+
@response_type = :json
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def validate
|
|
12
|
+
validate_presence :hash
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
data/lib/ebanx/command/token.rb
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module Ebanx
|
|
2
|
+
module Command
|
|
3
|
+
class TransferCancel < Command
|
|
4
|
+
def initialize(params)
|
|
5
|
+
@params = params
|
|
6
|
+
@request_method = :post
|
|
7
|
+
@request_action = 'transfer/cancel'
|
|
8
|
+
@response_type = :json
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def validate
|
|
12
|
+
validate_presence_either [:transfer_code, :uid, :external_reference, :settlement_code]
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module Ebanx
|
|
2
|
+
module Command
|
|
3
|
+
class TransferCommit < Command
|
|
4
|
+
def initialize(params)
|
|
5
|
+
@params = params
|
|
6
|
+
@request_method = :post
|
|
7
|
+
@request_action = 'transfer/commit'
|
|
8
|
+
@response_type = :json
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def validate
|
|
12
|
+
validate_presence_either [:transfer_code, :uid, :external_reference, :settlement_code]
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module Ebanx
|
|
2
|
+
module Command
|
|
3
|
+
class TransferCreate < Command
|
|
4
|
+
def initialize(params)
|
|
5
|
+
@params = params
|
|
6
|
+
@request_method = :post
|
|
7
|
+
@request_action = 'transfer/create'
|
|
8
|
+
@response_type = :json
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def validate
|
|
12
|
+
validate_presence :amount
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module Ebanx
|
|
2
|
+
module Command
|
|
3
|
+
class TransferRetrieve < Command
|
|
4
|
+
def initialize(params)
|
|
5
|
+
@params = params
|
|
6
|
+
@request_method = :post
|
|
7
|
+
@request_action = 'transfer/retrieve'
|
|
8
|
+
@response_type = :json
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def validate
|
|
12
|
+
validate_presence_either [:transfer_code, :uid, :external_reference, :settlement_code]
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Ebanx
|
|
2
|
+
module Command
|
|
3
|
+
class TransferSearch < Command
|
|
4
|
+
def initialize(params)
|
|
5
|
+
@params = params
|
|
6
|
+
@request_method = :post
|
|
7
|
+
@request_action = 'transfer/search'
|
|
8
|
+
@response_type = :json
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def validate
|
|
12
|
+
validate_presence :date_from
|
|
13
|
+
validate_presence :date_to
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
data/lib/ebanx/dig.rb
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module EBANX
|
|
2
|
+
module Dig
|
|
3
|
+
def dig(key, *rest)
|
|
4
|
+
value = self[key]
|
|
5
|
+
if value.nil? || rest.empty?
|
|
6
|
+
value
|
|
7
|
+
elsif value.respond_to?(:dig)
|
|
8
|
+
value.dig(*rest)
|
|
9
|
+
else
|
|
10
|
+
fail TypeError, "#{value.class} does not have #dig method"
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
if RUBY_VERSION < '2.3'
|
|
17
|
+
class Array
|
|
18
|
+
include EBANX::Dig
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
class Hash
|
|
22
|
+
include EBANX::Dig
|
|
23
|
+
end
|
|
24
|
+
end
|
data/lib/ebanx/version.rb
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
require_relative '../test_helper'
|
|
2
|
+
|
|
3
|
+
describe Ebanx::Command::TransferCreate do
|
|
4
|
+
it "gets EBANX Exception for Invalid Amount" do
|
|
5
|
+
err = lambda { ebanx.do_transfer_create({amount: "AAAA"}) }.must_raise EbanxApiException
|
|
6
|
+
assert_equal('Invalid amount', err.message)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
it "can't run without arguments" do
|
|
10
|
+
lambda { ebanx.do_transfer_create }.must_raise ArgumentError
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
require_relative '../test_helper'
|
|
2
|
+
|
|
3
|
+
describe Ebanx::Command::GetCurrencyRates do
|
|
4
|
+
it "performs a successful" do
|
|
5
|
+
params = {
|
|
6
|
+
currency_codes: ['USD','EUR'],
|
|
7
|
+
currency_base_codes: ['BRL','CLP']
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
response = ebanx.do_get_currency_rates params
|
|
11
|
+
|
|
12
|
+
response.http_code.must_equal 200
|
|
13
|
+
response.response['status'].must_equal 'SUCCESS'
|
|
14
|
+
assert_equal 4, response.response['currency_rates'].size
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
require_relative '../test_helper'
|
|
2
|
+
|
|
3
|
+
describe Ebanx::Command::GetMerchantSettlementReport do
|
|
4
|
+
it 'performs a successful settlement report' do
|
|
5
|
+
params = { settlement_id: 33 }
|
|
6
|
+
response = ebanx.do_get_merchant_settlement_report params
|
|
7
|
+
response.http_code.must_equal 200
|
|
8
|
+
response.response['status'].must_equal 'SUCCESS'
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
require_relative '../test_helper'
|
|
2
|
+
|
|
3
|
+
describe Ebanx::Command::GetMerchantSettlementStatement do
|
|
4
|
+
it 'performs a successful settlement statement' do
|
|
5
|
+
params = { start_date: '01/11/2016', end_date: '03/11/2016' }
|
|
6
|
+
response = ebanx.do_get_merchant_settlement_statement params
|
|
7
|
+
response.http_code.must_equal 200
|
|
8
|
+
response.response['status'].must_equal 'SUCCESS'
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
require_relative '../test_helper'
|
|
2
|
+
|
|
3
|
+
describe Ebanx::Command::ResendPaymentNotification do
|
|
4
|
+
before do
|
|
5
|
+
@params = {
|
|
6
|
+
payment: {
|
|
7
|
+
name: 'João da Silva',
|
|
8
|
+
email: 'joao@mailinator.com',
|
|
9
|
+
currency_code: 'BRL',
|
|
10
|
+
amount_total: 100.50,
|
|
11
|
+
merchant_payment_code: Random.rand(10000000000),
|
|
12
|
+
payment_type_code: 'boleto',
|
|
13
|
+
document: '13326724691',
|
|
14
|
+
birth_date: '01/01/1980',
|
|
15
|
+
zipcode: '70000-000',
|
|
16
|
+
address: 'Rua Brasil',
|
|
17
|
+
street_number: '1',
|
|
18
|
+
city: 'Brasília',
|
|
19
|
+
state: 'DF',
|
|
20
|
+
country: 'br',
|
|
21
|
+
phone_number: '6130001111',
|
|
22
|
+
due_date: (Time.now + 86400).strftime('%d/%m/%Y')
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it "can't run without arguments" do
|
|
28
|
+
lambda { ebanx.do_resend_payment_notification }.must_raise ArgumentError
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "resend notifiction successfully" do
|
|
32
|
+
|
|
33
|
+
payment_request = ebanx.do_direct @params
|
|
34
|
+
|
|
35
|
+
payment_request.http_code.must_equal 200
|
|
36
|
+
|
|
37
|
+
response = ebanx.do_resend_payment_notification({hash: payment_request.response['payment']['hash']})
|
|
38
|
+
response.http_code.must_equal 200
|
|
39
|
+
response.response['status'].must_equal 'SUCCESS'
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require_relative '../test_helper'
|
|
2
|
+
|
|
3
|
+
describe Ebanx::Command::PayoutSimulate do
|
|
4
|
+
it "can't run without arguments" do
|
|
5
|
+
lambda { ebanx.do_payout_simulate }.must_raise ArgumentError
|
|
6
|
+
end
|
|
7
|
+
it "performs a successful" do
|
|
8
|
+
params = { amount: 10.0, country: 'br', currency_code: 'USD' }
|
|
9
|
+
response = ebanx.do_payout_simulate params
|
|
10
|
+
response.http_code.must_equal 200
|
|
11
|
+
response.response['type'].must_equal 'success'
|
|
12
|
+
end
|
|
13
|
+
end
|
data/test/test_helper.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
if ENV['CODECLIMATE_REPO_TOKEN']
|
|
2
|
-
require '
|
|
3
|
-
|
|
2
|
+
require 'simplecov'
|
|
3
|
+
SimpleCov.start
|
|
4
4
|
end
|
|
5
5
|
|
|
6
6
|
require 'ebanx'
|
|
@@ -15,4 +15,4 @@ class MiniTest::Spec
|
|
|
15
15
|
e.test_mode = true
|
|
16
16
|
end
|
|
17
17
|
end
|
|
18
|
-
end
|
|
18
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ebanx
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.3.
|
|
4
|
+
version: 1.3.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Gustavo Henrique Mascarenhas Machado
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2017-10-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -72,14 +72,14 @@ dependencies:
|
|
|
72
72
|
requirements:
|
|
73
73
|
- - "~>"
|
|
74
74
|
- !ruby/object:Gem::Version
|
|
75
|
-
version:
|
|
75
|
+
version: 2.0.2
|
|
76
76
|
type: :runtime
|
|
77
77
|
prerelease: false
|
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
79
|
requirements:
|
|
80
80
|
- - "~>"
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
|
-
version:
|
|
82
|
+
version: 2.0.2
|
|
83
83
|
- !ruby/object:Gem::Dependency
|
|
84
84
|
name: json
|
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -121,28 +121,65 @@ files:
|
|
|
121
121
|
- lib/ebanx/command/due_date.rb
|
|
122
122
|
- lib/ebanx/command/edit_merchant_integration_properties.rb
|
|
123
123
|
- lib/ebanx/command/exchange.rb
|
|
124
|
+
- lib/ebanx/command/get_currency_rates.rb
|
|
124
125
|
- lib/ebanx/command/get_merchant_amount_balance_by_country.rb
|
|
125
126
|
- lib/ebanx/command/get_merchant_integration_properties.rb
|
|
126
127
|
- lib/ebanx/command/get_merchant_settlement_extract.rb
|
|
127
128
|
- lib/ebanx/command/get_merchant_settlement_info.rb
|
|
129
|
+
- lib/ebanx/command/get_merchant_settlement_report.rb
|
|
130
|
+
- lib/ebanx/command/get_merchant_settlement_statement.rb
|
|
131
|
+
- lib/ebanx/command/payout_balance.rb
|
|
132
|
+
- lib/ebanx/command/payout_bank_details.rb
|
|
133
|
+
- lib/ebanx/command/payout_banks.rb
|
|
134
|
+
- lib/ebanx/command/payout_cancel.rb
|
|
135
|
+
- lib/ebanx/command/payout_commit.rb
|
|
136
|
+
- lib/ebanx/command/payout_create.rb
|
|
137
|
+
- lib/ebanx/command/payout_retrieve.rb
|
|
138
|
+
- lib/ebanx/command/payout_search.rb
|
|
139
|
+
- lib/ebanx/command/payout_simulate.rb
|
|
128
140
|
- lib/ebanx/command/print.rb
|
|
129
141
|
- lib/ebanx/command/query.rb
|
|
130
142
|
- lib/ebanx/command/refund.rb
|
|
131
143
|
- lib/ebanx/command/refund_or_cancel.rb
|
|
132
144
|
- lib/ebanx/command/request.rb
|
|
145
|
+
- lib/ebanx/command/resend_payment_notification.rb
|
|
133
146
|
- lib/ebanx/command/token.rb
|
|
147
|
+
- lib/ebanx/command/transfer_cancel.rb
|
|
148
|
+
- lib/ebanx/command/transfer_commit.rb
|
|
149
|
+
- lib/ebanx/command/transfer_create.rb
|
|
150
|
+
- lib/ebanx/command/transfer_retrieve.rb
|
|
151
|
+
- lib/ebanx/command/transfer_search.rb
|
|
134
152
|
- lib/ebanx/command/zipcode.rb
|
|
153
|
+
- lib/ebanx/dig.rb
|
|
154
|
+
- lib/ebanx/exception/ebanx_api_exception.rb
|
|
135
155
|
- lib/ebanx/response.rb
|
|
136
156
|
- lib/ebanx/version.rb
|
|
137
157
|
- test/ebanx/cancel_command_test.rb
|
|
158
|
+
- test/ebanx/cancel_payout_command_test.rb
|
|
159
|
+
- test/ebanx/cancel_transfer_command_test.rb
|
|
160
|
+
- test/ebanx/commit_payout_command_test.rb
|
|
161
|
+
- test/ebanx/commit_transfer_command_test.rb
|
|
138
162
|
- test/ebanx/create_merchant_settlement_request_command_test.rb
|
|
163
|
+
- test/ebanx/create_payout_command_test.rb
|
|
164
|
+
- test/ebanx/create_transfer_command_test.rb
|
|
139
165
|
- test/ebanx/direct_command_test.rb
|
|
140
166
|
- test/ebanx/edit_merchant_integration_properties_command_test.rb
|
|
167
|
+
- test/ebanx/get_currency_rates_command_test.rb
|
|
141
168
|
- test/ebanx/get_merchant_amount_balance_by_country_command_test.rb
|
|
142
169
|
- test/ebanx/get_merchant_integration_properties_command_test.rb
|
|
143
170
|
- test/ebanx/get_merchant_settlement_extract_command_test.rb
|
|
144
171
|
- test/ebanx/get_merchant_settlement_info_command_test.rb
|
|
172
|
+
- test/ebanx/get_merchant_settlement_report_command_test.rb
|
|
173
|
+
- test/ebanx/get_merchant_settlement_statement_command_test.rb
|
|
174
|
+
- test/ebanx/payout_bank_details_command_test.rb
|
|
175
|
+
- test/ebanx/payout_banks_command_test.rb
|
|
145
176
|
- test/ebanx/request_command_test.rb
|
|
177
|
+
- test/ebanx/resend_payment_notification_command_test.rb
|
|
178
|
+
- test/ebanx/retrieve_payout_command_test.rb
|
|
179
|
+
- test/ebanx/retrieve_transfer_command_test.rb
|
|
180
|
+
- test/ebanx/search_payout_command_test.rb
|
|
181
|
+
- test/ebanx/search_transfer_command_test.rb
|
|
182
|
+
- test/ebanx/simulate_payout_command_test.rb
|
|
146
183
|
- test/ebanx/zipcode_command_test.rb
|
|
147
184
|
- test/test_helper.rb
|
|
148
185
|
homepage: https://www.ebanx.com
|
|
@@ -165,19 +202,36 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
165
202
|
version: '0'
|
|
166
203
|
requirements: []
|
|
167
204
|
rubyforge_project:
|
|
168
|
-
rubygems_version: 2.
|
|
205
|
+
rubygems_version: 2.5.2
|
|
169
206
|
signing_key:
|
|
170
207
|
specification_version: 4
|
|
171
208
|
summary: Ruby bindings for the EBANX API
|
|
172
209
|
test_files:
|
|
173
210
|
- test/ebanx/cancel_command_test.rb
|
|
211
|
+
- test/ebanx/cancel_payout_command_test.rb
|
|
212
|
+
- test/ebanx/cancel_transfer_command_test.rb
|
|
213
|
+
- test/ebanx/commit_payout_command_test.rb
|
|
214
|
+
- test/ebanx/commit_transfer_command_test.rb
|
|
174
215
|
- test/ebanx/create_merchant_settlement_request_command_test.rb
|
|
216
|
+
- test/ebanx/create_payout_command_test.rb
|
|
217
|
+
- test/ebanx/create_transfer_command_test.rb
|
|
175
218
|
- test/ebanx/direct_command_test.rb
|
|
176
219
|
- test/ebanx/edit_merchant_integration_properties_command_test.rb
|
|
220
|
+
- test/ebanx/get_currency_rates_command_test.rb
|
|
177
221
|
- test/ebanx/get_merchant_amount_balance_by_country_command_test.rb
|
|
178
222
|
- test/ebanx/get_merchant_integration_properties_command_test.rb
|
|
179
223
|
- test/ebanx/get_merchant_settlement_extract_command_test.rb
|
|
180
224
|
- test/ebanx/get_merchant_settlement_info_command_test.rb
|
|
225
|
+
- test/ebanx/get_merchant_settlement_report_command_test.rb
|
|
226
|
+
- test/ebanx/get_merchant_settlement_statement_command_test.rb
|
|
227
|
+
- test/ebanx/payout_bank_details_command_test.rb
|
|
228
|
+
- test/ebanx/payout_banks_command_test.rb
|
|
181
229
|
- test/ebanx/request_command_test.rb
|
|
230
|
+
- test/ebanx/resend_payment_notification_command_test.rb
|
|
231
|
+
- test/ebanx/retrieve_payout_command_test.rb
|
|
232
|
+
- test/ebanx/retrieve_transfer_command_test.rb
|
|
233
|
+
- test/ebanx/search_payout_command_test.rb
|
|
234
|
+
- test/ebanx/search_transfer_command_test.rb
|
|
235
|
+
- test/ebanx/simulate_payout_command_test.rb
|
|
182
236
|
- test/ebanx/zipcode_command_test.rb
|
|
183
237
|
- test/test_helper.rb
|