ebanx 1.3.1 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +4 -1
  3. data/CONTRIBUTORS +2 -1
  4. data/README.md +12 -3
  5. data/Rakefile +1 -0
  6. data/VERSION +1 -1
  7. data/ebanx.gemspec +1 -1
  8. data/lib/ebanx.rb +36 -9
  9. data/lib/ebanx/command/cancel.rb +1 -1
  10. data/lib/ebanx/command/capture.rb +1 -1
  11. data/lib/ebanx/command/command.rb +18 -4
  12. data/lib/ebanx/command/create_merchant_settlement_request.rb +1 -1
  13. data/lib/ebanx/command/direct.rb +1 -1
  14. data/lib/ebanx/command/document_balance.rb +1 -1
  15. data/lib/ebanx/command/edit_merchant_integration_properties.rb +1 -1
  16. data/lib/ebanx/command/exchange.rb +1 -1
  17. data/lib/ebanx/command/get_currency_rates.rb +16 -0
  18. data/lib/ebanx/command/get_merchant_amount_balance_by_country.rb +2 -2
  19. data/lib/ebanx/command/get_merchant_integration_properties.rb +1 -1
  20. data/lib/ebanx/command/get_merchant_settlement_extract.rb +2 -2
  21. data/lib/ebanx/command/get_merchant_settlement_info.rb +1 -1
  22. data/lib/ebanx/command/get_merchant_settlement_report.rb +16 -0
  23. data/lib/ebanx/command/get_merchant_settlement_statement.rb +17 -0
  24. data/lib/ebanx/command/payout_balance.rb +14 -0
  25. data/lib/ebanx/command/payout_bank_details.rb +14 -0
  26. data/lib/ebanx/command/payout_banks.rb +14 -0
  27. data/lib/ebanx/command/payout_cancel.rb +16 -0
  28. data/lib/ebanx/command/payout_commit.rb +16 -0
  29. data/lib/ebanx/command/payout_create.rb +24 -0
  30. data/lib/ebanx/command/payout_retrieve.rb +16 -0
  31. data/lib/ebanx/command/payout_search.rb +17 -0
  32. data/lib/ebanx/command/payout_simulate.rb +18 -0
  33. data/lib/ebanx/command/print.rb +1 -1
  34. data/lib/ebanx/command/query.rb +1 -1
  35. data/lib/ebanx/command/refund.rb +1 -1
  36. data/lib/ebanx/command/refund_or_cancel.rb +1 -1
  37. data/lib/ebanx/command/request.rb +5 -1
  38. data/lib/ebanx/command/resend_payment_notification.rb +16 -0
  39. data/lib/ebanx/command/token.rb +1 -1
  40. data/lib/ebanx/command/transfer_cancel.rb +16 -0
  41. data/lib/ebanx/command/transfer_commit.rb +16 -0
  42. data/lib/ebanx/command/transfer_create.rb +16 -0
  43. data/lib/ebanx/command/transfer_retrieve.rb +16 -0
  44. data/lib/ebanx/command/transfer_search.rb +17 -0
  45. data/lib/ebanx/command/zipcode.rb +1 -1
  46. data/lib/ebanx/dig.rb +24 -0
  47. data/lib/ebanx/exception/ebanx_api_exception.rb +9 -0
  48. data/lib/ebanx/version.rb +1 -1
  49. data/test/ebanx/cancel_command_test.rb +1 -1
  50. data/test/ebanx/cancel_payout_command_test.rb +7 -0
  51. data/test/ebanx/cancel_transfer_command_test.rb +7 -0
  52. data/test/ebanx/commit_payout_command_test.rb +7 -0
  53. data/test/ebanx/commit_transfer_command_test.rb +7 -0
  54. data/test/ebanx/create_merchant_settlement_request_command_test.rb +1 -1
  55. data/test/ebanx/create_payout_command_test.rb +7 -0
  56. data/test/ebanx/create_transfer_command_test.rb +12 -0
  57. data/test/ebanx/direct_command_test.rb +1 -1
  58. data/test/ebanx/edit_merchant_integration_properties_command_test.rb +1 -1
  59. data/test/ebanx/get_currency_rates_command_test.rb +16 -0
  60. data/test/ebanx/get_merchant_amount_balance_by_country_command_test.rb +1 -1
  61. data/test/ebanx/get_merchant_integration_properties_command_test.rb +1 -1
  62. data/test/ebanx/get_merchant_settlement_extract_command_test.rb +1 -1
  63. data/test/ebanx/get_merchant_settlement_info_command_test.rb +1 -1
  64. data/test/ebanx/get_merchant_settlement_report_command_test.rb +10 -0
  65. data/test/ebanx/get_merchant_settlement_statement_command_test.rb +10 -0
  66. data/test/ebanx/payout_bank_details_command_test.rb +8 -0
  67. data/test/ebanx/payout_banks_command_test.rb +8 -0
  68. data/test/ebanx/request_command_test.rb +1 -1
  69. data/test/ebanx/resend_payment_notification_command_test.rb +41 -0
  70. data/test/ebanx/retrieve_payout_command_test.rb +7 -0
  71. data/test/ebanx/retrieve_transfer_command_test.rb +7 -0
  72. data/test/ebanx/search_payout_command_test.rb +7 -0
  73. data/test/ebanx/search_transfer_command_test.rb +7 -0
  74. data/test/ebanx/simulate_payout_command_test.rb +13 -0
  75. data/test/ebanx/zipcode_command_test.rb +1 -1
  76. data/test/test_helper.rb +3 -3
  77. metadata +59 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b01d3492add2a5f5eaf0d81c9d29408c2ac7f9e8
4
- data.tar.gz: d4f018d7bcd044fd8ed0a62a0921b347f6f13286
3
+ metadata.gz: 78377be804e97bc892238ba52fbb5c760dc32ed4
4
+ data.tar.gz: d69594b94e9a241a78dfcf5bdf2702c9b25dc6a6
5
5
  SHA512:
6
- metadata.gz: b3d2ff8740dd2e0a24389f1d01b5447713921b9a9d2da2dcf758bf4ab74b8ee79859b9537b20912f526a7f3ef5540b512aa04d7c583a9b8de178a1c805a6506d
7
- data.tar.gz: 9ff6b8332cce085d4f5f71a7516363be6f6a9e61ddbb422fff88ea417ed221d72b6084b58bc4f6bbd560977a685c6b9a28e3db4ba5b8c692330884802ea4b8c3
6
+ metadata.gz: ac1d9850eb55b10958699f8af45dd48ba06e3da85d9da120ee2fd02819aeb9a716518c304427eac7aab0aee6a799864fae78d23532e72b35a05c22f3d6c90a94
7
+ data.tar.gz: ec59c619a7b7876c8c50c6191231cb7e68fa35491939bda433d85a8d8770c3044eee40964748dee85683424084a5e8651ae9e15e88acc29025deb54e2f63cd65
@@ -3,4 +3,7 @@ language: ruby
3
3
  rvm:
4
4
  - 2.0.0
5
5
  - 2.1
6
- - 2.2
6
+ - 2.2
7
+
8
+ after_script:
9
+ - bundle exec codeclimate-test-reporter
@@ -1,2 +1,3 @@
1
1
  Ariel Patschiki <arielpts@me.com>
2
- Gustavo Henrique Mascarenhas Machado <guhemama@gmail.com>
2
+ Gustavo Henrique Mascarenhas Machado <guhemama@gmail.com>
3
+ Vinicius da Cunha Ferreira <vinivcf@gmail.com>
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # EBANX Ruby gem [![Build Status](https://travis-ci.org/ebanx-integration/ebanx-ruby.svg?branch=master)](https://travis-ci.org/ebanx-integration/ebanx-ruby) [![Code Climate](https://codeclimate.com/github/ebanx-integration/ebanx-ruby/badges/gpa.svg)](https://codeclimate.com/github/ebanx-integration/ebanx-ruby) [![Test Coverage](https://codeclimate.com/github/ebanx-integration/ebanx-ruby/badges/coverage.svg)](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 = ebanx.do_direct {
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
@@ -1,3 +1,4 @@
1
+ require 'bundler'
1
2
  require 'bundler/gem_tasks'
2
3
  require 'rake/testtask'
3
4
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.1
1
+ 1.3.2
@@ -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', '~> 1.7.3'
26
+ spec.add_dependency 'rest-client' , '~> 2.0.2'
27
27
  spec.add_dependency 'json'
28
28
  end
@@ -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
- case command.request_method
68
- when :post
69
- response = RestClient.post uri, command.params, content_type: command.response_type
70
- when :get
71
- response = RestClient.get uri, params: command.params
72
- else
73
- raise ArgumentError "Request method #{command.request_method.to_s} is not supported."
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
@@ -13,4 +13,4 @@ module Ebanx
13
13
  end
14
14
  end
15
15
  end
16
- end
16
+ end
@@ -13,4 +13,4 @@ module Ebanx
13
13
  end
14
14
  end
15
15
  end
16
- end
16
+ end
@@ -23,18 +23,32 @@ module Ebanx
23
23
  raise NotImplementedError
24
24
  end
25
25
 
26
- def validate_presence(name)
27
- raise ArgumentError unless @params.include? name
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
@@ -15,4 +15,4 @@ module Ebanx
15
15
  end
16
16
  end
17
17
  end
18
- end
18
+ end
@@ -16,4 +16,4 @@ module Ebanx
16
16
  end
17
17
  end
18
18
  end
19
- end
19
+ end
@@ -14,4 +14,4 @@ module Ebanx
14
14
  end
15
15
  end
16
16
  end
17
- end
17
+ end
@@ -16,4 +16,4 @@ module Ebanx
16
16
  end
17
17
  end
18
18
  end
19
- end
19
+ end
@@ -13,4 +13,4 @@ module Ebanx
13
13
  end
14
14
  end
15
15
  end
16
- end
16
+ end
@@ -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 = :get
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
@@ -12,4 +12,4 @@ module Ebanx
12
12
  end
13
13
  end
14
14
  end
15
- end
15
+ end
@@ -3,7 +3,7 @@ module Ebanx
3
3
  class GetMerchantSettlementExtract < Command
4
4
  def initialize(params)
5
5
  @params = params
6
- @request_method = :get
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
@@ -12,4 +12,4 @@ module Ebanx
12
12
  end
13
13
  end
14
14
  end
15
- end
15
+ 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,14 @@
1
+ module Ebanx
2
+ module Command
3
+ class PayoutBalance < Command
4
+ def initialize(params)
5
+ @params = params
6
+ @request_method = :post
7
+ @request_action = 'payout/balance'
8
+ @response_type = :json
9
+ end
10
+ def validate
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ module Ebanx
2
+ module Command
3
+ class PayoutBankDetails < Command
4
+ def initialize()
5
+ @request_method = :post
6
+ @request_action = 'payout/bankdetails'
7
+ @response_type = :json
8
+ end
9
+
10
+ def validate
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ module Ebanx
2
+ module Command
3
+ class PayoutBanks < Command
4
+ def initialize()
5
+ @request_method = :post
6
+ @request_action = 'payout/banks'
7
+ @response_type = :json
8
+ end
9
+
10
+ def validate
11
+ end
12
+ end
13
+ end
14
+ 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
@@ -13,4 +13,4 @@ module Ebanx
13
13
  end
14
14
  end
15
15
  end
16
- end
16
+ end
@@ -13,4 +13,4 @@ module Ebanx
13
13
  end
14
14
  end
15
15
  end
16
- end
16
+ end
@@ -23,4 +23,4 @@ module Ebanx
23
23
  end
24
24
  end
25
25
  end
26
- end
26
+ end
@@ -14,4 +14,4 @@ module Ebanx
14
14
  end
15
15
  end
16
16
  end
17
- end
17
+ end
@@ -16,6 +16,10 @@ module Ebanx
16
16
  validate_presence :email
17
17
  validate_presence :payment_type_code
18
18
  end
19
+
20
+ def params
21
+ @params.to_json
22
+ end
19
23
  end
20
24
  end
21
- end
25
+ end
@@ -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
@@ -15,4 +15,4 @@ module Ebanx
15
15
  end
16
16
  end
17
17
  end
18
- end
18
+ end
@@ -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
@@ -13,4 +13,4 @@ module Ebanx
13
13
  end
14
14
  end
15
15
  end
16
- end
16
+ end
@@ -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
@@ -0,0 +1,9 @@
1
+ class EbanxApiException < StandardError
2
+ attr_accessor :response, :http_code
3
+
4
+ def initialize(message, response, http_code)
5
+ super(message)
6
+ @response = response
7
+ @http_code = http_code
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module Ebanx
2
- VERSION = '1.3.1'
2
+ VERSION = '1.3.2'
3
3
  end
@@ -4,4 +4,4 @@ describe Ebanx::Command::Cancel do
4
4
  it "can't run without arguments" do
5
5
  lambda { ebanx.do_cancel }.must_raise ArgumentError
6
6
  end
7
- end
7
+ end
@@ -0,0 +1,7 @@
1
+ require_relative '../test_helper'
2
+
3
+ describe Ebanx::Command::PayoutCancel do
4
+ it "can't run without arguments" do
5
+ lambda { ebanx.do_payout_cancel }.must_raise ArgumentError
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require_relative '../test_helper'
2
+
3
+ describe Ebanx::Command::TransferCancel do
4
+ it "can't run without arguments" do
5
+ lambda { ebanx.do_transfer_cancel }.must_raise ArgumentError
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require_relative '../test_helper'
2
+
3
+ describe Ebanx::Command::PayoutCommit do
4
+ it "can't run without arguments" do
5
+ lambda { ebanx.do_payout_commit }.must_raise ArgumentError
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require_relative '../test_helper'
2
+
3
+ describe Ebanx::Command::TransferCommit do
4
+ it "can't run without arguments" do
5
+ lambda { ebanx.do_transfer_commit }.must_raise ArgumentError
6
+ end
7
+ end
@@ -38,4 +38,4 @@ describe Ebanx::Command::CreateMerchantSettlementRequest do
38
38
  response.http_code.must_equal 200
39
39
  response.response['status'].must_equal 'SUCCESS'
40
40
  end
41
- end
41
+ end
@@ -0,0 +1,7 @@
1
+ require_relative '../test_helper'
2
+
3
+ describe Ebanx::Command::PayoutCreate do
4
+ it "can't run without arguments" do
5
+ lambda { ebanx.do_payout_create }.must_raise ArgumentError
6
+ end
7
+ end
@@ -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
@@ -33,4 +33,4 @@ describe Ebanx::Command::Direct do
33
33
  response.http_code.must_equal 200
34
34
  response.response['status'].must_equal 'SUCCESS'
35
35
  end
36
- end
36
+ end
@@ -52,4 +52,4 @@ describe Ebanx::Command::EditMerchantIntegrationProperties do
52
52
  response.http_code.must_equal 200
53
53
  response.response['status'].must_equal 'SUCCESS'
54
54
  end
55
- end
55
+ 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
@@ -11,4 +11,4 @@ describe Ebanx::Command::GetMerchantAmountBalanceByCountry do
11
11
  it "can't run without arguments" do
12
12
  lambda { ebanx.do_get_merchant_amount_balance_by_country }.must_raise ArgumentError
13
13
  end
14
- end
14
+ end
@@ -7,4 +7,4 @@ describe Ebanx::Command::GetMerchantIntegrationProperties do
7
7
  response.http_code.must_equal 200
8
8
  response.response['status'].must_equal 'SUCCESS'
9
9
  end
10
- end
10
+ end
@@ -18,4 +18,4 @@ describe Ebanx::Command::GetMerchantSettlementExtract do
18
18
  response.http_code.must_equal 200
19
19
  response.response['status'].must_equal 'SUCCESS'
20
20
  end
21
- end
21
+ end
@@ -7,4 +7,4 @@ describe Ebanx::Command::GetMerchantSettlementInfo do
7
7
  response.http_code.must_equal 200
8
8
  response.response['status'].must_equal 'SUCCESS'
9
9
  end
10
- end
10
+ 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,8 @@
1
+ require_relative '../test_helper'
2
+
3
+ describe Ebanx::Command::PayoutBankDetails do
4
+ it "performs a successful" do
5
+ response = ebanx.do_payout_bank_details
6
+ response.http_code.must_equal 200
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ require_relative '../test_helper'
2
+
3
+ describe Ebanx::Command::PayoutBanks do
4
+ it "performs a successful" do
5
+ response = ebanx.do_payout_banks
6
+ response.http_code.must_equal 200
7
+ end
8
+ end
@@ -21,4 +21,4 @@ describe Ebanx::Command::Request do
21
21
  response.http_code.must_equal 200
22
22
  response.response['status'].must_equal 'SUCCESS'
23
23
  end
24
- end
24
+ 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,7 @@
1
+ require_relative '../test_helper'
2
+
3
+ describe Ebanx::Command::PayoutRetrieve do
4
+ it "can't run without arguments" do
5
+ lambda { ebanx.do_payout_retrieve }.must_raise ArgumentError
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require_relative '../test_helper'
2
+
3
+ describe Ebanx::Command::TransferRetrieve do
4
+ it "can't run without arguments" do
5
+ lambda { ebanx.do_transfer_retrieve }.must_raise ArgumentError
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require_relative '../test_helper'
2
+
3
+ describe Ebanx::Command::PayoutSearch do
4
+ it "can't run without arguments" do
5
+ lambda { ebanx.do_payout_search }.must_raise ArgumentError
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require_relative '../test_helper'
2
+
3
+ describe Ebanx::Command::TransferSearch do
4
+ it "can't run without arguments" do
5
+ lambda { ebanx.do_transfer_search }.must_raise ArgumentError
6
+ end
7
+ 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
@@ -17,4 +17,4 @@ describe Ebanx::Command::Zipcode do
17
17
  response.http_code.must_equal 200
18
18
  response.response['status'].must_equal 'SUCCESS'
19
19
  end
20
- end
20
+ end
@@ -1,6 +1,6 @@
1
1
  if ENV['CODECLIMATE_REPO_TOKEN']
2
- require 'codeclimate-test-reporter'
3
- CodeClimate::TestReporter.start
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.1
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: 2016-09-29 00:00:00.000000000 Z
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: 1.7.3
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: 1.7.3
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.4.5
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