Skip to content

Commit

Permalink
Inicia inclusão de boletos
Browse files Browse the repository at this point in the history
  • Loading branch information
RafaelEstevamReis committed Dec 8, 2023
1 parent e452879 commit 5cacf5b
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 13 deletions.
4 changes: 2 additions & 2 deletions Sicoob.Cobranca/Models/ConsultaBoleto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@

public class ConsultaBoletoRequest
{
public string client_id { get; set; } = string.Empty;
public string numeroContrato { get; set; } = string.Empty;
public int modalidade { get; set; } = 1; // Só tem a opção de `1`
public int? nossoNumero { get; set; }
public string? linhaDigitavel { get; set; }
public string? codigoBarras { get; set; }
public bool? gerarPdf { get; set; }
}
public class ConsultaBoletosPagadorRequest
{
public string client_id { get; set; } = string.Empty;
public string numeroContrato { get; set; } = string.Empty;
/// <summary>
/// 1: Em Aberto
Expand Down Expand Up @@ -78,6 +77,7 @@ public class DadosBoleto
public Listahistorico[]? listaHistorico { get; set; }
public string? situacaoBoleto { get; set; }
public Rateiocredito[]? rateioCreditos { get; set; }
public string? pdfBoleto { get; set; }
public string? qrCode { get; set; }
}

Expand Down
65 changes: 65 additions & 0 deletions Sicoob.Cobranca/Models/IncluirBoletos.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
namespace Sicoob.Cobranca.Models;

using System;

public class IncluirBoletosRequest
{
public int numeroContrato { get; set; }
public int modalidade { get; set; } = 1; // Simples com Registro
public int numeroContaCorrente { get; set; }
public string especieDocumento { get; set; } = "DM"; // Duplicata Mercantil, ver lista
public DateTime dataEmissao { get; set; }
public int nossoNumero { get; set; }
public string seuNumero { get; set; }

Check warning on line 13 in Sicoob.Cobranca/Models/IncluirBoletos.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'seuNumero' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
public string identificacaoBoletoEmpresa { get; set; }

Check warning on line 14 in Sicoob.Cobranca/Models/IncluirBoletos.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'identificacaoBoletoEmpresa' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
public int identificacaoEmissaoBoleto { get; set; }
public int identificacaoDistribuicaoBoleto { get; set; }
public decimal valor { get; set; }
public DateTime dataVencimento { get; set; }
public DateTime dataLimitePagamento { get; set; }
public int valorAbatimento { get; set; }
public int tipoDesconto { get; set; }
public DateTime dataPrimeiroDesconto { get; set; }
public decimal valorPrimeiroDesconto { get; set; }
public DateTime dataSegundoDesconto { get; set; }
public decimal valorSegundoDesconto { get; set; }
public DateTime dataTerceiroDesconto { get; set; }
public decimal valorTerceiroDesconto { get; set; }
public int tipoMulta { get; set; }
public DateTime dataMulta { get; set; }
public decimal valorMulta { get; set; }
public int tipoJurosMora { get; set; }
public DateTime dataJurosMora { get; set; }
public decimal valorJurosMora { get; set; }
public int numeroParcela { get; set; }
public bool aceite { get; set; }
public int codigoNegativacao { get; set; }
public int numeroDiasNegativacao { get; set; }
public int codigoProtesto { get; set; }
public int numeroDiasProtesto { get; set; }
public DadosPagador pagador { get; set; }

Check warning on line 40 in Sicoob.Cobranca/Models/IncluirBoletos.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'pagador' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
public Beneficiariofinal beneficiarioFinal { get; set; }

Check warning on line 41 in Sicoob.Cobranca/Models/IncluirBoletos.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'beneficiarioFinal' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
public Mensagensinstrucao mensagensInstrucao { get; set; }

Check warning on line 42 in Sicoob.Cobranca/Models/IncluirBoletos.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'mensagensInstrucao' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
public bool gerarPdf { get; set; }
public Rateiocredito[] rateioCreditos { get; set; }

Check warning on line 44 in Sicoob.Cobranca/Models/IncluirBoletos.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'rateioCreditos' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
/// <summary>
/// 0: Padrão, 1: Com PIX, 2: Sem PIX
/// </summary>
public int codigoCadastrarPIX { get; set; }
public int numeroContratoCobranca { get; set; }
}

public class IncluirBoletosResponse
{
public DadosInclusao[]? resultado { get; set; }
}
public class DadosInclusao
{
public ResultadoInclusao? status { get; set; }
public DadosBoleto? boleto { get; set; }
}
public class ResultadoInclusao
{
public int codigo { get; set; }
public string mensagem { get; set; } = string.Empty;
}
25 changes: 22 additions & 3 deletions Sicoob.Cobranca/SicoobCobranca.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
\**************************************/
namespace Sicoob.Cobranca;

using CS.BCB.PIX.Models;
using Sicoob.Cobranca.Models;
using Sicoob.Shared.Models.Acesso;
using Simple.API;
Expand Down Expand Up @@ -54,7 +55,6 @@ protected override void atualizaClients(TokenResponse token)
{
var consulta = new ConsultaBoletoRequest()
{
client_id = ConfigApi.ClientId ?? throw new ArgumentNullException($"{nameof(ConfigApi)}.{nameof(ConfigApi.ClientId)} must not be null"),
modalidade = 1,
numeroContrato = numeroContrato,
nossoNumero = nossoNumero,
Expand All @@ -73,11 +73,10 @@ protected override void atualizaClients(TokenResponse token)
/// <param name="dataVencimentoInicio">Data de Vencimento Inicial</param>
/// <param name="dataVencimentoFim">Data de Vencimento Final</param>
/// <returns>Boletos do Pagador</returns>
public async Task<ConsultaBoletosPagadorResponse> ConsultarBoletosPagador(string numeroCpfCnpj, string numeroContrato, int? codigoSituacao = null, DateTime? dataVencimentoInicio = null, DateTime? dataVencimentoFim = null)
public async Task<ConsultaBoletosPagadorResponse> ConsultarBoletosPagador(string numeroContrato, string numeroCpfCnpj,int? codigoSituacao = null, DateTime? dataVencimentoInicio = null, DateTime? dataVencimentoFim = null)
{
var consulta = new ConsultaBoletosPagadorRequest()
{
client_id = ConfigApi.ClientId ?? throw new ArgumentNullException($"{nameof(ConfigApi)}.{nameof(ConfigApi.ClientId)} must not be null"),
numeroContrato = numeroContrato,
codigoSituacao = codigoSituacao,
dataInicio = dataVencimentoInicio?.ToString("yyyy-MM-dd"),
Expand All @@ -86,4 +85,24 @@ public async Task<ConsultaBoletosPagadorResponse> ConsultarBoletosPagador(string
return await ExecutaChamadaAsync(() => clientApi.GetAsync<ConsultaBoletosPagadorResponse>("/cobranca-bancaria/v2/boletos/pagadores/" + numeroCpfCnpj, consulta));
}

public async Task<ConsultaBoletoResponse?> ConsultarSegundaViaBoleto(string numeroContrato, int modalidade, int? nossoNumero = null, string? linhaDigitavel = null, string? codigoBarras = null, bool gerarPdf = false)
{
var consulta = new ConsultaBoletoRequest()
{
modalidade = modalidade,
numeroContrato = numeroContrato,
nossoNumero = nossoNumero,
linhaDigitavel = linhaDigitavel,
codigoBarras = codigoBarras,
gerarPdf = gerarPdf
};
return await ExecutaChamadaAsync(() => clientApi.GetAsync<ConsultaBoletoResponse?>("/cobranca-bancaria/v2/boletos/segunda-via", consulta));
}

public async Task<IncluirBoletosResponse?> IncluirBoletos(IncluirBoletosRequest[] boletos)
{

return await ExecutaChamadaAsync(() => clientApi.PostAsync<IncluirBoletosResponse?>("/cobranca-bancaria/v2/boletos", boletos));
}

}
1 change: 1 addition & 0 deletions Sicoob.Testes/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
//await TestesApiPIX.Run();
//await TestesApiConta.Run_ContaCorrente();
//await TestesApiConta.Run_ContaPoupanca();
await TestesApiCobranca.Run_Cobranca();

11 changes: 3 additions & 8 deletions Sicoob.Testes/TestesApiCobranca.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,9 @@ internal static async Task Run_Cobranca()
var cobranca = new SicoobCobranca(cfg);
await cobranca.SetupAsync();

//var consulta = await cobranca.ConsultarBoletos("531413");
var consulta = await cobranca.ConsultarBoletosPagador(new Cobranca.Models.ConsultaBoletosPagadorRequest()
{
client_id = cfg.ClientId,
numeroContrato = "531413",
numeroCpfCnpj = "45769189000209",
});

var boleto = await cobranca.ConsultarBoleto("", nossoNumero: 0);
var consulta = await cobranca.ConsultarBoletosPagador("", numeroCpfCnpj: "");
var segVia = await cobranca.ConsultarSegundaViaBoleto("",1, nossoNumero: 0, gerarPdf: true);

cfg = cfg;
}
Expand Down

0 comments on commit 5cacf5b

Please sign in to comment.