A hard fork of Zammad.Client with support for System.Text.Json
instead of
Newtonsoft.Json
.
This library provides a .NET client for interacting with the Zammad helpdesk system API.
dotnet add package Zammad.Client.SystemTextJson
Basic example:
var httpClient = new HttpClient();
var client = new ZammadClient(
httpClient,
Options.Create(new ZammadOptions
{
BaseUrl = new Uri("https://zammad.example.com/"),
Token = "your_token_here",
})
);
var user = await client.GetUserMeAsync();
Console.WriteLine($"Signed in as {user.FirstName} {user.LastName} ({user.Email})");
Install the extensions package:
dotnet add package Zammad.Client.SystemTextJson.Extensions
Configure the client:
builder.Services.AddZammadClient(options =>
{
options.BaseUrl = new Uri("https://zammad.example.com/");
options.Token = "your_token_here";
});
Alternatively, use a configuration section:
builder.Services.AddZammadClient(builder.Configuration.GetSection("Zammad"));
Then inject the client:
public class MyService(IZammadClient client)
{
public async Task DoSomething()
{
var user = await client.GetUserMeAsync();
Console.WriteLine($"Signed in as {user.FirstName} {user.LastName} ({user.Email})");
}
}
The AddZammadClient
method returns an IHttpClientBuilder
, allowing further customization of the underlying
HttpClient
. For example, to add a resilience handler:
dotnet add package Microsoft.Extensions.Http.Resilience
builder.Services.AddZammadClient(builder.Configuration.GetSection("Zammad"))
.AddStandardResilienceHandler();
This configuration will automatically handle transipent errors, making your application more robust.
Pull requests are welcome. Please use Conventional Commits to keep commit messages consistent.
Please consider adding tests for any new features or bug fixes.
- Zammad API Documentation
- The original Zammad.Client library by @S3bt3r
Distributed under the Apache License 2.0. See LICENSE
for more
information.