C# / .NET SDK
Installation
Section titled “Installation”dotnet add package TracktileInstall-Package Tracktile<PackageReference Include="Tracktile" Version="0.3.0" />Quick Start
Section titled “Quick Start”using Tracktile;
var client = new TracktileClient(jwt: "your-api-token");
var products = await client.Products.ListAsync();Authentication
Section titled “Authentication”var client = new TracktileClient(jwt: "your-api-token");Available Resources
Section titled “Available Resources”| Resource | Methods |
|---|---|
client.Inventory | ReceiveAsync, MoveAsync, UpdateAsync, WasteAsync, AssignAsync, UnassignAsync, BundleAsync, MergeAsync, UnmergeAsync |
client.Orders | ListAsync, CreateAsync, GetAsync, UpdateAsync, DeleteAsync, GetProductAttributesAsync |
client.Products | ListAsync, CreateAsync, GetAsync, UpdateAsync, DeleteAsync, BatchUpdateAsync, FetchByIdsAsync |
client.PurchaseOrders | ListAsync, CreateAsync, GetAsync, UpdateAsync, DeleteAsync |
client.Shipments | ListAsync, CreateAsync, GetAsync, UpdateAsync, PatchAsync, DeleteAsync, GetItemsAsync |
client.Suppliers | ListAsync, CreateAsync, GetAsync, UpdateAsync, DeleteAsync, GetDefaultOrderAsync |
client.Transports | ListAsync, CreateAsync, GetAsync, UpdateAsync, DeleteAsync |
Cancellation Support
Section titled “Cancellation Support”All async methods accept a CancellationToken:
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(10));
try{ var products = await client.Products.ListAsync(cancellationToken: cts.Token);}catch (OperationCanceledException){ // Handle timeout or cancellation}Error Handling
Section titled “Error Handling”using Tracktile.Models.Errors;
try{ var product = await client.Products.GetAsync(id: "invalid");}catch (BadRequestException ex){ // Handle 400 errors}catch (UnauthorizedException ex){ // Handle 401 errors}catch (ForbiddenException ex){ // Handle 403 errors}catch (NotFoundException ex){ // Handle 404 errors}catch (ServerException ex){ // Handle 500 errors}Retries
Section titled “Retries”var client = new TracktileClient( jwt: "your-api-token", retryConfig: new RetryConfig { Strategy = RetryStrategy.Backoff, Backoff = new BackoffStrategy { InitialInterval = 1, MaxInterval = 50, Exponent = 1.1, MaxElapsedTime = 100 }, RetryConnectionErrors = false });Dependency Injection
Section titled “Dependency Injection”Register the client with ASP.NET Core’s DI container:
// In Program.cs or Startup.csbuilder.Services.AddSingleton<ITracktileClient>(sp => new TracktileClient(jwt: builder.Configuration["Tracktile:ApiKey"]));
// In your service or controllerpublic class ProductService{ private readonly ITracktileClient _client;
public ProductService(ITracktileClient client) { _client = client; }
public async Task<IEnumerable<Product>> GetProductsAsync() { return await _client.Products.ListAsync(); }}Custom HTTP Client
Section titled “Custom HTTP Client”var httpClient = new HttpClient{ Timeout = TimeSpan.FromSeconds(30)};
var client = new TracktileClient( jwt: "your-api-token", httpClient: httpClient);Debug Logging
Section titled “Debug Logging”using Microsoft.Extensions.Logging;
var loggerFactory = LoggerFactory.Create(builder =>{ builder.AddConsole(); builder.SetMinimumLevel(LogLevel.Debug);});
var client = new TracktileClient( jwt: "your-api-token", logger: loggerFactory.CreateLogger<TracktileClient>());Runtime Support
Section titled “Runtime Support”| Runtime | Version |
|---|---|
| .NET | 6.0+ |
| .NET | 8.0+ (recommended) |
The SDK is fully async and follows .NET conventions for naming, error handling, and cancellation.