From 2b2ace135de5f916c6437166473eef0aeaa76a5b Mon Sep 17 00:00:00 2001 From: RafaelEstevamReis Date: Mon, 18 Dec 2023 10:56:34 -0300 Subject: [PATCH] =?UTF-8?q?[CC]=20Refatora=20c=C3=B3digo=20da=20conta?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sicoob.Conta/SicoobContaCorrente.cs | 17 +++++------------ Sicoob.Testes/TestesApiConta.cs | 4 ++-- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/Sicoob.Conta/SicoobContaCorrente.cs b/Sicoob.Conta/SicoobContaCorrente.cs index 47a8514..7544c79 100644 --- a/Sicoob.Conta/SicoobContaCorrente.cs +++ b/Sicoob.Conta/SicoobContaCorrente.cs @@ -17,13 +17,16 @@ public sealed class SicoobContaCorrente : Shared.Sicoob // > APIs tipo "Swagger": // https://developers.sicoob.com.br/#!/apis + private readonly int numeroContaCorrente; private ClientInfo clientApi; + public Shared.Models.ConfiguracaoAPI ConfigApi { get; } - public SicoobContaCorrente(Shared.Models.ConfiguracaoAPI configApi, System.Security.Cryptography.X509Certificates.X509Certificate2? certificado = null) + public SicoobContaCorrente(Shared.Models.ConfiguracaoAPI configApi, int NumeroContaCorrente, System.Security.Cryptography.X509Certificates.X509Certificate2? certificado = null) : base(configApi, certificado) { ConfigApi = configApi; + numeroContaCorrente = NumeroContaCorrente; } protected override void setupClients(HttpClientHandler handler) @@ -44,24 +47,14 @@ protected override void atualizaClients(TokenResponse token) /// O recurso de Saldo retorna o valor disponível atual e o limite de crédito (cheque especial) de uma conta corrente. /// public async Task> ObterSaldoAsync() - => await ExecutaChamadaAsync(() => clientApi.GetAsync>("/conta-corrente/v2/saldo")); - /// - /// O recurso de Saldo retorna o valor disponível atual e o limite de crédito (cheque especial) de uma conta corrente. - /// - public async Task> ObterSaldoAsync(string numeroContaCorrente) => await ExecutaChamadaAsync(() => clientApi.GetAsync>("/conta-corrente/v2/saldo", new { numeroContaCorrente })); + /// /// O recurso de Extrato retorna todas as transações ocorridas em uma conta corrente no devido mês e ano. /// Há um limite de 3 meses /// public async Task> ObterExtratoAsync(int mes, int ano) - => await ExecutaChamadaAsync(() => clientApi.GetAsync>($"/conta-corrente/v2/extrato/{mes}/{ano}")); - /// - /// O recurso de Extrato retorna todas as transações ocorridas em uma conta corrente no devido mês e ano. - /// Há um limite de 3 meses - /// - public async Task> ObterExtratoAsync(int mes, int ano, string numeroContaCorrente) => await ExecutaChamadaAsync(() => clientApi.GetAsync>($"/conta-corrente/v2/extrato/{mes}/{ano}", new { numeroContaCorrente })); } diff --git a/Sicoob.Testes/TestesApiConta.cs b/Sicoob.Testes/TestesApiConta.cs index 9459ba3..911e912 100644 --- a/Sicoob.Testes/TestesApiConta.cs +++ b/Sicoob.Testes/TestesApiConta.cs @@ -26,11 +26,11 @@ public static async Task Run_ContaCorrente() //}; //File.WriteAllText("config_CC.json", JsonConvert.SerializeObject(cfg)); - var cCorrente = new SicoobContaCorrente(cfg); + var cCorrente = new SicoobContaCorrente(cfg, 00000); await cCorrente.SetupAsync(); + var extrato = await cCorrente.ObterExtratoAsync(12, 2023); var saldo = await cCorrente.ObterSaldoAsync(); - var extrato = await cCorrente.ObterExtratoAsync(12, 2022); } public static async Task Run_ContaPoupanca() {