Ecuafact.Sdk.Core 1.0.0

dotnet add package Ecuafact.Sdk.Core --version 1.0.0
                    
NuGet\Install-Package Ecuafact.Sdk.Core -Version 1.0.0
                    
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="Ecuafact.Sdk.Core" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Ecuafact.Sdk.Core" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Ecuafact.Sdk.Core" />
                    
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 Ecuafact.Sdk.Core --version 1.0.0
                    
#r "nuget: Ecuafact.Sdk.Core, 1.0.0"
                    
#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 Ecuafact.Sdk.Core@1.0.0
                    
#: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=Ecuafact.Sdk.Core&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Ecuafact.Sdk.Core&version=1.0.0
                    
Install as a Cake Tool

Ecuafact.Sdk.Core

Integracion de dependencias (Microsoft.Extensions.DependencyInjection) para Ecuafact.Sdk. Compatible con netstandard2.0 y net10.0.

Instalacion

dotnet add package Ecuafact.Sdk.Core

Uso

Registra el cliente y resuelve la interfaz.

using Ecuafact.Sdk.Core;

builder.Services.AddEcuafactClient(o =>
{
    o.BaseAddress = new Uri(configuration["Ecuafact:BaseUrl"]!); // sandbox: https://staging-api.mynexusapi.com/ (sin /v1)
    o.ApiKey = configuration["Ecuafact:ApiKey"]!;
    // o.Identificacion = "0123456789001"; // valor "identificacion" de GET /v1/contexto; solo integraciones de un contribuyente
});

Si no configuras ApiKey ni BaseAddress, el SDK lee ECUAFACT_API_KEY y ECUAFACT_BASE_URL.

El cliente por defecto queda inyectable como IEcuafactClient:

public sealed class Facturacion(IEcuafactClient client)
{
    public async Task EmitirAsync(FacturaRequest comprobante, CancellationToken ct)
    {
        EmisionResultado r = await client.EmitirAsync(comprobante, ct: ct);
        Operation op = await client.EsperarResultadoAsync(r.Admission.IdOperacion, ct: ct);
        Console.WriteLine(op.EsAutorizado);
    }
}

Desde configuracion

{
  "Ecuafact": {
    "BaseAddress": "https://staging-api.mynexusapi.com/",
    "ApiKey": "",
    "Identificacion": "0123456789001",
    "MaxAttempts": 3,
    "RetryRateLimited": true,
    "RetryBackoff": "Exponential",
    "TotalTimeout": "00:01:00",
    "RetryableStatusCodes": [ 408, 425, 500, 502, 503, 504 ]
  }
}
builder.Services.AddEcuafactClient(builder.Configuration.GetSection("Ecuafact"));

Claves admitidas: BaseAddress (o BaseUrl), ApiKey, Identificacion, Timeout, UserAgent, RetryTransientFailures, MaxAttempts, RespectRetryAfter, MaxRetryDelay, RetryRateLimited, RetryableStatusCodes, RetryBaseDelay, RetryBackoff, RetryJitter, TotalTimeout y AdditionalInfo (cabecera X-Additional-Info). Timeout por defecto: 30 s por intento. Los tiempos aceptan hh:mm:ss o segundos. No guardes la API Key en appsettings.json: usa secretos de usuario o variables de entorno.

Pipeline HTTP (proxy, TLS, handlers)

Cada cliente usa el HttpClient nombrado Ecuafact:<nombre>. Configuralo con el IHttpClientBuilder:

builder.Services.AddEcuafactHttpClient(o => { /* opciones */ })
    .ConfigurePrimaryHttpMessageHandler(() => new SocketsHttpHandler
    {
        Proxy = new WebProxy("http://proxy.local:8080"),
        ConnectTimeout = TimeSpan.FromSeconds(10)
    })
    .AddHttpMessageHandler<MiHandlerDeAuditoria>();

// O sobre un cliente ya registrado con AddEcuafactClient:
builder.Services.ConfigureEcuafactHttpClient("integracionA").AddHttpMessageHandler<MiHandlerDeAuditoria>();

EcuafactClientOptions.Handler tambien entra por IHttpClientFactory: es el handler principal del HttpClient nombrado, todas las resoluciones comparten sus conexiones y la fabrica no lo libera al rotar. Crea la instancia fuera de la lambda de configuracion. Un ConfigurePrimaryHttpMessageHandler sobre el builder tiene prioridad sobre options.Handler.

var proxy = new SocketsHttpHandler { Proxy = new WebProxy("http://proxy.local:8080") };
builder.Services.AddEcuafactClient(o => { /* opciones */ o.Handler = proxy; });

Varias credenciales

Registra un cliente por nombre (una credencial por integracion).

builder.Services.AddEcuafactClient("integracionA", o =>
{
    o.BaseAddress = new Uri(configuration["EcuafactA:BaseUrl"]!);
    o.ApiKey = configuration["EcuafactA:ApiKey"]!;
});
builder.Services.AddEcuafactClient("integracionB", configuration.GetSection("EcuafactB"));
public sealed class Multi(IEcuafactClientProvider provider)
{
    public Task Emitir(CancellationToken ct)
        => provider.GetClient("integracionA").EmitirAsync(comprobante, ct: ct);
}

La politica de reintentos es la del SDK base: el 429 por limite de solicitudes (o sin cuerpo) se reintenta por defecto respetando Retry-After (RetryRateLimited = false lo desactiva) y el cupo agotado (429/cupo_agotado) nunca se reintenta.

Documentacion

Licencia

MIT.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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.0.0 91 11/14/2026

Versión 1.0.0 de la integración de dependencias del SDK de Ecuafact: AddEcuafactClient, clientes con nombre y configuración desde IConfiguration sobre IHttpClientFactory.