bs2_api 1.4.1 → 1.5.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: 9e4d7f6e459c54a97638a2dbaab2b78116db4eef72f4f1249901d35193061a4a
4
- data.tar.gz: a246e42a43100320dea1df879c059d4b91db38a5987d6a3a00d7dce9522f4590
3
+ metadata.gz: 5ad83195aa09b4ddbe8e9860c63f16ac1fe93429f14e243eebcc611c643f886d
4
+ data.tar.gz: 64c37b6828752620d665c60da3a5db499effc88ddf227f806387dad4e54fe098
5
5
  SHA512:
6
- metadata.gz: 6fc63cb91a06046febcb71fc20ee3e8344cd4c28b676e5453e228f080de4b518de89d3f76870f7b8d5bcfba5e27d02ce992ea0b2f8e9dd94215bd1a86650832c
7
- data.tar.gz: 636f5d7ccb751c66fd5ba9a2cbcd06f545f62d0bac02f8b302c4998128c34c09e3c1d811382b7f1dffb156eca69781b1eec38b8c731cc09a6df8782f36405fde
6
+ metadata.gz: 52cff9953cb6a4a5c60c0c3c7488415ce962d256dc6af90959d2c195009bc6c53a3285d9026667557854a50bdf58d51aa9b26987bf9de2967b9c07395ffa12e7
7
+ data.tar.gz: e30185ccb6d3ce95bec3679e79a27c9c7e4f2a6e13cd1f8819b02aaf33f8d6f9a47d9d5fc5f1eaa44cccabb7ea34b12d6965f155823b176b475bee0bf8180763
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bs2_api (1.4.1)
4
+ bs2_api (1.5.0)
5
5
  activesupport
6
6
  builder
7
7
  bundler
@@ -14,4 +14,4 @@ class Configuration
14
14
 
15
15
  true
16
16
  end
17
- end
17
+ end
@@ -4,4 +4,4 @@ module Bs2Api
4
4
  module Errors
5
5
  class BadRequest < Base; end
6
6
  end
7
- end
7
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bs2Api
4
+ module Errors
5
+ class RefundError < Base; end
6
+ end
7
+ end
@@ -3,7 +3,13 @@
3
3
  module Bs2Api
4
4
  module Payment
5
5
  class Key < Base
6
- def initialize key
6
+ def initialize(
7
+ key,
8
+ client_id: Bs2Api.configuration.client_id,
9
+ client_secret: Bs2Api.configuration.client_secret
10
+ )
11
+ @client_id = client_id
12
+ @client_secret = client_secret
7
13
  @key = key
8
14
  end
9
15
 
@@ -3,7 +3,14 @@
3
3
  module Bs2Api
4
4
  module Payment
5
5
  class Manual < Base
6
- def initialize bank
6
+ def initialize(
7
+ bank,
8
+ client_id: Bs2Api.configuration.client_id,
9
+ client_secret: Bs2Api.configuration.client_secret
10
+ )
11
+
12
+ @client_id = client_id
13
+ @client_secret = client_secret
7
14
  raise Bs2Api::Errors::InvalidBank, 'Invalid Bank' unless bank.is_a?(Bs2Api::Entities::Bank)
8
15
  @bank = bank
9
16
  end
@@ -20,4 +27,4 @@ module Bs2Api
20
27
  end
21
28
  end
22
29
  end
23
- end
30
+ end
@@ -19,7 +19,6 @@ module Bs2Api
19
19
 
20
20
  def call
21
21
  url = "#{Bs2Api.endpoint}/pix/direto/forintegration/v1/recebimentos/#{@end_to_end_id}/recebimento"
22
-
23
22
  access_token = Bs2Api::Request::Auth.token(
24
23
  client_id: @client_id,
25
24
  client_secret: @client_secret
@@ -29,7 +29,6 @@ module Bs2Api
29
29
  client_secret: @client_secret
30
30
  )
31
31
 
32
- # TODO: is PUT the right method?
33
32
  response = HTTParty.put(
34
33
  url,
35
34
  http_proxyaddr: @proxy&.host,
@@ -42,11 +41,11 @@ module Bs2Api
42
41
  'Authorization' => "Bearer #{access_token}",
43
42
  },
44
43
  body: {
45
- valor: value
44
+ valor: @value
46
45
  }.to_json
47
46
  )
48
47
 
49
- raise response.body unless response.success?
48
+ raise Bs2Api::Errors::RefundError, response.body.to_s unless response.success?
50
49
 
51
50
  response.body
52
51
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bs2Api
4
- VERSION = '1.4.1'
4
+ VERSION = '1.5.0'
5
5
  end
data/lib/bs2_api.rb CHANGED
@@ -16,6 +16,7 @@ require 'bs2_api/errors/invalid_pix_key'
16
16
  require 'bs2_api/errors/invalid_bank'
17
17
  require 'bs2_api/errors/invalid_customer'
18
18
  require 'bs2_api/errors/missing_configuration'
19
+ require 'bs2_api/errors/refund_error'
19
20
  require 'bs2_api/errors/unauthorized'
20
21
  require 'bs2_api/errors/bad_request'
21
22
  require 'bs2_api/errors/server_error'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bs2_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kim Pastro
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-06-30 00:00:00.000000000 Z
11
+ date: 2022-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: builder
@@ -216,6 +216,7 @@ files:
216
216
  - lib/bs2_api/errors/invalid_pix_key.rb
217
217
  - lib/bs2_api/errors/missing_bank.rb
218
218
  - lib/bs2_api/errors/missing_configuration.rb
219
+ - lib/bs2_api/errors/refund_error.rb
219
220
  - lib/bs2_api/errors/server_error.rb
220
221
  - lib/bs2_api/errors/unauthorized.rb
221
222
  - lib/bs2_api/payment/async.rb