bs2_api 1.6.0 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f216fd8e2feeeeb8f8223e820839c1b7be43ab4f360946fb9fbeb6c3282237e0
4
- data.tar.gz: 7c30ce3c1b8e31f0c97aa744d46f6462d36eadaee7f2acb84086fe5af4aae26b
3
+ metadata.gz: 7455eef55c86c81150fae145f2e570ce1e88a1c36276b1dfd7e381e7431a3283
4
+ data.tar.gz: 17247bbba1a6db2d7c385333ab57be1d61532563ea3a807ff24aa4ef65c80e32
5
5
  SHA512:
6
- metadata.gz: 285edcdb49d779a6de9a8c36b1f16588d46e44c993db5c00e733f8946a000e3ffed6429a81bfeefa1d74152d6baa84dad8400e00b209943df3231f96846f2ec0
7
- data.tar.gz: e6b1affdd5cc0c84005f68d9d723b83faba9cced4f606fdebc10164f2ba309442a37103dada2b7da8409e40f916f7978ed9d716d9065190b7cd507f717579a1d
6
+ metadata.gz: 5b21aa07c3a5395db419b07e389f0298f00ebb0dab899e628b39f71da73c783f0144305045ef9f07a3271a68b3b34a6100e43166c9c1928f2835f461f521fab8
7
+ data.tar.gz: 54a5dcc93e7488d9ad833bb480cdad8def6f99d64063f5aabaf5691ac37e7245b7d60c323096d13c864af46b68bdd3883c7f32171123ddad66f12a531b358e67
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bs2_api (1.5.1)
4
+ bs2_api (1.6.0)
5
5
  activesupport
6
6
  builder
7
7
  bundler
@@ -68,6 +68,14 @@ module Bs2Api
68
68
  def error?
69
69
  @status == :error
70
70
  end
71
+
72
+ def awaiting_validation?
73
+ @status == :awaiting_validation
74
+ end
75
+
76
+ def in_process?
77
+ @status == :in_process
78
+ end
71
79
  end
72
80
  end
73
81
  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
- url = request_status_url(request_id)
27
+
27
28
  bearer_token = Bs2Api::Request::Auth.token(
28
29
  client_id: client_id,
29
30
  client_secret: client_secret
30
31
  )
31
- headers = { 'Authorization': "Bearer #{bearer_token}" }
32
- response = HTTParty.get(url, headers: headers)
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
 
@@ -29,7 +29,14 @@ module Bs2Api
29
29
  end
30
30
 
31
31
  def detail_request
32
- HTTParty.get(url, headers: headers)
32
+ HTTParty.get(
33
+ url,
34
+ headers: headers,
35
+ http_proxyaddr: @proxy&.host,
36
+ http_proxyport: @proxy&.port,
37
+ http_proxyuser: @proxy&.user,
38
+ http_proxypass: @proxy&.password
39
+ )
33
40
  end
34
41
 
35
42
  def bearer_token
@@ -6,7 +6,7 @@ module Bs2Api
6
6
  'EM_PROCESSAMENTO' => :processing,
7
7
  'DEVOLVIDO' => :refunded,
8
8
  'NAO_REALIZADO' => :not_achieved,
9
- }.transform_keys(&:downcase).freeze
9
+ }.freeze
10
10
 
11
11
  def initialize(
12
12
  client_id:,
@@ -46,7 +46,7 @@ module Bs2Api
46
46
 
47
47
  raise response.body unless response.success?
48
48
 
49
- response.body
49
+ JSON.parse(response.body)
50
50
  end
51
51
 
52
52
  def status
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bs2Api
4
- VERSION = '1.6.0'
4
+ VERSION = '1.7.0'
5
5
  end
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.6.0
4
+ version: 1.7.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-01 00:00:00.000000000 Z
11
+ date: 2022-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: builder