RetailSolutions.Shared.Max 1.3.1387

dotnet add package RetailSolutions.Shared.Max --version 1.3.1387
                    
NuGet\Install-Package RetailSolutions.Shared.Max -Version 1.3.1387
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="RetailSolutions.Shared.Max" Version="1.3.1387" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="RetailSolutions.Shared.Max" Version="1.3.1387" />
                    
Directory.Packages.props
<PackageReference Include="RetailSolutions.Shared.Max" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add RetailSolutions.Shared.Max --version 1.3.1387
                    
#r "nuget: RetailSolutions.Shared.Max, 1.3.1387"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package RetailSolutions.Shared.Max@1.3.1387
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=RetailSolutions.Shared.Max&version=1.3.1387
                    
Install as a Cake Addin
#tool nuget:?package=RetailSolutions.Shared.Max&version=1.3.1387
                    
Install as a Cake Tool

RetailSolutions.Shared.Max

Biblioteca .NET que fornece abstrações e integração simplificada com a API da Max Sistemas, incluindo gerenciamento automático de autenticação, cache de tokens e configuração de HttpClient.

Características

  • 🔐 Autenticação Automática: Gerenciamento automático de tokens de acesso com cache em Redis
  • 🌐 HttpClient Configurado: Múltiplos clientes HTTP pré-configurados para diferentes endpoints da API
  • Cache Inteligente: Cache de tokens em Redis para otimizar performance
  • 🔧 Fácil Configuração: Extensões simples para integração com HostApplicationBuilder
  • 📝 Logging Integrado: Suporte completo a logging com Serilog

Instalação

Instale o pacote via NuGet:

dotnet add package RetailSolutions.Shared.Max

Ou via Package Manager:

Install-Package RetailSolutions.Shared.Max

Requisitos

  • .NET 10.0 ou superior
  • Redis (para cache de tokens)
  • Credenciais de acesso à API Max Sistemas

Início Rápido

1. Configurar o Redis

Primeiro, configure o Redis no seu projeto. Este pacote utiliza RetailSolutions.Shared.Cache para gerenciar a conexão Redis.

2. Configurar a Aplicação

No seu arquivo Program.cs ou Startup.cs, adicione a configuração:

using RetailSolutions.Shared.Max;

var builder = Host.CreateApplicationBuilder(args);

// Configurar Max Sistemas
builder.Services.Configure<MaxSistemasConfiguration>(builder.Configuration.GetSection("MaxSistemas"));
builder.AddMaxHttpClient();

var host = builder.Build();

3. Configurar appsettings.json

Adicione as configurações no seu appsettings.json:

{
  "MaxSistemas": {
    "BaseUrl": "https://api.maxsistemas.com.br",
    "BaseUrlUnificado": "https://api-unificado.maxsistemas.com.br",
    "BaseUrl04": "https://api04.maxsistemas.com.br",
    "Login": "seu-login",
    "Password": "sua-senha"
  }
}

4. Usar os HttpClientes

O pacote registra automaticamente vários clientes HTTP nomeados que você pode injetar:

public class MeuServico
{
    private readonly IHttpClientFactory _httpClientFactory;
    
    public MeuServico(IHttpClientFactory httpClientFactory)
    {
        _httpClientFactory = httpClientFactory;
    }
    
    public async Task<string> ObterDadosAsync()
    {
        var client = _httpClientFactory.CreateClient(MaxConstants.MAX_SISTEMAS_API);
        var response = await client.GetAsync("/api/v1/dados");
        return await response.Content.ReadAsStringAsync();
    }
}

Clientes HTTP Disponíveis

O pacote registra os seguintes clientes HTTP nomeados:

  • MaxSistemas-API: Cliente principal para a API Max Sistemas
  • MaxSistemas-API-Unificado: Cliente para a API Unificada
  • MaxSistemas-API-04: Cliente para a API versão 04
  • MaxSistemas-TOKEN: Cliente para autenticação (sem handler de autorização)

Todos os clientes de API incluem automaticamente o header de autorização Bearer token.

Gerenciamento de Tokens

O MaxTokenService gerencia automaticamente os tokens de acesso:

  • Tokens são armazenados em cache no Redis
  • Tokens são renovados automaticamente quando expiram
  • Cache é compartilhado entre instâncias da aplicação

Usar o Token Service Diretamente

public class MeuServico
{
    private readonly ITokenService _tokenService;
    
    public MeuServico(ITokenService tokenService)
    {
        _tokenService = tokenService;
    }
    
    public async Task<string> ObterTokenAsync()
    {
        return await _tokenService.GetAccessTokenAsync();
    }
}

Exemplo Completo

using Microsoft.Extensions.Options;
using RetailSolutions.Shared.Max;

var builder = Host.CreateApplicationBuilder(args);

// Configurar Max Sistemas
builder.Services.Configure<MaxSistemasConfiguration>(
    builder.Configuration.GetSection("MaxSistemas")
);

// Adicionar serviços Max
builder.AddMaxHttpClient();

// Registrar seu serviço
builder.Services.AddScoped<MeuServico>();

var host = builder.Build();

// Usar o serviço
var servico = host.Services.GetRequiredService<MeuServico>();
var dados = await servico.ObterDadosAsync();

Configuração Avançada

Personalizar Timeout de Conexão

Os clientes HTTP são configurados com:

  • Pool de conexões com lifetime de 15 minutos
  • Validação de certificado SSL customizada
  • Handler lifetime infinito para reutilização de conexões

Logging

O pacote utiliza ILogger para registrar:

  • Requisições de autenticação
  • Respostas da API
  • Erros e exceções

Configure seu logger preferido (Serilog, NLog, etc.) normalmente.

Dependências

  • Microsoft.Extensions.Http (10.0.1)
  • Microsoft.Extensions.Logging (10.0.1)
  • Microsoft.Extensions.Options (10.0.1)
  • Newtonsoft.Json (13.0.4)
  • Serilog (4.3.0)
  • StackExchange.Redis (2.10.1)
  • RetailSolutions.Shared.Cache (1.2.73)

Suporte e Feedback

Licença

Copyright © Retail Solutions. Todos os direitos reservados.

Tags

Gemco, RetailSolutions, Max Sistemas

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.3.1387 113 7/6/2026
1.2.126 98 7/6/2026
1.2.78 144 12/13/2025