diff --git a/lib/pjbank/contadigital/contadigital.rb b/lib/pjbank/contadigital/contadigital.rb index ca06ba8..2ceb281 100644 --- a/lib/pjbank/contadigital/contadigital.rb +++ b/lib/pjbank/contadigital/contadigital.rb @@ -1,13 +1,14 @@ require_relative 'credenciamento/credenciamento' +require_relative 'recebimento/boleto' require_relative 'transacoes/transacoes' class ContaDigitalController def initialize - @credenciamentoController = CredenciamentoContaDigital.new - - @transacoesController = TransacoesContaDigital.new + # @credenciamentoController = CredenciamentoContaDigital.new + + # @transacoesController = TransacoesContaDigital.new end @@ -17,7 +18,7 @@ def credenciamento opcao = gets.chomp case opcao - when '1' + when '1' @credenciamentoController.credenciamento when '2' @credenciamentoController.consulta @@ -32,7 +33,7 @@ def transacoes opcao = gets.chomp case opcao - when '1' + when '1' @transacoesController.pagamentoBoleto end end @@ -49,4 +50,4 @@ def transacoes # end -end \ No newline at end of file +end diff --git a/lib/pjbank/contadigital/credenciamento/base.rb b/lib/pjbank/contadigital/credenciamento/base.rb new file mode 100644 index 0000000..0a49335 --- /dev/null +++ b/lib/pjbank/contadigital/credenciamento/base.rb @@ -0,0 +1,19 @@ +module PJBank + module Contadigital + module Credenciamento + class Base + attr_reader :http + + def initialize(http) + @http = http + end + + private + + def base_url_path + "/contadigital" + end + end + end + end +end diff --git a/lib/pjbank/contadigital/credenciamento/credenciamento.rb b/lib/pjbank/contadigital/credenciamento/credenciamento.rb index eee9757..abcb894 100644 --- a/lib/pjbank/contadigital/credenciamento/credenciamento.rb +++ b/lib/pjbank/contadigital/credenciamento/credenciamento.rb @@ -1,117 +1,13 @@ -class CredenciamentoContaDigital - - def credenciamento - - puts "Nome da empresa. Ex: Exemplo Conta Digital" - nome_empresa = gets.chomp - puts "CNPJ. Ex: 60285827000110" - cnpj = gets.chomp - puts "CEP. Ex: 13032-525" - cep = gets.chomp - puts "Endereço. Ex: Rua Joaquim Vilac" - endereco = gets.chomp - puts "Número. Ex: 509" - numero = gets.chomp - puts "Bairro. Ex: Vila Teixeira" - bairro = gets.chomp - puts "Complemento. Ex: (opcional)" - complemento = gets.chomp - puts "Cidade. Ex: Campinas" - cidade = gets.chomp - puts "Estado. Ex: SP" - estado = gets.chomp - puts "DDD. Ex: 19" - ddd = gets.chomp - puts "Telefone. Ex: 987652345" - telefone = gets.chomp - puts "E-mail. Ex: api@pjbank.com.br" - email = gets.chomp - - puts "\nLoading...\n" - - begin - response = RestClient::Request.execute( - method: :post, - url: 'https://api.pjbank.com.br/contadigital/', - header: { - "Content-Type": "application/x-www-form-urlencoded" - }, - payload: { - nome_empresa: "#{nome_empresa}", - cnpj: "#{cnpj}", - cep: "#{cep}", - endereco: "#{endereco}", - numero: numero, - bairro: "#{bairro}", - complemento: "#{complemento}", - cidade: "#{cidade}", - estado: "#{estado}", - ddd: "#{ddd}", - telefone: "#{telefone}", - email: "#{email}" - } - ) - - return response - rescue RestClient::ExceptionWithResponse => err - return err +require_relative 'base' + +module PJBank + module Contadigital + module Credenciamento + class Credenciamento < Base + def credenciamento(dados) + http.post("#{base_url_path}/", payload: dados) end + end end - - def consulta - - puts "Digite a Credencial. Ex: eb2af021c5e2448c343965a7a80d7d090eb64164" - credencial = gets.chomp - puts "Digite a Chave. Ex: a834d47e283dd12f50a1b3a771603ae9dfd5a32c" - chave = gets.chomp - - puts "\nLoading...\n" - - begin - response = RestClient::Request.execute( - method: :get, - url: "https://api.pjbank.com.br/contadigital/#{credencial}", - headers: { - 'x-chave-conta': chave, - } - ) - - return response - rescue RestClient::ExceptionWithResponse => err - return err - end - - end - - def boleto - - puts "Digite a Credencial. Ex: eb2af021c5e2448c343965a7a80d7d090eb64164" - credencial = gets.chomp - puts "Digite a Chave. Ex: a834d47e283dd12f50a1b3a771603ae9dfd5a32c" - chave = gets.chomp - puts "Valor a ser adicionado. Ex: 900.00" - valor = gets.chomp - - puts "\nLoading...\n" - - begin - response = RestClient::Request.execute( - method: :post, - url: "https://api.pjbank.com.br/contadigital/#{credencial}", - headers: { - 'x-chave-conta': chave, - "Content-Type": "application/x-www-form-urlencoded" - }, - payload: { - 'valor': valor - } - ) - - return response - rescue RestClient::ExceptionWithResponse => err - return err - end - - end - -end \ No newline at end of file + end +end diff --git a/lib/pjbank/contadigital/recebimento/base.rb b/lib/pjbank/contadigital/recebimento/base.rb new file mode 100644 index 0000000..a3b0a81 --- /dev/null +++ b/lib/pjbank/contadigital/recebimento/base.rb @@ -0,0 +1,19 @@ +module PJBank + module Contadigital + module Recebimento + class Base + attr_reader :http + + def initialize(http) + @http = http + end + + private + + def base_url_path + "/contadigital" + end + end + end + end +end diff --git a/lib/pjbank/contadigital/recebimento/boleto.rb b/lib/pjbank/contadigital/recebimento/boleto.rb new file mode 100644 index 0000000..c3c7cab --- /dev/null +++ b/lib/pjbank/contadigital/recebimento/boleto.rb @@ -0,0 +1,17 @@ +require_relative 'base' + +module PJBank + module Contadigital + module Recebimento + class Boleto < Base + def emitir(dados) + http.post("#{base_url_path}/:credencial/recebimentos/transacoes", payload: dados) + end + + def cancelar(id) + http.delete("#{base_url_path}/:credencial/recebimentos/transacoes/#{id}") + end + end + end + end +end diff --git a/spec/pjbank/contadigital/credenciamento/credenciamento_spec.rb b/spec/pjbank/contadigital/credenciamento/credenciamento_spec.rb new file mode 100644 index 0000000..60e02f3 --- /dev/null +++ b/spec/pjbank/contadigital/credenciamento/credenciamento_spec.rb @@ -0,0 +1,52 @@ +require 'spec_helper' + +RSpec.describe PJBank::Contadigital::Credenciamento::Credenciamento do + subject { described_class.new(http) } + + describe "#credenciamento" do + let(:http) { PJBank::Http.new } + + let(:dados) do + { + nome_empresa: "Boleto Sem Conta Digital", + cnpj: "61702829000120", + cep: "22031030", + endereco: "Rua Silva Castro", + numero: "48", + bairro: "Copacabana", + complemento: "8 andar", + cidade: "Rio de Janeiro", + estado: "RJ", + ddd: "22", + telefone: "988225511", + email: "pjbank-ruby-sdk@mailinator.com" + } + end + + context "when success" do + it "returns the object with correct data" do + VCR.use_cassette("contadigital/credenciamento/credenciamento/sucesso") do + response = subject.credenciamento(dados) + expect(response.credencial).to_not be_nil + expect(response.chave).to_not be_nil + end + end + end + + context "when failure" do + before { dados[:cnpj] = "" } + + context "when validation error (400)" do + it "raises PJBank::RequestError" do + VCR.use_cassette("contadigital/credenciamento/credenciamento/erro_400") do + expect { subject.credenciamento(dados) }.to raise_error do |error| + expect(error).to be_a(PJBank::RequestError) + expect(error.message).to eql("CNPJ inválido.") + expect(error.code).to eql(400) + end + end + end + end + end + end +end diff --git a/spec/pjbank/contadigital/recebimento/boleto_spec.rb b/spec/pjbank/contadigital/recebimento/boleto_spec.rb new file mode 100644 index 0000000..a6c417d --- /dev/null +++ b/spec/pjbank/contadigital/recebimento/boleto_spec.rb @@ -0,0 +1,124 @@ +require 'spec_helper' + +RSpec.describe PJBank::Contadigital::Recebimento::Boleto do + let(:credencial) { "a92c4a6fae4a8f9e06f141ca4561679f8a9d49a2" } + let(:chave) { "6c1c05b0ccff1e4d3c8c7c28078d4928ec5d99db" } + + let(:http) { PJBank::Http.new(credencial: credencial, chave: chave) } + + subject { described_class.new(http) } + + describe "#emitir" do + let(:dados) do + { + vencimento: "12/30/2019", + valor: 50.75, + juros: 0, + multa: 0, + desconto: "", + nome_cliente: "Cliente de Exemplo", + cpf_cliente: "62936576000112", + endereco_cliente: "Rua Joaquim Vilac", + numero_cliente: "509", + complemento_cliente: "", + bairro_cliente: "Vila Teixeira", + cidade_cliente: "Campinas", + estado_cliente: "SP", + cep_cliente: "13301510", + logo_url: "http://wallpapercave.com/wp/xK64fR4.jpg", + texto: "Exemplo de emissão de boleto", + grupo: "Boletos", + pedido_numero: "2342" + } + end + + context "when success" do + context "when does not exist with same pedido_numero" do + it "returns the object with correct data" do + VCR.use_cassette("contadigital/recebimento/boleto/emitir/sucesso") do + response = subject.emitir(dados) + expect(response.status).to eql("201") + expect(response.linhaDigitavel).to_not be_nil + expect(response.linkBoleto).to_not be_nil + end + end + end + + context "when exists with same pedido_numero" do + # É necessário que tenha emitido um boleto com esse mesmo pedido_numero para simular essa resposta + before { dados[:pedido_numero] = "2342" } + + it "returns the object with correct data" do + VCR.use_cassette("contadigital/recebimento/boleto/emitir/sucesso_existent") do + response = subject.emitir(dados) + expect(response.status).to eql("200") + expect(response.pedido_numero).to be_nil + expect(response.linhaDigitavel).to_not be_nil + expect(response.linkBoleto).to_not be_nil + end + end + end + end + + context "when failure" do + context "when exists a canceled with same pedido_numero (500)" do + # É necessário que tenha emitido um boleto com esse mesmo pedido_numero e depois cancelado ele + before { dados[:pedido_numero] = "552224411" } + + xit "raises PJBank::RequestError" do + VCR.use_cassette("contadigital/recebimento/boleto/emitir/erro_reemitir_cancelada") do + pending("TODO: ver com o suporte porque está retornando um array sendo que não é uma emissão em lote") + expect { subject.emitir(dados) }.to raise_error do |error| + expect(error).to be_a(PJBank::RequestError) + expect(error.message).to eql("Cobrança que corresponde a esse pedido 1 foi invalidada.") + expect(error.code).to eql(500) + end + end + end + end + + context "when validation error (500)" do + let(:dados) do + { valor: "100.55" } + end + + it "raises PJBank::RequestError" do + VCR.use_cassette("contadigital/recebimento/boleto/emitir/erro_500") do + expect { subject.emitir(dados) }.to raise_error do |error| + expect(error).to be_a(PJBank::RequestError) + expect(error.message).to eql("Vencimento, este campo não pode ser vazio.") + expect(error.code).to eql(500) + end + end + end + end + + context "when Badrequest error (400)" do + let(:credencial) { "109c93905615524442a57788c4f3d821302155a9" } + + it "raises PJBank::RequestError" do + VCR.use_cassette("contadigital/recebimento/boleto/emitir/erro_400") do + expect { subject.emitir(dados) }.to raise_error do |error| + expect(error).to be_a(PJBank::RequestError) + expect(error.message).to eql("Credencial não localizada.") + expect(error.code).to eql(400) + end + end + end + end + end + end + + describe "#cancelar" do + let(:pedido_numero) { "69087" } + let(:id_unico) { "123336" } + + xit "returns the object with correct data" do + VCR.use_cassette("contadigital/recebimento/boleto/cancelar/sucesso") do + response = subject.cancelar(pedido_numero) + expect(response.status).to eql("200") + expect(response.msg).to eql("Cobrança #{id_unico} invalidada com sucesso.") + end + end + end +end diff --git a/spec/vcr_cassettes/contadigital/credenciamento/credenciamento/erro_400.yml b/spec/vcr_cassettes/contadigital/credenciamento/credenciamento/erro_400.yml new file mode 100644 index 0000000..03d77f4 --- /dev/null +++ b/spec/vcr_cassettes/contadigital/credenciamento/credenciamento/erro_400.yml @@ -0,0 +1,59 @@ +--- +http_interactions: +- request: + method: post + uri: https://sandbox.pjbank.com.br/contadigital/ + body: + encoding: UTF-8 + string: '{"nome_empresa":"Boleto Sem Conta Digital","cnpj":"","cep":"22031030","endereco":"Rua + Silva Castro","numero":"48","bairro":"Copacabana","complemento":"8 andar","cidade":"Rio + de Janeiro","estado":"RJ","ddd":"22","telefone":"988225511","email":"pjbank-ruby-sdk@mailinator.com"}' + headers: + Accept: + - "*/*" + Accept-Encoding: + - gzip, deflate + User-Agent: + - pjbank-ruby-sdk/0.1.0 + Content-Type: + - application/json + X-Chave: + - '' + Content-Length: + - '275' + Host: + - sandbox.pjbank.com.br + response: + status: + code: 400 + message: Bad Request + headers: + Content-Type: + - application/json + Content-Length: + - '53' + Connection: + - keep-alive + Date: + - Wed, 18 Apr 2018 13:49:34 GMT + X-Amzn-Requestid: + - 531ed564-430f-11e8-b89c-a9e68ac2a031 + Access-Control-Allow-Origin: + - "*" + X-Amz-Apigw-Id: + - Fij1EHPCGjQFi-Q= + X-Amzn-Trace-Id: + - Root=1-5ad74ced-00cf001fff9798580a686c43 + X-Cache: + - Error from cloudfront + Via: + - 1.1 6a5c800c7461352cf3c0abd4ca7b1c70.cloudfront.net (CloudFront) + X-Amz-Cf-Id: + - 5OhgI4lolmBqepTW5gaUKatCGavezdLXsERb00SXybvjiRnEtrLMZg== + body: + encoding: ASCII-8BIT + string: !binary |- + ewogICAgInN0YXR1cyI6ICI0MDAiLAogICAgIm1zZyI6ICJDTlBKIGludsOhbGlkby4iCn0= + http_version: + recorded_at: Wed, 18 Apr 2018 13:49:34 GMT +recorded_with: VCR 4.0.0 diff --git a/spec/vcr_cassettes/contadigital/credenciamento/credenciamento/sucesso.yml b/spec/vcr_cassettes/contadigital/credenciamento/credenciamento/sucesso.yml new file mode 100644 index 0000000..52f27b4 --- /dev/null +++ b/spec/vcr_cassettes/contadigital/credenciamento/credenciamento/sucesso.yml @@ -0,0 +1,63 @@ +--- +http_interactions: +- request: + method: post + uri: https://sandbox.pjbank.com.br/contadigital/ + body: + encoding: UTF-8 + string: '{"nome_empresa":"Boleto Sem Conta Digital","cnpj":"61702829000120","cep":"22031030","endereco":"Rua + Silva Castro","numero":"48","bairro":"Copacabana","complemento":"8 andar","cidade":"Rio + de Janeiro","estado":"RJ","ddd":"22","telefone":"988225511","email":"pjbank-ruby-sdk@mailinator.com"}' + headers: + Accept: + - "*/*" + Accept-Encoding: + - gzip, deflate + User-Agent: + - pjbank-ruby-sdk/0.1.0 + Content-Type: + - application/json + X-Chave: + - '' + Content-Length: + - '289' + Host: + - sandbox.pjbank.com.br + response: + status: + code: 201 + message: Created + headers: + Content-Type: + - application/json + Content-Length: + - '146' + Connection: + - keep-alive + Date: + - Wed, 18 Apr 2018 13:38:47 GMT + X-Amzn-Requestid: + - d208d499-430d-11e8-b412-07baf1e37258 + Access-Control-Allow-Origin: + - "*" + X-Amz-Apigw-Id: + - FiiQIFGymjQFSlg= + X-Amzn-Trace-Id: + - Root=1-5ad74a67-ed00df431a97fc05ffb19e74 + X-Cache: + - Miss from cloudfront + Via: + - 1.1 2804e22600214b85d35113275791b33a.cloudfront.net (CloudFront) + X-Amz-Cf-Id: + - ajnHNCh7JgVhenaQnNjKhkev5b5Zi-_S2wjo-R0KHNSut-erYJq-Zg== + body: + encoding: UTF-8 + string: |- + { + "credencial": "a92c4a6fae4a8f9e06f141ca4561679f8a9d49a2", + "chave": "6c1c05b0ccff1e4d3c8c7c28078d4928ec5d99db", + "webhook_chave": "" + } + http_version: + recorded_at: Wed, 18 Apr 2018 13:38:47 GMT +recorded_with: VCR 4.0.0 diff --git a/spec/vcr_cassettes/contadigital/recebimento/boleto/cancelar/sucesso.yml b/spec/vcr_cassettes/contadigital/recebimento/boleto/cancelar/sucesso.yml new file mode 100644 index 0000000..b1aa0e7 --- /dev/null +++ b/spec/vcr_cassettes/contadigital/recebimento/boleto/cancelar/sucesso.yml @@ -0,0 +1,53 @@ +--- +http_interactions: +- request: + method: delete + uri: https://sandbox.pjbank.com.br/contadigital/a92c4a6fae4a8f9e06f141ca4561679f8a9d49a2/recebimentos/transacoes/69087 + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - "*/*" + Accept-Encoding: + - gzip, deflate + User-Agent: + - pjbank-ruby-sdk/0.1.0 + Content-Type: + - application/json + X-Chave: + - 6c1c05b0ccff1e4d3c8c7c28078d4928ec5d99db + Host: + - sandbox.pjbank.com.br + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json + Content-Length: + - '60' + Connection: + - keep-alive + Date: + - Wed, 18 Apr 2018 18:09:28 GMT + X-Amzn-Requestid: + - a29978b5-4333-11e8-855a-b3d0d27bf366 + X-Amz-Apigw-Id: + - FjJ51FWCmjQFXUg= + X-Amzn-Trace-Id: + - Root=1-5ad789d8-bdf24f6b0c928111b97e3ccf + X-Cache: + - Miss from cloudfront + Via: + - 1.1 4251da4481948b0ac3a8deec1d24db31.cloudfront.net (CloudFront) + X-Amz-Cf-Id: + - FUt5oTfShEha0iHfD8gGKOEQ7NBUNcw-2uuy-YaBX_FyrhpcamEujA== + body: + encoding: ASCII-8BIT + string: !binary |- + ewogICAgInN0YXR1cyI6ICI0MDQiLAogICAgIm1zZyI6ICJDb250YSBuw6NvIGVuY29udHJhZGEuIgp9 + http_version: + recorded_at: Wed, 18 Apr 2018 18:09:28 GMT +recorded_with: VCR 4.0.0 diff --git a/spec/vcr_cassettes/contadigital/recebimento/boleto/emitir/erro_400.yml b/spec/vcr_cassettes/contadigital/recebimento/boleto/emitir/erro_400.yml new file mode 100644 index 0000000..b24b14f --- /dev/null +++ b/spec/vcr_cassettes/contadigital/recebimento/boleto/emitir/erro_400.yml @@ -0,0 +1,59 @@ +--- +http_interactions: +- request: + method: post + uri: https://sandbox.pjbank.com.br/contadigital/109c93905615524442a57788c4f3d821302155a9/recebimentos/transacoes + body: + encoding: UTF-8 + string: '{"vencimento":"12/30/2019","valor":50.75,"juros":0,"multa":0,"desconto":"","nome_cliente":"Cliente + de Exemplo","cpf_cliente":"62936576000112","endereco_cliente":"Rua Joaquim + Vilac","numero_cliente":"509","complemento_cliente":"","bairro_cliente":"Vila + Teixeira","cidade_cliente":"Campinas","estado_cliente":"SP","cep_cliente":"13301510","logo_url":"http://wallpapercave.com/wp/xK64fR4.jpg","texto":"Exemplo + de emissão de boleto","grupo":"Boletos","pedido_numero":"2342"}' + headers: + Accept: + - "*/*" + Accept-Encoding: + - gzip, deflate + User-Agent: + - pjbank-ruby-sdk/0.1.0 + Content-Type: + - application/json + X-Chave: + - 6c1c05b0ccff1e4d3c8c7c28078d4928ec5d99db + Content-Length: + - '471' + Host: + - sandbox.pjbank.com.br + response: + status: + code: 400 + message: Bad Request + headers: + Content-Type: + - application/json + Content-Length: + - '65' + Connection: + - keep-alive + Date: + - Wed, 18 Apr 2018 14:54:05 GMT + X-Amzn-Requestid: + - 56771216-4318-11e8-b49a-3ff2a37cbf9f + X-Amz-Apigw-Id: + - FitR7E67GjQFrFw= + X-Amzn-Trace-Id: + - Root=1-5ad75c0c-8b2441903e2968c7dbc11433 + X-Cache: + - Error from cloudfront + Via: + - 1.1 94b0e881c9c9f6ab766133c7c81d54ed.cloudfront.net (CloudFront) + X-Amz-Cf-Id: + - NN_QZi4UrRPj_DCdzMFFrbixjIFT6KYbIGhUemygwIHwcd5btEPRHg== + body: + encoding: ASCII-8BIT + string: !binary |- + ewogICAgInN0YXR1cyI6ICI0MDAiLAogICAgIm1zZyI6ICJDcmVkZW5jaWFsIG7Do28gbG9jYWxpemFkYS4iCn0= + http_version: + recorded_at: Wed, 18 Apr 2018 14:54:05 GMT +recorded_with: VCR 4.0.0 diff --git a/spec/vcr_cassettes/contadigital/recebimento/boleto/emitir/erro_500.yml b/spec/vcr_cassettes/contadigital/recebimento/boleto/emitir/erro_500.yml new file mode 100644 index 0000000..c9e6ef1 --- /dev/null +++ b/spec/vcr_cassettes/contadigital/recebimento/boleto/emitir/erro_500.yml @@ -0,0 +1,55 @@ +--- +http_interactions: +- request: + method: post + uri: https://sandbox.pjbank.com.br/contadigital/a92c4a6fae4a8f9e06f141ca4561679f8a9d49a2/recebimentos/transacoes + body: + encoding: UTF-8 + string: '{"valor":"100.55"}' + headers: + Accept: + - "*/*" + Accept-Encoding: + - gzip, deflate + User-Agent: + - pjbank-ruby-sdk/0.1.0 + Content-Type: + - application/json + X-Chave: + - 6c1c05b0ccff1e4d3c8c7c28078d4928ec5d99db + Content-Length: + - '18' + Host: + - sandbox.pjbank.com.br + response: + status: + code: 500 + message: Internal Server Error + headers: + Content-Type: + - application/json + Content-Length: + - '105' + Connection: + - keep-alive + Date: + - Wed, 18 Apr 2018 14:44:14 GMT + X-Amzn-Requestid: + - f5ff97ef-4316-11e8-836b-8b11e9bf0293 + X-Amz-Apigw-Id: + - Fir1iFRnmjQFZnQ= + X-Amzn-Trace-Id: + - Root=1-5ad759bd-79c9cdaa09fd4c170180c273 + X-Cache: + - Error from cloudfront + Via: + - 1.1 6c2b5afbff5b4824ab1be294c1c31c34.cloudfront.net (CloudFront) + X-Amz-Cf-Id: + - YOiVihDBDaxiDRZd7jBKqcxay76Aknso85-NKy03s2QPjloSO8yUfQ== + body: + encoding: ASCII-8BIT + string: !binary |- + ewogICAgInN0YXR1cyI6ICI1MDAiLAogICAgIm1zZyI6ICJWZW5jaW1lbnRvLCBlc3RlIGNhbXBvIG7Do28gcG9kZSBzZXIgdmF6aW8uIiwKICAgICJjb2x1bW5pZG5hbWUiOiAiIgp9 + http_version: + recorded_at: Wed, 18 Apr 2018 14:44:14 GMT +recorded_with: VCR 4.0.0 diff --git a/spec/vcr_cassettes/contadigital/recebimento/boleto/emitir/sucesso.yml b/spec/vcr_cassettes/contadigital/recebimento/boleto/emitir/sucesso.yml new file mode 100644 index 0000000..68fa56c --- /dev/null +++ b/spec/vcr_cassettes/contadigital/recebimento/boleto/emitir/sucesso.yml @@ -0,0 +1,71 @@ +--- +http_interactions: +- request: + method: post + uri: https://sandbox.pjbank.com.br/contadigital/a92c4a6fae4a8f9e06f141ca4561679f8a9d49a2/recebimentos/transacoes + body: + encoding: UTF-8 + string: '{"vencimento":"12/30/2019","valor":50.75,"juros":0,"multa":0,"desconto":"","nome_cliente":"Cliente + de Exemplo","cpf_cliente":"62936576000112","endereco_cliente":"Rua Joaquim + Vilac","numero_cliente":"509","complemento_cliente":"","bairro_cliente":"Vila + Teixeira","cidade_cliente":"Campinas","estado_cliente":"SP","cep_cliente":"13301510","logo_url":"http://wallpapercave.com/wp/xK64fR4.jpg","texto":"Exemplo + de emissão de boleto","grupo":"Boletos","pedido_numero":"68908"}' + headers: + Accept: + - "*/*" + Accept-Encoding: + - gzip, deflate + User-Agent: + - pjbank-ruby-sdk/0.1.0 + Content-Type: + - application/json + X-Chave: + - 6c1c05b0ccff1e4d3c8c7c28078d4928ec5d99db + Content-Length: + - '472' + Host: + - sandbox.pjbank.com.br + response: + status: + code: 201 + message: Created + headers: + Content-Type: + - application/json + Content-Length: + - '584' + Connection: + - keep-alive + Date: + - Wed, 18 Apr 2018 16:00:10 GMT + X-Amzn-Requestid: + - 91d44754-4321-11e8-855a-b3d0d27bf366 + X-Amz-Apigw-Id: + - Fi29eEx8GjQFXUg= + X-Amzn-Trace-Id: + - Root=1-5ad76b89-7e449ae6db77c88d2e36ab85 + X-Cache: + - Miss from cloudfront + Via: + - 1.1 4251da4481948b0ac3a8deec1d24db31.cloudfront.net (CloudFront) + X-Amz-Cf-Id: + - zH6UPz8bv8PtZKf8BDS1dZS89dfzJV2iBIrFg_VL4SoV5931krEROw== + body: + encoding: UTF-8 + string: |- + { + "status": "201", + "msg": "Sucesso.", + "nossonumero": "121333", + "id_unico": "121333", + "banco_numero": "033", + "token_facilitador": "78f0dce295bf8c4fa26bf5de3daefd1d659fe381", + "credencial": "bcad14cd6befc106efa52f6a755c0789d106c1d2", + "linkBoleto": "https:\/\/sandbox.pjbank.com.br\/boletos\/41eeedac07ee602fcc6f31cf53087e62fe0070f2", + "linkGrupo": "https:\/\/sandbox.pjbank.com.br\/boletos\/grupos\/659966048461749609b8f4fb512deba64f0f4532", + "linhaDigitavel": "03399.69925 58737.800019 21333.301014 7 81190000005075", + "pedido_numero": "68908" + } + http_version: + recorded_at: Wed, 18 Apr 2018 16:00:10 GMT +recorded_with: VCR 4.0.0 diff --git a/spec/vcr_cassettes/contadigital/recebimento/boleto/emitir/sucesso_existent.yml b/spec/vcr_cassettes/contadigital/recebimento/boleto/emitir/sucesso_existent.yml new file mode 100644 index 0000000..dcbe48e --- /dev/null +++ b/spec/vcr_cassettes/contadigital/recebimento/boleto/emitir/sucesso_existent.yml @@ -0,0 +1,66 @@ +--- +http_interactions: +- request: + method: post + uri: https://sandbox.pjbank.com.br/contadigital/a92c4a6fae4a8f9e06f141ca4561679f8a9d49a2/recebimentos/transacoes + body: + encoding: UTF-8 + string: '{"vencimento":"12/30/2019","valor":50.75,"juros":0,"multa":0,"desconto":"","nome_cliente":"Cliente + de Exemplo","cpf_cliente":"62936576000112","endereco_cliente":"Rua Joaquim + Vilac","numero_cliente":"509","complemento_cliente":"","bairro_cliente":"Vila + Teixeira","cidade_cliente":"Campinas","estado_cliente":"SP","cep_cliente":"13301510","logo_url":"http://wallpapercave.com/wp/xK64fR4.jpg","texto":"Exemplo + de emissão de boleto","grupo":"Boletos","pedido_numero":"2342"}' + headers: + Accept: + - "*/*" + Accept-Encoding: + - gzip, deflate + User-Agent: + - pjbank-ruby-sdk/0.1.0 + Content-Type: + - application/json + X-Chave: + - 6c1c05b0ccff1e4d3c8c7c28078d4928ec5d99db + Content-Length: + - '471' + Host: + - sandbox.pjbank.com.br + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json + Content-Length: + - '370' + Connection: + - keep-alive + Date: + - Wed, 18 Apr 2018 14:42:31 GMT + X-Amzn-Requestid: + - b8ad80b4-4316-11e8-bbff-dd8d93e0612b + X-Amz-Apigw-Id: + - FirldHkhGjQFcSQ= + X-Amzn-Trace-Id: + - Root=1-5ad75956-56520dd753d0c40893e5fe64 + X-Cache: + - Miss from cloudfront + Via: + - 1.1 2c1dfdeba26d1f154396d817d28a8ee0.cloudfront.net (CloudFront) + X-Amz-Cf-Id: + - kzVB_tTPdh1n4_AZjxVdSM5bHdMT1yUUAwspR2gp7I01ptMNu_dM5Q== + body: + encoding: UTF-8 + string: |- + { + "status": "200", + "msg": "Sucesso.", + "nossonumero": "119508", + "linkBoleto": "https:\/\/sandbox.pjbank.com.br\/boletos\/740c7b2d1c23461be7118a4f061ff2d5cdc27dd3", + "linkGrupo": "https:\/\/sandbox.pjbank.com.br\/boletos\/grupos\/659966048461749609b8f4fb512deba64f0f4532", + "linhaDigitavel": "03399.69925 58737.800019 19508.401015 3 81190000005075" + } + http_version: + recorded_at: Wed, 18 Apr 2018 14:42:31 GMT +recorded_with: VCR 4.0.0 diff --git a/spec/vcr_cassettes/contadigital/recebimento/boleto/testando/bla.yml b/spec/vcr_cassettes/contadigital/recebimento/boleto/testando/bla.yml new file mode 100644 index 0000000..a4a1fc0 --- /dev/null +++ b/spec/vcr_cassettes/contadigital/recebimento/boleto/testando/bla.yml @@ -0,0 +1,70 @@ +--- +http_interactions: +- request: + method: post + uri: https://sandbox.pjbank.com.br/contadigital/a92c4a6fae4a8f9e06f141ca4561679f8a9d49a2/recebimentos/transacoes + body: + encoding: UTF-8 + string: '{"vencimento":"04/25/2018","valor":155.75,"juros":0,"multa":0,"desconto":"","nome_cliente":"João + Mello","cpf_cliente":"12406989763","endereco_cliente":"Rua Joaquim Vilac","numero_cliente":"509","complemento_cliente":"","bairro_cliente":"Vila + Teixeira","cidade_cliente":"Campinas","estado_cliente":"SP","cep_cliente":"13301510","logo_url":"http://wallpapercave.com/wp/xK64fR4.jpg","texto":"Boleto + boladão","grupo":"Boletos","pedido_numero":"69087"}' + headers: + Accept: + - "*/*" + Accept-Encoding: + - gzip, deflate + User-Agent: + - pjbank-ruby-sdk/0.1.0 + Content-Type: + - application/json + X-Chave: + - 6c1c05b0ccff1e4d3c8c7c28078d4928ec5d99db + Content-Length: + - '449' + Host: + - sandbox.pjbank.com.br + response: + status: + code: 201 + message: Created + headers: + Content-Type: + - application/json + Content-Length: + - '584' + Connection: + - keep-alive + Date: + - Wed, 18 Apr 2018 18:03:20 GMT + X-Amzn-Requestid: + - c6b88ff7-4332-11e8-b206-51a324c1c894 + X-Amz-Apigw-Id: + - FjJAMFJ3GjQFafQ= + X-Amzn-Trace-Id: + - Root=1-5ad78867-e60c6f34504e6f00cb1282f7 + X-Cache: + - Miss from cloudfront + Via: + - 1.1 441a4f67963b083bbf3d61460a1f347f.cloudfront.net (CloudFront) + X-Amz-Cf-Id: + - CWPtZC6H0Y9aYwUuYuT-kzLmlNJkl0LIzlw41i82QGvt6yZ7FvF8EQ== + body: + encoding: UTF-8 + string: |- + { + "status": "201", + "msg": "Sucesso.", + "nossonumero": "123336", + "id_unico": "123336", + "banco_numero": "033", + "token_facilitador": "78f0dce295bf8c4fa26bf5de3daefd1d659fe381", + "credencial": "bcad14cd6befc106efa52f6a755c0789d106c1d2", + "linkBoleto": "https:\/\/sandbox.pjbank.com.br\/boletos\/a8bda310250341ed6797b424105769baa0096134", + "linkGrupo": "https:\/\/sandbox.pjbank.com.br\/boletos\/grupos\/659966048461749609b8f4fb512deba64f0f4532", + "linhaDigitavel": "03399.69925 58737.800019 23336.901014 8 75050000015575", + "pedido_numero": "69087" + } + http_version: + recorded_at: Wed, 18 Apr 2018 18:03:20 GMT +recorded_with: VCR 4.0.0