bs2_api 1.8.0 → 1.9.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8449060cc6217780e2b9a1e3698d79c998e141d919765b2c9573d5f350594f66
4
- data.tar.gz: c045fd2971f93c19b18fc764dd6328c1e08d3fe430e7c5505d1afc24ecb7db2d
3
+ metadata.gz: e227d119f3349c177684b484c96511b5777c5812c8f120cf10051fe9a1abcdba
4
+ data.tar.gz: 3affe7ed09839958dbeac84a9e7db055985b51aec44f2d6e7538aa58bf863c2a
5
5
  SHA512:
6
- metadata.gz: 6929c953e3ff67fee1d6b118b72f611eee5e23b1172d47afdd209cd121616ab6b5468249e2e71e267830206a2f918b3171163d56ac025f8d119c18134ccd888f
7
- data.tar.gz: 89fe2992dc08bcf58adfc42f9f4d7ac3ba8c97a344e6f61e35905794a279d695c6cc4d5d5c78e865263b5c92b855e1d8404b4072563e9d2f4f4693d3a0588e50
6
+ metadata.gz: 4d4f791b5a21950626dfc1c010b0fd28cb9bb515fee03237de78456f0d93bf5d5bfb655e9112bed81ca176fbd8a5e1e7464fb43870e517e0c4a37ca7c3ca768d
7
+ data.tar.gz: ed0d0cddde24d0d1edb6e492e244a9708342a2f45ee38fef59e9dc6e6ae89aec8f25aa739fad1a959dba9831b19eb28266fe43292f59a27b508474e7789a3ced
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bs2_api (1.7.0)
4
+ bs2_api (1.9.0)
5
5
  activesupport
6
6
  builder
7
7
  bundler
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bs2Api
4
+ module Entities
5
+ class Error
6
+ attr_accessor :code, :description
7
+
8
+ def initialize(args = {})
9
+ @code = args.fetch(:code, nil)
10
+ @description = args.fetch(:description, nil)
11
+ end
12
+
13
+ def to_hash
14
+ hash_data = {
15
+ "erroCodigo": @code,
16
+ "erroDescricao": @description
17
+ }
18
+
19
+ ActiveSupport::HashWithIndifferentAccess.new(hash_data)
20
+ end
21
+
22
+ def self.from_response(hash_payload)
23
+ return {} if hash_payload.blank?
24
+
25
+ hash = ActiveSupport::HashWithIndifferentAccess.new(hash_payload)
26
+ Bs2Api::Entities::Error.new(
27
+ code: hash['erroCodigo'],
28
+ description: hash['erroDescricao']
29
+ )
30
+ end
31
+ end
32
+ end
33
+ end
@@ -3,7 +3,7 @@
3
3
  module Bs2Api
4
4
  module Entities
5
5
  class Payment
6
- attr_accessor :payment_id, :end_to_end_id, :receiver, :payer, :status, :error_message, :error_code
6
+ attr_accessor :payment_id, :end_to_end_id, :receiver, :payer, :status, :error
7
7
 
8
8
  def initialize(args = {})
9
9
  @payment_id = args.fetch(:payment_id, nil)
@@ -11,21 +11,19 @@ module Bs2Api
11
11
  @receiver = args.fetch(:receiver, nil)
12
12
  @payer = args.fetch(:payer, nil)
13
13
  @status = args.fetch(:status, nil)
14
- @error_code = args.fetch(:error_code, nil)
15
- @error_message = args.fetch(:error_message, nil)
14
+ @error = args.fetch(:error, nil)
16
15
  end
17
16
 
18
17
  def to_hash
19
18
  hash_data = {
20
- "pagamentoId": @payment_id,
21
- "endToEndId": @end_to_end_id,
22
- "status": @status,
23
- "error_code": @error_code,
24
- "error_message": @error_message
19
+ "pagamentoId": @payment_id,
20
+ "endToEndId": @end_to_end_id,
21
+ "status": @status
25
22
  }
26
23
 
27
24
  hash_data.merge!({ "recebedor": @receiver.to_hash } ) if @receiver.present?
28
25
  hash_data.merge!({ "pagador": @payer.to_hash } ) if @payer.present?
26
+ hash_data.merge!({ "erro": @error.to_hash } ) if @error.present?
29
27
  ActiveSupport::HashWithIndifferentAccess.new(hash_data)
30
28
  end
31
29
 
@@ -38,8 +36,7 @@ module Bs2Api
38
36
  receiver: Bs2Api::Entities::Bank.from_response(hash["recebedor"]),
39
37
  payer: Bs2Api::Entities::Bank.from_response(hash["pagador"]),
40
38
  status: hash["status"],
41
- error_code: hash.dig('erro', 'erroCodigo'),
42
- error_message: hash.dig('erro', 'erroDescricao')
39
+ error: Bs2Api::Entities::Error.from_response(hash["erro"])
43
40
  )
44
41
  end
45
42
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bs2Api
4
- VERSION = '1.8.0'
4
+ VERSION = '1.9.0'
5
5
  end
data/lib/bs2_api.rb CHANGED
@@ -25,6 +25,7 @@ require 'bs2_api/errors/missing_bank'
25
25
 
26
26
  require 'bs2_api/entities/account'
27
27
  require 'bs2_api/entities/bank'
28
+ require 'bs2_api/entities/error'
28
29
  require 'bs2_api/entities/customer'
29
30
  require 'bs2_api/entities/payment'
30
31
  require 'bs2_api/entities/pix_key'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bs2_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 1.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kim Pastro
@@ -207,6 +207,7 @@ files:
207
207
  - lib/bs2_api/entities/async_status.rb
208
208
  - lib/bs2_api/entities/bank.rb
209
209
  - lib/bs2_api/entities/customer.rb
210
+ - lib/bs2_api/entities/error.rb
210
211
  - lib/bs2_api/entities/payment.rb
211
212
  - lib/bs2_api/entities/pix_key.rb
212
213
  - lib/bs2_api/errors/bad_request.rb