boletosimples 1.0.3 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/README.md +10 -8
- data/lib/boletosimples/configuration.rb +10 -8
- data/lib/boletosimples/last_request.rb +5 -1
- data/lib/boletosimples/middlewares/custom_headers.rb +12 -0
- data/lib/boletosimples/response_error.rb +2 -2
- data/lib/boletosimples/version.rb +1 -1
- data/lib/boletosimples.rb +1 -0
- data/spec/boletosimples/configuration_spec.rb +87 -70
- data/spec/boletosimples/last_request_spec.rb +1 -0
- data/spec/boletosimples/middlewares/custom_headers_spec.rb +26 -0
- data/spec/boletosimples/resources/bank_billet_spec.rb +2 -2
- data/spec/boletosimples/resources/customer_spec.rb +9 -4
- data/spec/boletosimples/resources/customer_subscription_spec.rb +1 -1
- data/spec/boletosimples/resources/installment_spec.rb +1 -1
- data/spec/fixtures/discharge.RET +3 -3
- data/spec/fixtures/vcr_cassettes/custom_headers.yml +113 -0
- data/spec/fixtures/vcr_cassettes/last_request/bank_billets.yml +386 -520
- data/spec/fixtures/vcr_cassettes/resources/bank_billet/all.yml +78 -522
- data/spec/fixtures/vcr_cassettes/resources/bank_billet/cancel/success.yml +30 -12
- data/spec/fixtures/vcr_cassettes/resources/bank_billet/create/invalid_params.yml +32 -16
- data/spec/fixtures/vcr_cassettes/resources/bank_billet/create/invalid_root.yml +31 -15
- data/spec/fixtures/vcr_cassettes/resources/bank_billet/create/valid.yml +42 -28
- data/spec/fixtures/vcr_cassettes/resources/bank_billet/duplicate/success.yml +41 -27
- data/spec/fixtures/vcr_cassettes/resources/bank_billet/find.yml +46 -31
- data/spec/fixtures/vcr_cassettes/resources/bank_billet_account/all.yml +47 -103
- data/spec/fixtures/vcr_cassettes/resources/bank_billet_account/create/invalid_params.yml +31 -15
- data/spec/fixtures/vcr_cassettes/resources/bank_billet_account/create/invalid_root.yml +31 -15
- data/spec/fixtures/vcr_cassettes/resources/bank_billet_account/create/valid.yml +35 -19
- data/spec/fixtures/vcr_cassettes/resources/bank_billet_account/find.yml +35 -19
- data/spec/fixtures/vcr_cassettes/resources/bank_billet_discharge/all.yml +35 -41
- data/spec/fixtures/vcr_cassettes/resources/bank_billet_payment/all.yml +73 -72
- data/spec/fixtures/vcr_cassettes/resources/bank_billet_remittance/all.yml +39 -70
- data/spec/fixtures/vcr_cassettes/resources/customer/all.yml +111 -56
- data/spec/fixtures/vcr_cassettes/resources/customer/create/invalid_params.yml +35 -19
- data/spec/fixtures/vcr_cassettes/resources/customer/create/invalid_root.yml +35 -16
- data/spec/fixtures/vcr_cassettes/resources/customer/create/valid.yml +37 -21
- data/spec/fixtures/vcr_cassettes/resources/customer/find.yml +36 -20
- data/spec/fixtures/vcr_cassettes/resources/customer_import/all.yml +34 -18
- data/spec/fixtures/vcr_cassettes/resources/customer_import/create/invalid_params.yml +31 -15
- data/spec/fixtures/vcr_cassettes/resources/customer_import/create/invalid_root.yml +31 -15
- data/spec/fixtures/vcr_cassettes/resources/customer_import/create/valid.yml +36 -20
- data/spec/fixtures/vcr_cassettes/resources/customer_import/find.yml +34 -18
- data/spec/fixtures/vcr_cassettes/resources/customer_subscription/all.yml +35 -71
- data/spec/fixtures/vcr_cassettes/resources/customer_subscription/create/invalid_params.yml +32 -16
- data/spec/fixtures/vcr_cassettes/resources/customer_subscription/create/invalid_root.yml +31 -15
- data/spec/fixtures/vcr_cassettes/resources/customer_subscription/create/valid.yml +35 -19
- data/spec/fixtures/vcr_cassettes/resources/customer_subscription/find.yml +36 -20
- data/spec/fixtures/vcr_cassettes/resources/customer_subscription/next_charge.yml +36 -20
- data/spec/fixtures/vcr_cassettes/resources/customer_subscription_import/all.yml +34 -19
- data/spec/fixtures/vcr_cassettes/resources/customer_subscription_import/create/invalid_params.yml +31 -15
- data/spec/fixtures/vcr_cassettes/resources/customer_subscription_import/create/invalid_root.yml +31 -15
- data/spec/fixtures/vcr_cassettes/resources/customer_subscription_import/create/valid.yml +36 -20
- data/spec/fixtures/vcr_cassettes/resources/customer_subscription_import/find.yml +34 -18
- data/spec/fixtures/vcr_cassettes/resources/discharge/all.yml +37 -39
- data/spec/fixtures/vcr_cassettes/resources/discharge/create/invalid_params.yml +31 -15
- data/spec/fixtures/vcr_cassettes/resources/discharge/create/invalid_root.yml +31 -15
- data/spec/fixtures/vcr_cassettes/resources/discharge/create/valid.yml +37 -21
- data/spec/fixtures/vcr_cassettes/resources/discharge/find.yml +36 -18
- data/spec/fixtures/vcr_cassettes/resources/email_delivery/all.yml +1 -1
- data/spec/fixtures/vcr_cassettes/resources/event/all.yml +267 -432
- data/spec/fixtures/vcr_cassettes/resources/installment/all.yml +71 -375
- data/spec/fixtures/vcr_cassettes/resources/installment/create/invalid_params.yml +32 -16
- data/spec/fixtures/vcr_cassettes/resources/installment/create/invalid_root.yml +31 -15
- data/spec/fixtures/vcr_cassettes/resources/installment/create/valid.yml +35 -19
- data/spec/fixtures/vcr_cassettes/resources/installment/find.yml +59 -19
- data/spec/fixtures/vcr_cassettes/resources/remittance/all.yml +82 -81
- data/spec/fixtures/vcr_cassettes/resources/sns_delivery/all.yml +31 -15
- data/spec/fixtures/vcr_cassettes/resources/transaction/all.yml +72 -71
- data/spec/fixtures/vcr_cassettes/resources/web_hook/all.yml +33 -17
- data/spec/fixtures/vcr_cassettes/resources/webhook_delivery/all.yml +2657 -1206
- metadata +10 -186
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b0b065f756a9ee10d080e10686637aee38ca6b63306878dc4879dbf56fd676c
|
4
|
+
data.tar.gz: c83c0eadff5245a19d07ea7a6cbe8c184eeed809e0895db4eb9ca78802250cf8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 977fb2769a02f9fcc6da3e2a4a4fe35ba9fe9f80327584bfc3b48dbb1446ea666f1b1cb0c5b61d09422cc1f1ff702a88768e3b58c820b8c83121972dab9ae4cd
|
7
|
+
data.tar.gz: fa35fda07bc7f85c31c03f4991fed958107e4709418292798c22122da79940719688bc337c5ab686224877102c30e475421e79e9d117b4f7ba66c883fba7c333
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
[gem]: https://rubygems.org/gems/boletosimples
|
7
7
|
|
8
|
-
Biblioteca Ruby para acessar informações
|
8
|
+
Biblioteca Ruby para acessar informações da [Kobana](https://www.kobana.com.br) através da [API](https://api.kobana.com.br).
|
9
9
|
|
10
10
|
## Instalação
|
11
11
|
|
@@ -23,18 +23,19 @@ Ou instale você mesmo:
|
|
23
23
|
|
24
24
|
## Configuração
|
25
25
|
|
26
|
-
Saiba mais sobre o [Token de API ](https://
|
26
|
+
Saiba mais sobre o [Token de API ](https://developers.kobana.com.br/reference/token-de-acesso)
|
27
27
|
|
28
28
|
```ruby
|
29
29
|
require 'boletosimples'
|
30
30
|
|
31
31
|
BoletoSimples.configure do |c|
|
32
32
|
c.environment = :production # defaut :sandbox
|
33
|
-
# production - https://
|
34
|
-
# sandbox - https://sandbox.
|
33
|
+
# production - https://app.kobana.com.br/conta/api/tokens
|
34
|
+
# sandbox - https://app-sandbox.kobana.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
37
|
# c.debug = true
|
38
|
+
# c.custom_headers = { 'X-CUSTOM' => 'CONTENT' }
|
38
39
|
end
|
39
40
|
```
|
40
41
|
|
@@ -50,7 +51,7 @@ ENV['BOLETOSIMPLES_DEBUG']
|
|
50
51
|
|
51
52
|
### Configurando cache
|
52
53
|
|
53
|
-
É altamente recomendável utilizar o cache para evitar chegar no [limite de requisições](
|
54
|
+
É altamente recomendável utilizar o cache para evitar chegar no [limite de requisições](https://developers.kobana.com.br/reference/limite-de-requisições)
|
54
55
|
|
55
56
|
Para isso recomendamos a utilização da gem [Dalli](https://github.com/mperham/dalli)
|
56
57
|
|
@@ -60,7 +61,9 @@ Exemplo:
|
|
60
61
|
require 'dalli'
|
61
62
|
|
62
63
|
BoletoSimples.configure do |c|
|
63
|
-
c.cache = ActiveSupport::Cache.lookup_store(:
|
64
|
+
c.cache = ActiveSupport::Cache.lookup_store(:mem_cache_store, ['localhost:11211'],
|
65
|
+
namespace: 'boletosimples_client',
|
66
|
+
compress: true)
|
64
67
|
end
|
65
68
|
```
|
66
69
|
|
@@ -111,8 +114,7 @@ Exemplo:
|
|
111
114
|
end
|
112
115
|
|
113
116
|
# Cancelar um boleto
|
114
|
-
@bank_billet = BoletoSimples::BankBillet.
|
115
|
-
@bank_billet.cancel
|
117
|
+
@bank_billet = BoletoSimples::BankBillet.cancel(id: 1)
|
116
118
|
|
117
119
|
```
|
118
120
|
|
@@ -2,20 +2,21 @@
|
|
2
2
|
|
3
3
|
module BoletoSimples
|
4
4
|
class Configuration
|
5
|
-
attr_accessor :environment, :cache, :user_agent, :api_token, :debug
|
5
|
+
attr_accessor :environment, :cache, :user_agent, :custom_headers, :api_token, :debug
|
6
6
|
|
7
7
|
BASE_URI = {
|
8
|
-
sandbox: 'https://sandbox.
|
9
|
-
production: 'https://
|
8
|
+
sandbox: 'https://api-sandbox.kobana.com.br/v1',
|
9
|
+
production: 'https://api.kobana.com.br/v1',
|
10
10
|
development: 'http://localhost:5000/api/v1'
|
11
11
|
}.freeze
|
12
12
|
|
13
13
|
def initialize
|
14
|
-
@environment = (
|
15
|
-
@api_token = ENV
|
16
|
-
@user_agent = ENV
|
14
|
+
@environment = ENV.fetch('BOLETOSIMPLES_ENV', :sandbox).to_sym
|
15
|
+
@api_token = ENV.fetch('BOLETOSIMPLES_API_TOKEN', nil)
|
16
|
+
@user_agent = ENV.fetch('BOLETOSIMPLES_USER_AGENT', nil)
|
17
|
+
@custom_headers = {}
|
17
18
|
@cache = nil
|
18
|
-
@debug = ENV
|
19
|
+
@debug = ENV.fetch('BOLETOSIMPLES_DEBUG', nil)
|
19
20
|
end
|
20
21
|
|
21
22
|
def base_uri
|
@@ -35,10 +36,11 @@ module BoletoSimples
|
|
35
36
|
# Request
|
36
37
|
c.use BoletoSimples::Middleware::UserAgent
|
37
38
|
c.use BoletoSimples::Middleware::Bearer if api_token?
|
39
|
+
c.use BoletoSimples::Middleware::CustomHeaders
|
38
40
|
c.use Faraday::Request::Multipart
|
39
41
|
c.use FaradayMiddleware::EncodeJson
|
40
42
|
c.use Her::Middleware::AcceptJSON
|
41
|
-
c.use Faraday::HttpCache, store: cache unless cache.nil?
|
43
|
+
c.use Faraday::HttpCache, store: cache, serializer: Marshal unless cache.nil?
|
42
44
|
|
43
45
|
# Response
|
44
46
|
c.use BoletoSimples::Middleware::Debug if debug?
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module BoletoSimples
|
4
4
|
class LastRequest
|
5
|
-
attr_reader :body, :response_headers, :total, :ratelimit_limit, :ratelimit_remaining, :links
|
5
|
+
attr_reader :body, :request_headers, :response_headers, :total, :ratelimit_limit, :ratelimit_remaining, :links
|
6
6
|
|
7
7
|
def initialize(env)
|
8
8
|
@env = env
|
@@ -12,6 +12,10 @@ module BoletoSimples
|
|
12
12
|
@body ||= @env[:body][:data]
|
13
13
|
end
|
14
14
|
|
15
|
+
def request_headers
|
16
|
+
@request_headers ||= @env.request_headers
|
17
|
+
end
|
18
|
+
|
15
19
|
def response_headers
|
16
20
|
@response_headers ||= @env[:response_headers]
|
17
21
|
end
|
@@ -9,14 +9,14 @@ module BoletoSimples
|
|
9
9
|
# Examples:
|
10
10
|
#
|
11
11
|
# BoletoSimples::BankBillet.all
|
12
|
-
# BoletoSimples::ResponseError: 401 POST https://sandbox.
|
12
|
+
# BoletoSimples::ResponseError: 401 POST https://api-sandbox.kobana.com.br/v1/bank_billets
|
13
13
|
#
|
14
14
|
# begin
|
15
15
|
# BoletoSimples::BankBillet.all
|
16
16
|
# rescue BoletoSimples::ResponseError => response
|
17
17
|
# response.status # => 401
|
18
18
|
# response.method # => "GET"
|
19
|
-
# response.url # => "https://sandbox.
|
19
|
+
# response.url # => "https://api-sandbox.kobana.com.br/v1/bank_billets"
|
20
20
|
# response.body # => "{"error":"Você precisa se logar ou registrar antes de prosseguir."}"
|
21
21
|
# response.error_message # => "Você precisa se logar ou registrar antes de prosseguir."
|
22
22
|
# end
|
data/lib/boletosimples.rb
CHANGED
@@ -32,6 +32,7 @@ module BoletoSimples
|
|
32
32
|
|
33
33
|
module Middleware
|
34
34
|
autoload :UserAgent, 'boletosimples/middlewares/user_agent'
|
35
|
+
autoload :CustomHeaders, 'boletosimples/middlewares/custom_headers'
|
35
36
|
autoload :RaiseError, 'boletosimples/middlewares/raise_error'
|
36
37
|
autoload :LastRequest, 'boletosimples/middlewares/last_request'
|
37
38
|
autoload :Debug, 'boletosimples/middlewares/debug'
|
@@ -1,72 +1,89 @@
|
|
1
1
|
# # frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe BoletoSimples::Configuration do
|
6
|
+
describe 'defaults' do
|
7
|
+
subject { described_class.new }
|
8
|
+
|
9
|
+
before do
|
10
|
+
stub_env('BOLETOSIMPLES_ENV', nil)
|
11
|
+
stub_env('BOLETOSIMPLES_USER_AGENT', nil)
|
12
|
+
subject.setup_her
|
13
|
+
end
|
14
|
+
|
15
|
+
after do
|
16
|
+
BoletoSimples.configure
|
17
|
+
end
|
18
|
+
|
19
|
+
it do
|
20
|
+
expect(subject.environment).to eq(:sandbox)
|
21
|
+
expect(subject.base_uri).to eq('https://api-sandbox.kobana.com.br/v1')
|
22
|
+
expect(subject.cache).to be_nil
|
23
|
+
expect(subject.user_agent).to be_nil
|
24
|
+
expect(subject.custom_headers).to eq({})
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe 'environment variables' do
|
29
|
+
subject { BoletoSimples.configuration }
|
30
|
+
|
31
|
+
before do
|
32
|
+
stub_env('BOLETOSIMPLES_ENV', 'production')
|
33
|
+
stub_env('BOLETOSIMPLES_USER_AGENT', 'email@minhaempresa.com.br')
|
34
|
+
BoletoSimples.configure
|
35
|
+
end
|
36
|
+
|
37
|
+
after do
|
38
|
+
BoletoSimples.configure
|
39
|
+
end
|
40
|
+
|
41
|
+
it do
|
42
|
+
expect(subject.environment).to eq(:production)
|
43
|
+
expect(subject.base_uri).to eq('https://api.kobana.com.br/v1')
|
44
|
+
expect(subject.user_agent).to eq('email@minhaempresa.com.br')
|
45
|
+
end
|
46
|
+
|
47
|
+
describe 'cache' do
|
48
|
+
it do
|
49
|
+
expect(subject.cache).to be_nil
|
50
|
+
expect(Her::API.default_api.connection.builder.handlers).not_to include(Faraday::HttpCache)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe 'configuration' do
|
56
|
+
subject { BoletoSimples.configuration }
|
57
|
+
|
58
|
+
let(:cache_object) { double('Dalli') }
|
59
|
+
|
60
|
+
before do
|
61
|
+
BoletoSimples.configure do |c|
|
62
|
+
c.environment = :production
|
63
|
+
c.cache = cache_object
|
64
|
+
c.user_agent = 'Meu agent'
|
65
|
+
c.custom_headers = {
|
66
|
+
'X-CUSTOM' => 'CONTENT'
|
67
|
+
}
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
after do
|
72
|
+
BoletoSimples.configure
|
73
|
+
end
|
74
|
+
|
75
|
+
it do
|
76
|
+
expect(subject.environment).to eq(:production)
|
77
|
+
expect(subject.user_agent).to eq('Meu agent')
|
78
|
+
expect(subject.custom_headers).to eq({ 'X-CUSTOM' => 'CONTENT' })
|
79
|
+
expect(subject.base_uri).to eq('https://api.kobana.com.br/v1')
|
80
|
+
end
|
81
|
+
|
82
|
+
describe 'cache' do
|
83
|
+
it do
|
84
|
+
expect(subject.cache).to eq(cache_object)
|
85
|
+
expect(Her::API.default_api.connection.builder.handlers).to include(Faraday::HttpCache)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -12,6 +12,7 @@ RSpec.describe BoletoSimples::LastRequest do
|
|
12
12
|
expect(subject).to be_kind_of(described_class)
|
13
13
|
expect(subject.body).to be_kind_of(Array)
|
14
14
|
expect(subject.body.first).to be_kind_of(Hash)
|
15
|
+
expect(subject.request_headers).to be_kind_of(Hash)
|
15
16
|
expect(subject.response_headers).to be_kind_of(Hash)
|
16
17
|
expect(subject.total).to be_kind_of(Integer)
|
17
18
|
expect(subject.ratelimit_limit).to be_kind_of(Integer)
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe BoletoSimples::Middleware::CustomHeaders do
|
6
|
+
describe 'bank_billets', vcr: { cassette_name: 'custom_headers' } do
|
7
|
+
subject { BoletoSimples.last_request }
|
8
|
+
|
9
|
+
before do
|
10
|
+
BoletoSimples.configure do |c|
|
11
|
+
c.custom_headers = {
|
12
|
+
'X-CUSTOM' => 'CONTENT'
|
13
|
+
}
|
14
|
+
end
|
15
|
+
BoletoSimples::BankBillet.all(page: 2).size
|
16
|
+
end
|
17
|
+
|
18
|
+
after do
|
19
|
+
BoletoSimples.configure
|
20
|
+
end
|
21
|
+
|
22
|
+
it do
|
23
|
+
expect(subject.request_headers).to include({ 'X-CUSTOM' => 'CONTENT' })
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -10,7 +10,7 @@ RSpec.describe BoletoSimples::BankBillet do
|
|
10
10
|
@bank_billet = described_class.create(
|
11
11
|
amount: 9.01,
|
12
12
|
description: 'Despesas do contrato 0012',
|
13
|
-
expire_at: '
|
13
|
+
expire_at: '2024-01-01',
|
14
14
|
customer_address: 'Rua quinhentos',
|
15
15
|
customer_address_complement: 'Sala 4',
|
16
16
|
customer_address_number: '111',
|
@@ -60,7 +60,7 @@ RSpec.describe BoletoSimples::BankBillet do
|
|
60
60
|
|
61
61
|
it {
|
62
62
|
expect(subject.response_errors).to eq({ customer_person_name: ['não pode ficar em branco'],
|
63
|
-
customer_cnpj_cpf: ['não
|
63
|
+
customer_cnpj_cpf: ['não é um CNPJ ou CPF válido'],
|
64
64
|
customer_zipcode: ['não pode ficar em branco'],
|
65
65
|
expire_at: ['não pode ficar em branco', 'não é uma data válida'],
|
66
66
|
customer_address: ['não pode ficar em branco'],
|
@@ -9,7 +9,7 @@ RSpec.describe BoletoSimples::Customer do
|
|
9
9
|
VCR.use_cassette('resources/customer/create/valid') do
|
10
10
|
@customer = described_class.create(
|
11
11
|
person_name: 'Maria José',
|
12
|
-
cnpj_cpf: '
|
12
|
+
cnpj_cpf: '84.232.027/0001-08',
|
13
13
|
email: 'cliente@example.com',
|
14
14
|
address: 'Rua quinhentos',
|
15
15
|
city_name: 'Rio de Janeiro',
|
@@ -42,8 +42,13 @@ RSpec.describe BoletoSimples::Customer do
|
|
42
42
|
end
|
43
43
|
|
44
44
|
it {
|
45
|
-
expect(subject.response_errors).to eq(
|
46
|
-
|
45
|
+
expect(subject.response_errors).to eq({ address: ['não pode ficar em branco'],
|
46
|
+
city_name: ['não pode ficar em branco'],
|
47
|
+
cnpj_cpf: ['não é um CNPJ ou CPF válido'],
|
48
|
+
neighborhood: ['não pode ficar em branco'],
|
49
|
+
person_name: ['não pode ficar em branco'],
|
50
|
+
state: ['não está incluído na lista'],
|
51
|
+
zipcode: ['não pode ficar em branco'] })
|
47
52
|
}
|
48
53
|
end
|
49
54
|
|
@@ -56,7 +61,7 @@ RSpec.describe BoletoSimples::Customer do
|
|
56
61
|
|
57
62
|
it {
|
58
63
|
expect(subject.response_errors).to eq({ person_name: ['não pode ficar em branco'],
|
59
|
-
cnpj_cpf: ['não
|
64
|
+
cnpj_cpf: ['não é um CNPJ ou CPF válido'], zipcode: ['não pode ficar em branco'],
|
60
65
|
address: ['não pode ficar em branco'], neighborhood: ['não pode ficar em branco'],
|
61
66
|
city_name: ['não pode ficar em branco'], state: ['não está incluído na lista'] })
|
62
67
|
}
|
@@ -61,7 +61,7 @@ RSpec.describe BoletoSimples::CustomerSubscription do
|
|
61
61
|
|
62
62
|
it {
|
63
63
|
expect(subject.response_errors).to eq({ customer_person_name: ['não pode ficar em branco'],
|
64
|
-
customer_cnpj_cpf: ['não
|
64
|
+
customer_cnpj_cpf: ['não é um CNPJ ou CPF válido'],
|
65
65
|
customer_zipcode: ['não pode ficar em branco'],
|
66
66
|
amount: ['não pode ficar em branco'],
|
67
67
|
customer_address: ['não pode ficar em branco'],
|
@@ -62,7 +62,7 @@ RSpec.describe BoletoSimples::Installment do
|
|
62
62
|
|
63
63
|
it {
|
64
64
|
expect(subject.response_errors).to eq({ customer_person_name: ['não pode ficar em branco'],
|
65
|
-
customer_cnpj_cpf: ['não
|
65
|
+
customer_cnpj_cpf: ['não é um CNPJ ou CPF válido'],
|
66
66
|
customer_zipcode: ['não pode ficar em branco'],
|
67
67
|
total: ['não pode ficar em branco', 'não é um número'],
|
68
68
|
start_at: ['não pode ficar em branco'],
|
data/spec/fixtures/discharge.RET
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
02RETORNO01COBRANCA 16511300049999999999 SISTEMAS S.A 033SANTANDER 20032000000000009483012 325000001
|
2
|
-
1027879661300014165199000999990009999 04958535 510200320495853 0495853500 12111900000000300350331651901000000000003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 N 200320 SOLUCOES DIGITAIS L 00000000000000000000000000000000000000000C 325000002
|
3
|
-
9201033 000025050000053763329700000518 000000000000000000000000000000 000000000000000000000000000000 325000632
|
1
|
+
02RETORNO01COBRANCA 16511300049999999999 SISTEMAS S.A 033SANTANDER 20032000000000009483012 325000001
|
2
|
+
1027879661300014165199000999990009999 04958535 510200320495853 0495853500 12111900000000300350331651901000000000003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 N 200320 SOLUCOES DIGITAIS L 00000000000000000000000000000000000000000C 325000002
|
3
|
+
9201033 000025050000053763329700000518 000000000000000000000000000000 000000000000000000000000000000 325000632
|
@@ -0,0 +1,113 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://api-sandbox.kobana.com.br/v1/bank_billets?page=2
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Authorization:
|
11
|
+
- Bearer BOLETOSIMPLES_API_TOKEN
|
12
|
+
X-Custom:
|
13
|
+
- CONTENT
|
14
|
+
Accept:
|
15
|
+
- application/json
|
16
|
+
Accept-Encoding:
|
17
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
18
|
+
User-Agent:
|
19
|
+
- Ruby
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 200
|
23
|
+
message: OK
|
24
|
+
headers:
|
25
|
+
Content-Type:
|
26
|
+
- application/json; charset=utf-8
|
27
|
+
Transfer-Encoding:
|
28
|
+
- chunked
|
29
|
+
Connection:
|
30
|
+
- keep-alive
|
31
|
+
Server:
|
32
|
+
- Cowboy
|
33
|
+
X-Frame-Options:
|
34
|
+
- DENY
|
35
|
+
X-Xss-Protection:
|
36
|
+
- 1; mode=block
|
37
|
+
X-Content-Type-Options:
|
38
|
+
- nosniff
|
39
|
+
X-Download-Options:
|
40
|
+
- noopen
|
41
|
+
X-Permitted-Cross-Domain-Policies:
|
42
|
+
- none
|
43
|
+
Referrer-Policy:
|
44
|
+
- strict-origin-when-cross-origin
|
45
|
+
Expect-Ct:
|
46
|
+
- max-age=0, report-uri="https://boletosimples.report-uri.com/r/d/ct/reportOnly"
|
47
|
+
Cross-Origin-Resource-Policy:
|
48
|
+
- cross-origin
|
49
|
+
Cross-Origin-Embedder-Policy:
|
50
|
+
- unsafe-none
|
51
|
+
Cross-Origin-Opener-Policy:
|
52
|
+
- unsafe-none
|
53
|
+
Link:
|
54
|
+
- <https://api-sandbox.kobana.com.br/api/v1/bank_billets?page=1>; rel="first",
|
55
|
+
<https://api-sandbox.kobana.com.br/api/v1/bank_billets?page=>; rel="prev",
|
56
|
+
<https://api-sandbox.kobana.com.br/api/v1/bank_billets?page=>; rel="next"
|
57
|
+
Per-Page:
|
58
|
+
- '50'
|
59
|
+
Page:
|
60
|
+
- '2'
|
61
|
+
X-Ratelimit-Limit:
|
62
|
+
- '60'
|
63
|
+
X-Ratelimit-Remaining:
|
64
|
+
- '59'
|
65
|
+
Etag:
|
66
|
+
- W/"4f53cda18c2baa0c0354bb5f9a3ecbe5"
|
67
|
+
Cache-Control:
|
68
|
+
- must-revalidate, private, max-age=0
|
69
|
+
Content-Security-Policy-Report-Only:
|
70
|
+
- 'default-src ''self'' https: app-sandbox.kobana.com.br; font-src ''self''
|
71
|
+
https: data: app-sandbox.kobana.com.br fonts.googleapis.com fonts.gstatic.com
|
72
|
+
themes.googleusercontent.com; img-src ''self'' https: data: maps.googleapis.com
|
73
|
+
bole.test:5001 bole.to www.google-analytics.com boletosimples-sandbox.s3.amazonaws.com
|
74
|
+
d3caatrp30sdc5.cloudfront.net; object-src ''self'' https: app-sandbox.kobana.com.br;
|
75
|
+
media-src ''self'' https: data: app-sandbox.kobana.com.br; script-src ''self''
|
76
|
+
https: ''unsafe-inline'' app-sandbox.kobana.com.br zapier.com www.google-analytics.com
|
77
|
+
www.googleadservices.com app.popupdomination.com js-agent.newrelic.com doug1izaerwt3.cloudfront.net
|
78
|
+
cdn.ywxi.net bam.nr-data.net cdnjs.cloudflare.com widget.pluga.co www.google.com
|
79
|
+
www.gstatic.com cdn.mxpnl.com cdn.amplitude.com www.draw.io; style-src ''self''
|
80
|
+
https: ''unsafe-inline'' app-sandbox.kobana.com.br fonts.googleapis.com; child-src
|
81
|
+
''self'' app-sandbox.kobana.com.br www.googleadservices.com docs.google.com
|
82
|
+
googleads.g.doubleclick.net www.google.com www.google.com.br app.popupdomination.com
|
83
|
+
bid.g.doubleclick.net widget.pluga.co www.googletagmanager.com www.facebook.com
|
84
|
+
www.youtube.com; connect-src ''self'' https: ws: wss: boletosimples.com.br
|
85
|
+
*.boletosimples.com.br kobana.com.br *.kobana.com.br api.mixpanel.com *.cloudfront.net
|
86
|
+
*.google-analytics.com *.amplitude.com; report-uri https://boletosimples.report-uri.com/r/d/csp/reportOnly'
|
87
|
+
X-Request-Id:
|
88
|
+
- 97404e79-3ee9-4b3b-ac85-73bf55a49eb9
|
89
|
+
X-Runtime:
|
90
|
+
- '0.031604'
|
91
|
+
Date:
|
92
|
+
- Mon, 16 May 2022 01:47:15 GMT
|
93
|
+
X-Rack-Cache:
|
94
|
+
- miss
|
95
|
+
Strict-Transport-Security:
|
96
|
+
- max-age=31556952; includeSubDomains; preload
|
97
|
+
Vary:
|
98
|
+
- Origin,Accept-Encoding
|
99
|
+
X-Rack-Cors:
|
100
|
+
- miss; no-origin
|
101
|
+
Via:
|
102
|
+
- 1.1 vegur, 1.1 5d90b9fb6ab804caa33b8aa5260094e8.cloudfront.net (CloudFront)
|
103
|
+
X-Cache:
|
104
|
+
- Miss from cloudfront
|
105
|
+
X-Amz-Cf-Pop:
|
106
|
+
- BOS50-C3
|
107
|
+
X-Amz-Cf-Id:
|
108
|
+
- BgmGgAdTdYoBOyDh0-HynXgB_vgYgX8s41CtoUxRaGOuAtdOJer_-A==
|
109
|
+
body:
|
110
|
+
encoding: UTF-8
|
111
|
+
string: "[]"
|
112
|
+
recorded_at: Mon, 16 May 2022 01:47:14 GMT
|
113
|
+
recorded_with: VCR 6.1.0
|