Kleer 1.0.5

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

Kleer

Kleer is an accounting service — see API documentation.
This project provides C# bindings to make it easier to interact with the Kleer API.

Om oss / About us
SE: Vi på Devies är experter på Kleer, är integrationspartner med dem och hjälper gärna till med integrationer, rådgivning och vidareutveckling.
EN: We at Devies are Kleer experts and an integration partner. We're happy to help with integrations, advisory work, and enhancements.
Kontakt / Contact: hello@devies.se

Generating models

The Kleer data model is defined by an XML Schema (XSD) available at
https://api.kleer.se/v1/xsd.
We keep a copy of this schema in Kleer/doc.xsd and use it to generate the Kleer.Models classes.

The GitHub Actions pipeline automatically checks whether the generated models differ from the committed ones.
If that check fails, you can regenerate the models locally with:

curl -sSL https://api.kleer.se/v1/xsd -o Kleer/doc.xsd
rm -rf Kleer/Models
mkdir -p Kleer/Models
xscgen Kleer/doc.xsd --namespace=Kleer.Models --output Kleer/Models

KleerClient

KleerClient is a wrapper around HttpClient that simplifies working with the Kleer API.

  • It sets up the BaseAddress and authentication headers (X-Token).

  • It provides helpers to build requests:

    • BuildRequest – bare request with default headers.

    • BuildXmlRequest<T> – request with XML-serialized content from a model.

    • BuildBinaryRequest – request for file uploads (byte array or stream).

  • It provides async send methods:

    • SendAsync(HttpRequestMessage) – returns raw HttpResponseMessage.

    • SendAsync<T>(HttpRequestMessage) – sends a request and deserializes the XML response into a model.

Example usage:

var client = new KleerClient(token, "https://api.kleer.se/v1/company/1234/");
var request = KleerClient.BuildRequest(HttpMethod.Get, "user/54321");
var user = await client.SendAsync<User>(request);

or for XML POSTs:

var data = new ApproveEventsRequest { ... };
var request = KleerClient.BuildXmlRequest(HttpMethod.Post, "event/approve", data);
var result = await client.SendAsync<Ok>(request);

KleerXmlSerializer

The Kleer API’s schema is defined via XSD, and xscgen generates C# models decorated with [XmlType]. However, xscgen also generates duplicate *2Redefinition classes for schema redefinitions, which can cause the built-in XmlSerializer to fail.

KleerXmlSerializer works around this by:

  • Automatically renaming all *2Redefinition classes to unique names at runtime.
  • Caching XmlSerializer instances per type (and per assembly override set) for performance.
  • Serializing with settings tuned for the Kleer API:
    • UTF-8 encoding without BOM.
    • No XML declaration (<?xml ...?>).
    • Suppressed xmlns:xsi / xmlns:xsd namespace attributes.

Typically, you do not need to use KleerXmlSerializer directly, it is used internally by KleerClient for both requests and responses. But you can use it if you just want to work with models outside of HTTP:

var xml = KleerXmlSerializer.Serialize(user);
var parsed = KleerXmlSerializer.Deserialize<User>(xml);

XML vs JSON

The Kleer API supports both XML and JSON payloads.

Historically, the JSON examples in the documentation have sometimes been outdated or inconsistent, while the XML schema (XSD) is authoritative and always up to date. Because of this, this client defaults to XML for both requests and responses, ensuring compatibility with the official schema-generated models.

You can still send JSON manually if needed by constructing your own HttpRequestMessage with application/json content. If you build helpers for this, feel free to contribute them back to this repository.

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 netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen 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.5 132 8/19/2025
1.0.4 128 8/19/2025
1.0.3 133 8/14/2025
1.0.2 132 8/13/2025
1.0.1 128 8/13/2025
1.0.0 128 8/13/2025