Skip to content

invoicetronic/csharp-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

124 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

C# SDK for the Invoicetronic API

The Invoicetronic API is a RESTful service that allows you to send and receive invoices through the Italian Servizio di Interscambio (SDI), or Interchange Service. The API is designed to be simple and easy to use, abstracting away SDI complexity while providing complete control over the invoice send/receive process. It provides advanced features as encryption at rest, multi-language pre-flight invoice validation, multiple upload formats, webhooks, event logging, client SDKs, and CLI tools.

For more information, see Invoicetronic website

Before you start

For the full integration guide, tutorials, SDKs and quickstarts, see the Documentation. A few cross-cutting topics worth knowing before integrating:

  • Prerequisites — what you need to start in Sandbox and what's required to move to production.
  • API Keys — how ik_live_ and ik_test_ keys select the environment.
  • Sandbox — free test environment that mirrors the live workflow, with no credits consumed.
  • Rate Limiting — per-second, per-minute and per-day limits; how to handle 429 Too Many Requests.
  • Paginationpage and page_size parameters and the Invoicetronic-Total-Count response header.
  • CORS — calling the API from the browser; allowed origins are configured per key.
  • Webhooks — real-time event notifications with HMAC-SHA256 signature validation.
  • Localization — use the Accept-Language header to receive error messages in Italian, English or German.

This C# SDK is automatically generated by the OpenAPI Generator project:

  • API version: 1.14.0
  • SDK version: 1.9
  • Generator version: 7.20.0
  • Build package: org.openapitools.codegen.languages.CSharpClientCodegen For more information, please visit https://invoicetronic.com/en/contact/

Frameworks supported

  • .NET Core >=1.0
  • .NET Framework >=4.6
  • Mono/Xamarin >=vNext

Dependencies

The DLLs included in the package may not be the latest version. We recommend using NuGet to obtain the latest version of the packages:

Install-Package Newtonsoft.Json
Install-Package JsonSubTypes
Install-Package System.ComponentModel.Annotations

Installation

Generate the DLL using your preferred tool (e.g. dotnet build)

Then include the DLL (under the bin folder) in the C# project, and use the namespaces:

using Invoicetronic.Sdk.Api;
using Invoicetronic.Sdk.Client;
using Invoicetronic.Sdk.Model;

Usage

To use the API client with a HTTP proxy, setup a System.Net.WebProxy

Configuration c = new Configuration();
System.Net.WebProxy webProxy = new System.Net.WebProxy("http://myProxyUrl:80/");
webProxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
c.Proxy = webProxy;

Connections

Each ApiClass (properly the ApiClient inside it) will create an instance of HttpClient. It will use that for the entire lifecycle and dispose it when called the Dispose method.

To better manager the connections it's a common practice to reuse the HttpClient and HttpClientHandler (see here for details). To use your own HttpClient instance just pass it to the ApiClass constructor.

HttpClientHandler yourHandler = new HttpClientHandler();
HttpClient yourHttpClient = new HttpClient(yourHandler);
var api = new YourApiClass(yourHttpClient, yourHandler);

If you want to use an HttpClient and don't have access to the handler, for example in a DI context in Asp.net Core when using IHttpClientFactory.

HttpClient yourHttpClient = new HttpClient();
var api = new YourApiClass(yourHttpClient);

You'll loose some configuration settings, the features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. You need to either manually handle those in your setup of the HttpClient or they won't be available.

Here an example of DI setup in a sample web project:

services.AddHttpClient<YourApiClass>(httpClient =>
   new PetApi(httpClient));

Getting Started

using System.Collections.Generic;
using System.Diagnostics;
using System.Net.Http;
using Invoicetronic.Sdk.Api;
using Invoicetronic.Sdk.Client;
using Invoicetronic.Sdk.Model;

namespace Example
{
    public class Example
    {
        public static void Main()
        {

            Configuration config = new Configuration();
            config.BasePath = "https://api.invoicetronic.com";
            // Configure HTTP basic authorization: Basic
            config.Username = "YOUR_USERNAME";
            config.Password = "YOUR_PASSWORD";

            // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes
            HttpClient httpClient = new HttpClient();
            HttpClientHandler httpClientHandler = new HttpClientHandler();
            var apiInstance = new CompanyApi(httpClient, config, httpClientHandler);
            var page = 1;  // int? | Page number. (optional)  (default to 1)
            var pageSize = 100;  // int? | Items per page. Cannot be greater than 200. (optional)  (default to 100)
            var sort = "sort_example";  // string | Sort by field. Prefix with '-' for descending order. (optional) 
            var q = "q_example";  // string | Full-text search across committente, prestatore, identifier, and file name. (optional) 

            try
            {
                // List companies
                List<Company> result = apiInstance.CompanyGet(page, pageSize, sort, q);
                Debug.WriteLine(result);
            }
            catch (ApiException e)
            {
                Debug.Print("Exception when calling CompanyApi.CompanyGet: " + e.Message );
                Debug.Print("Status Code: "+ e.ErrorCode);
                Debug.Print(e.StackTrace);
            }

        }
    }
}

Documentation for API Endpoints

All URIs are relative to http://localhost

Class Method HTTP request Description
CompanyApi CompanyGet GET /company List companies
CompanyApi CompanyIdDelete DELETE /company/{id} Delete a company
CompanyApi CompanyIdGet GET /company/{id} Get a company by id
CompanyApi CompanyPost POST /company Add a company
CompanyApi CompanyPut PUT /company Update a company
CompanyApi CompanyVatGet GET /company/{vat} Get a company by vat number
ExportApi ExportGet GET /export Export invoices as a ZIP archive
HealthApi HealthGet GET /health Health check
LogApi LogGet GET /log List events
LogApi LogIdGet GET /log/{id} Get an event by id
ReceiveApi ReceiveGet GET /receive List incoming invoices
ReceiveApi ReceiveIdDelete DELETE /receive/{id} Delete an incoming invoice by id
ReceiveApi ReceiveIdGet GET /receive/{id} Get an incoming invoice by id
ReceiveApi ReceiveIdPayloadGet GET /receive/{id}/payload Get a receive invoice payload by id
SendApi SendFilePost POST /send/file Add an invoice by file
SendApi SendGet GET /send List invoices
SendApi SendIdGet GET /send/{id} Get a invoice by id
SendApi SendIdPayloadGet GET /send/{id}/payload Get a send invoice payload by id
SendApi SendIdentifierGet GET /send/{identifier} Get a invoice by identifier
SendApi SendJsonPost POST /send/json Add an invoice by json
SendApi SendPost POST /send Add an invoice
SendApi SendValidateFilePost POST /send/validate/file Validate an invoice file
SendApi SendValidateJsonPost POST /send/validate/json Validate an invoice by json
SendApi SendValidatePost POST /send/validate Validate an invoice
SendApi SendValidateXmlPost POST /send/validate/xml Validate an invoice by xml
SendApi SendXmlPost POST /send/xml Add an invoice by xml
StatusApi StatusGet GET /status Account status
UpdateApi UpdateGet GET /update List updates
UpdateApi UpdateIdGet GET /update/{id} Get an update by id
WebhookApi WebhookGet GET /webhook List webhooks
WebhookApi WebhookIdDelete DELETE /webhook/{id} Delete a webhook by id
WebhookApi WebhookIdGet GET /webhook/{id} Get a webhook by id
WebhookApi WebhookPost POST /webhook Add a webhook
WebhookApi WebhookPut PUT /webhook Update a webhook
WebhookApi WebhookhistoryGet GET /webhookhistory List webhook history items
WebhookApi WebhookhistoryIdGet GET /webhookhistory/{id} Get a webhook history item by id

Documentation for Models

Documentation for Authorization

Authentication schemes defined for the API:

Basic

  • Type: HTTP basic authentication

About

C# SDK for the Invoicetronic API

Topics

Resources

License

Stars

1 star

Watchers

1 watching

Forks

Contributors

Languages