boletosimples 1.0.2 → 1.0.3
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 +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +2 -0
- data/lib/boletosimples.rb +1 -0
- data/lib/boletosimples/configuration.rb +7 -1
- data/lib/boletosimples/middlewares/debug.rb +30 -0
- data/lib/boletosimples/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5047dd925f3b36110d38363bd557b1e2e0485c11106663e515aaa995c9678bf8
|
4
|
+
data.tar.gz: 0612c53269469fc2288bed2a0ae12b54fa31cccecfe2e0adbb5fb6dcb7dc6ea4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c091d334a34ea8c8fd8bd2e3fe7af7d3143fe53c1357f7453d27e0aaa9a416858bd7f3eef37fc346596169226d5b0ac1badfe3ab08d7024c3f5b3b4977f74f47
|
7
|
+
data.tar.gz: f170c056e9d3cd25363e2321ac3e277bd4c06aa65f03ed88406d874bf16d6723cfb1d57b444aa28d7b24e9d0664ad26c29ba18bc03abf254db2ece277224740e
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -34,6 +34,7 @@ BoletoSimples.configure do |c|
|
|
34
34
|
# sandbox - https://sandbox.boletosimples.com.br/conta/api/tokens
|
35
35
|
c.api_token = 'api-token'
|
36
36
|
c.user_agent = 'email@minhaempresa.com.br' #Colocar um e-mail válido para contatos técnicos relacionado ao uso da API.
|
37
|
+
# c.debug = true
|
37
38
|
end
|
38
39
|
```
|
39
40
|
|
@@ -44,6 +45,7 @@ Você também pode configurar as variáveis de ambiente a seguir e não será ne
|
|
44
45
|
```bash
|
45
46
|
ENV['BOLETOSIMPLES_ENV']
|
46
47
|
ENV['BOLETOSIMPLES_API_TOKEN']
|
48
|
+
ENV['BOLETOSIMPLES_DEBUG']
|
47
49
|
```
|
48
50
|
|
49
51
|
### Configurando cache
|
data/lib/boletosimples.rb
CHANGED
@@ -34,6 +34,7 @@ module BoletoSimples
|
|
34
34
|
autoload :UserAgent, 'boletosimples/middlewares/user_agent'
|
35
35
|
autoload :RaiseError, 'boletosimples/middlewares/raise_error'
|
36
36
|
autoload :LastRequest, 'boletosimples/middlewares/last_request'
|
37
|
+
autoload :Debug, 'boletosimples/middlewares/debug'
|
37
38
|
autoload :Bearer, 'boletosimples/middlewares/bearer'
|
38
39
|
end
|
39
40
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module BoletoSimples
|
4
4
|
class Configuration
|
5
|
-
attr_accessor :environment, :cache, :user_agent, :api_token
|
5
|
+
attr_accessor :environment, :cache, :user_agent, :api_token, :debug
|
6
6
|
|
7
7
|
BASE_URI = {
|
8
8
|
sandbox: 'https://sandbox.boletosimples.com.br/api/v1',
|
@@ -15,6 +15,7 @@ module BoletoSimples
|
|
15
15
|
@api_token = ENV['BOLETOSIMPLES_API_TOKEN']
|
16
16
|
@user_agent = ENV['BOLETOSIMPLES_USER_AGENT']
|
17
17
|
@cache = nil
|
18
|
+
@debug = ENV['BOLETOSIMPLES_DEBUG']
|
18
19
|
end
|
19
20
|
|
20
21
|
def base_uri
|
@@ -25,6 +26,10 @@ module BoletoSimples
|
|
25
26
|
!@api_token.nil?
|
26
27
|
end
|
27
28
|
|
29
|
+
def debug?
|
30
|
+
!@debug.nil?
|
31
|
+
end
|
32
|
+
|
28
33
|
def setup_her
|
29
34
|
Her::API.setup url: base_uri do |c|
|
30
35
|
# Request
|
@@ -36,6 +41,7 @@ module BoletoSimples
|
|
36
41
|
c.use Faraday::HttpCache, store: cache unless cache.nil?
|
37
42
|
|
38
43
|
# Response
|
44
|
+
c.use BoletoSimples::Middleware::Debug if debug?
|
39
45
|
c.use BoletoSimples::Middleware::LastRequest
|
40
46
|
c.use BoletoSimples::Middleware::RaiseError
|
41
47
|
c.use Her::Middleware::DefaultParseJSON
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BoletoSimples
|
4
|
+
module Middleware
|
5
|
+
class Debug < Faraday::Response::Middleware
|
6
|
+
def initialize(app, logger = nil)
|
7
|
+
super(app)
|
8
|
+
@logger = logger || begin
|
9
|
+
require 'logger'
|
10
|
+
::Logger.new($stdout)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def on_complete(env)
|
15
|
+
@logger.info "\n::#{env[:method].upcase} #{env[:url]}"
|
16
|
+
@logger.info ' Request'
|
17
|
+
env[:request_headers].each do |key, value|
|
18
|
+
@logger.info " -- #{key}: #{value}"
|
19
|
+
end
|
20
|
+
@logger.info ' Response'
|
21
|
+
@logger.info " -- Status: #{env[:status]}"
|
22
|
+
env[:response_headers].each do |key, value|
|
23
|
+
@logger.info " -- #{key}: #{value}"
|
24
|
+
end
|
25
|
+
@logger.info ' Response body'
|
26
|
+
@logger.info " -- #{env[:body]} \n"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: boletosimples
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kivanio Barbosa
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2021-04-
|
13
|
+
date: 2021-04-20 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: faraday-http-cache
|
@@ -252,6 +252,7 @@ files:
|
|
252
252
|
- lib/boletosimples/configuration.rb
|
253
253
|
- lib/boletosimples/last_request.rb
|
254
254
|
- lib/boletosimples/middlewares/bearer.rb
|
255
|
+
- lib/boletosimples/middlewares/debug.rb
|
255
256
|
- lib/boletosimples/middlewares/last_request.rb
|
256
257
|
- lib/boletosimples/middlewares/raise_error.rb
|
257
258
|
- lib/boletosimples/middlewares/user_agent.rb
|