bs2_api 1.6.2 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.tool-versions +1 -0
- data/Gemfile.lock +1 -1
- data/bs2_api.gemspec +1 -1
- data/lib/bs2_api/entities/async_status.rb +8 -0
- data/lib/bs2_api/entities/error.rb +33 -0
- data/lib/bs2_api/entities/payment.rb +5 -2
- data/lib/bs2_api/payment/async.rb +17 -4
- data/lib/bs2_api/version.rb +1 -1
- data/lib/bs2_api.rb +1 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e227d119f3349c177684b484c96511b5777c5812c8f120cf10051fe9a1abcdba
|
4
|
+
data.tar.gz: 3affe7ed09839958dbeac84a9e7db055985b51aec44f2d6e7538aa58bf863c2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d4f791b5a21950626dfc1c010b0fd28cb9bb515fee03237de78456f0d93bf5d5bfb655e9112bed81ca176fbd8a5e1e7464fb43870e517e0c4a37ca7c3ca768d
|
7
|
+
data.tar.gz: ed0d0cddde24d0d1edb6e492e244a9708342a2f45ee38fef59e9dc6e6ae89aec8f25aa739fad1a959dba9831b19eb28266fe43292f59a27b508474e7789a3ced
|
data/.gitignore
CHANGED
data/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 2.7.2
|
data/Gemfile.lock
CHANGED
data/bs2_api.gemspec
CHANGED
@@ -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
|
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,6 +11,7 @@ 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 = args.fetch(:error, nil)
|
14
15
|
end
|
15
16
|
|
16
17
|
def to_hash
|
@@ -22,6 +23,7 @@ module Bs2Api
|
|
22
23
|
|
23
24
|
hash_data.merge!({ "recebedor": @receiver.to_hash } ) if @receiver.present?
|
24
25
|
hash_data.merge!({ "pagador": @payer.to_hash } ) if @payer.present?
|
26
|
+
hash_data.merge!({ "erro": @error.to_hash } ) if @error.present?
|
25
27
|
ActiveSupport::HashWithIndifferentAccess.new(hash_data)
|
26
28
|
end
|
27
29
|
|
@@ -33,7 +35,8 @@ module Bs2Api
|
|
33
35
|
end_to_end_id: hash["endToEndId"],
|
34
36
|
receiver: Bs2Api::Entities::Bank.from_response(hash["recebedor"]),
|
35
37
|
payer: Bs2Api::Entities::Bank.from_response(hash["pagador"]),
|
36
|
-
status: hash["status"]
|
38
|
+
status: hash["status"],
|
39
|
+
error: Bs2Api::Entities::Error.from_response(hash["erro"])
|
37
40
|
)
|
38
41
|
end
|
39
42
|
end
|
@@ -21,15 +21,28 @@ module Bs2Api
|
|
21
21
|
def check_payment_status(
|
22
22
|
request_id,
|
23
23
|
client_id: Bs2Api.configuration.client_id,
|
24
|
-
client_secret: Bs2Api.configuration.client_secret
|
24
|
+
client_secret: Bs2Api.configuration.client_secret,
|
25
|
+
proxy: nil
|
25
26
|
)
|
26
|
-
|
27
|
+
|
27
28
|
bearer_token = Bs2Api::Request::Auth.token(
|
28
29
|
client_id: client_id,
|
29
30
|
client_secret: client_secret
|
30
31
|
)
|
31
|
-
|
32
|
-
response = HTTParty.get(
|
32
|
+
|
33
|
+
response = HTTParty.get(
|
34
|
+
request_status_url(request_id),
|
35
|
+
http_proxyaddr: proxy&.host,
|
36
|
+
http_proxyport: proxy&.port,
|
37
|
+
http_proxyuser: proxy&.user,
|
38
|
+
http_proxypass: proxy&.password,
|
39
|
+
headers: {
|
40
|
+
'Authorization': "Bearer #{bearer_token}"
|
41
|
+
}
|
42
|
+
)
|
43
|
+
|
44
|
+
raise Bs2Api::Errors::Base, response.body.to_s unless response.success?
|
45
|
+
|
33
46
|
Bs2Api::Entities::AsyncStatus.from_response response.parsed_response
|
34
47
|
end
|
35
48
|
|
data/lib/bs2_api/version.rb
CHANGED
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,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
|
+
version: 1.9.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-07-
|
11
|
+
date: 2022-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: builder
|
@@ -188,6 +188,7 @@ files:
|
|
188
188
|
- ".gitignore"
|
189
189
|
- ".rspec"
|
190
190
|
- ".ruby-version"
|
191
|
+
- ".tool-versions"
|
191
192
|
- CHANGELOG.md
|
192
193
|
- Gemfile
|
193
194
|
- Gemfile.lock
|
@@ -206,6 +207,7 @@ files:
|
|
206
207
|
- lib/bs2_api/entities/async_status.rb
|
207
208
|
- lib/bs2_api/entities/bank.rb
|
208
209
|
- lib/bs2_api/entities/customer.rb
|
210
|
+
- lib/bs2_api/entities/error.rb
|
209
211
|
- lib/bs2_api/entities/payment.rb
|
210
212
|
- lib/bs2_api/entities/pix_key.rb
|
211
213
|
- lib/bs2_api/errors/bad_request.rb
|