TeronEsirClient 1.0.6

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

TeronEsirClient

Simple facade for .NET HttpClient covering all* requests described in the Teron ESIR API docs (also applicable to OFS P5 EFU ESIR, since they are nearly identical).

Bug-reports and pull requests are welcome.

* E-Faktura requests are currently not supported.

Installation

Install the package with NuGet:

Install-Package TeronEsirClient

Or using the .NET CLI:

dotnet add package TeronEsirClient

Usage

A new instance of TeronEsirApiClient is created by passing it an instance of HttpClient via the constructor:

TeronEsirApiClient client = new TeronEsirApiClient(myHttpClient);

It us up to you to construct the HttpClient beforehand. Reading up on Microsoft's best practices for using the HttpClient is recommended.

All of the methods return the result of type TeronEsirResult, or TeronEsirResult<T> if there is data that needs to be returned from the API. This type contains the following properties:

 // Whether the operation was successful or not
 public bool IsSuccessful { get; } 
 
 // Message from the API
 public string Message { get; }
 
 // Raw response content from the API
 public string RawResponse { get; }
 
 // The value returned (if applicable)
 public T Value { get; }

Fiscalization request example

Following is a fiscalization request example inside a ASP.NET 9 WebAPI controller:

[HttpPut("fiscalize")]
public async Task<IActionResult> Fiscalize([FromServices] IHttpClientFactory httpClientFactory)
{
    var httpClient = httpClientFactory.CreateClient();
    var teronEsirClient = new TeronEsirApiClient(httpClient);

    TeronEsirApiParameters apiParams = new("http://192.168.1.100:3566", "Bearer myBearerToken32432523523");

    // Check if available
    bool isAvaliable = await teronEsirClient.IsAvailableAsync(apiParams);
    if (!isAvaliable) return BadRequest("ESIR unavaliable");

    // Check if secure element is inserted
    var statusResult = await teronEsirClient.GetStatusAsync(apiParams);
    if (!statusResult.IsSuccessful)
    {
        return BadRequest(statusResult.Message);
    }

    if (statusResult.Value!.Gsc.Contains(TeronEsirClient.Enums.LpfrStatus.SmartCardNotPresent))
    {
        return BadRequest("Secure element not inserted");
    }

    if (statusResult.Value!.Gsc.Contains(TeronEsirClient.Enums.LpfrStatus.SmartCardNotPresent))
    {
        return BadRequest("Secure element not inserted");
    }

    // Check if pin is required and enter it
    if (statusResult.Value!.Gsc.Contains(TeronEsirClient.Enums.LpfrStatus.PinCodeRequired))
    {
        var unlockResult = await teronEsirClient.UnlockSecureElementAsync(apiParams, "1234");
        if (!unlockResult.IsSuccessful)
        {
            return BadRequest(unlockResult.Message);
        }
    }


    TeronEsirInvoice teronEsirInvoice = new()
    {
        InvoiceRequest = new TeronEsirInvoiceRequest
        {
            InvoiceType = TeronEsirClient.Enums.InvoiceType.Normal,
            TransactionType = TeronEsirClient.Enums.TransactionType.Sale,
            Payment = [
                    new TeronEsirPayment {
                        PaymentType = TeronEsirClient.Enums.PaymentType.Cash,
                        Amount = 50,
                    },
                    new TeronEsirPayment {
                        PaymentType = TeronEsirClient.Enums.PaymentType.Card,
                        Amount = 50,
                    }
                ],
            Cashier = "John Smith",
            BuyerId = "JOHN1234",
            BuyerCostCenterId = "COSTCENTER1234",
            Items = [
                    new TeronEsirInvoiceItem {
                        Name = "Item 1",
                        Gtin = "12345678",
                        Labels = ["A"],
                        UnitPrice = 25,
                        Quantity = 2,
                        TotalAmount = 50,
                        Discount = 0,
                        DiscountAmount = 0,
                    },
                    new TeronEsirInvoiceItem {
                        Name = "Item 2",
                        Gtin = "22345678",
                        Labels = ["A"],
                        UnitPrice = 50,
                        Quantity = 1,
                        TotalAmount = 50,
                        Discount = 0,
                        DiscountAmount = 0,
                    }
                ],
        },
        Print = true,
        Email = "johnsmith@somecompany.com",
        RenderReceiptImage = true,
        ReceiptImageFormat = TeronEsirClient.Enums.ReceiptImageFormat.Png,
        ReceiptLayout = TeronEsirClient.Enums.ReceiptLayout.Slip,
        ReceiptFooterTextLines = ["Line 1", "Line 2"],
    };

    var fiscalizationResult = await teronEsirClient.IssueInvoiceAsync(apiParams, teronEsirInvoice);
    if (!fiscalizationResult.IsSuccessful)
    {
        return BadRequest(fiscalizationResult.Message);
    }


    return Ok($"Fiscalized invoice: {fiscalizationResult.Value.InvoiceNumber} and sent to email.");
}
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 was computed.  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.6 231 12/4/2025
1.0.5 223 6/24/2025
1.0.4 165 5/18/2025
1.0.3 224 5/16/2025
1.0.2 283 5/14/2025
1.0.1 122 5/10/2025
1.0.0 219 3/27/2025