SDK Reference
C# / .NET SDK
Production-grade C# SDK for the Linkit API — .NET 9, System.Text.Json, async/await, fluent builders, NuGet package.
C# / .NET SDK
Package
sa.linkit.LinkitDotNet · .NET 9+ · System.Text.Json · Zero external dependencies
Installation
nuget install LinkitDotNetdotnet add package LinkitDotNet<PackageReference Include="LinkitDotNet" Version="0.1.0" />Quick Start
Initialize the Client
using LinkitDotNet;
var client = LinkitClient.QuickSetup("https://linkit.works/api/v1", "your-jwt-token");Create a Product
var product = await client.Products.CreateAsync(new ProductRequest
{
IvId = "PROD-001",
NameEn = "Premium Widget",
NameAr = "ودجت فاخر",
AveragePrice = 149.99,
IsEnabled = true,
});Manage SKU Inventory
var sku = new SkuCreateBuilder()
.WithIvId("SKU-W001-RYD")
.InBranch("BR-RIYADH-001")
.ForProduct("PROD-001")
.WithBarcode("5901234123457")
.WithPrice(149.99)
.WithQty(500)
.WithAvailable(true)
.Build();
var created = await client.Skus.CreateAsync(sku);
Console.WriteLine($"Created SKU: {created.IvId}");Clean Up
client.Dispose();Configuration
var client = LinkitClient.Create(new LinkitConfiguration
{
BaseUrl = "https://linkit.works/api/v1",
JwtToken = "your-jwt-token",
TimeoutMs = 30_000,
MaxRetries = 3,
RetryBaseDelayMs = 1_000,
RetryMaxDelayMs = 30_000,
CircuitBreakerThreshold = 5,
CircuitBreakerRecoveryMs = 60_000,
MaxConcurrentRequests = 10,
});Services Reference
| Service | Methods | Description |
|---|---|---|
client.Skus | CreateAsync, GetByIdAsync, UpdateAsync, UpdateStockAsync, DeleteAsync, ListAsync | Stock Keeping Units per branch |
client.Products | CreateAsync, GetByIdAsync, UpdateAsync, DeleteAsync, ListAsync | Central product catalog |
client.Branches | CreateAsync, GetByIdAsync, UpdateAsync, DeleteAsync, ListAsync | Physical locations |
client.Customers | CreateAsync, GetByIdAsync, UpdateAsync, DeleteAsync, ListAsync, CreateAddressAsync, CreateGroupAsync | Customer profiles |
client.Orders | GetByIdAsync | Order retrieval |
client.Offers | CreateAsync, GetByIdAsync, UpdateAsync, UpdateStatusAsync, DeleteAsync, ListAsync, BulkUpsertAsync | Promotions & discounts |
client.Brands | CreateAsync, GetByIdAsync, UpdateAsync, DeleteAsync | Brand management |
client.Categories | CreateAsync, GetByIdAsync, UpdateAsync, DeleteAsync | Product categories |
client.Generics | CreateAsync, GetByIdAsync, UpdateAsync, DeleteAsync | Generic entities |
client.Health | CheckAsync, PingAsync | System health monitoring |
client.Integrations | GetByIdAsync, ExecuteAsync, EnableAsync, DisableAsync | Platform connections |
Fluent Builders
SkuCreateBuilder
var request = new SkuCreateBuilder()
.WithIvId("SKU-001")
.InBranch("BR-RYD")
.ForProduct("PROD-001")
.WithPrice(29.99)
.WithQty(500)
.WithAvailable(true)
.WithBarcode("5901234123457")
.WithAmazonSku("AMZ-W001")
.Build(); // ← Validates and throws LinkitValidationException on errorProductCreateBuilder
var request = new ProductCreateBuilder()
.WithIvId("PROD-001")
.WithNameEn("Premium Widget")
.WithNameAr("ودجت فاخر")
.WithAveragePrice(149.99)
.WithEnabled(true)
.Build();BranchCreateBuilder
var request = new BranchCreateBuilder()
.WithIvId("BR-RYD")
.WithNameEn("Riyadh Main Store")
.WithNameAr("متجر الرياض الرئيسي")
.WithLocation(24.7136, 46.6753)
.WithStatus(BranchStatus.Published)
.WithEmail("riyadh@linkit.sa")
.Build();Error Handling
try
{
var sku = await client.Skus.GetByIdAsync("nonexistent");
}
catch (LinkitNotFoundException ex)
{
Console.WriteLine($"Not found: {ex.ResourceType}");
}
catch (LinkitRateLimitException ex)
{
Console.WriteLine($"Rate limited — retry after {ex.RetryAfterMs}ms");
}
catch (LinkitValidationException ex)
{
foreach (var error in ex.ValidationErrors)
Console.WriteLine($" {error.Field}: {error.Message}");
}
catch (LinkitApiException ex)
{
Console.WriteLine($"API error {ex.StatusCode}: {ex.UserFriendlyMessage}");
}Exception Hierarchy
| Exception | Status | Description |
|---|---|---|
LinkitException | — | Base for all SDK errors |
LinkitInitializationException | — | Invalid configuration |
LinkitApiException | Any | API error responses |
LinkitAuthenticationException | 401 | Invalid credentials |
LinkitAuthorizationException | 403 | Insufficient permissions |
LinkitNotFoundException | 404 | Resource not found |
LinkitValidationException | 400 | Request validation failed |
LinkitConflictException | 409 | State conflict |
LinkitRateLimitException | 429 | Rate limit exceeded |
LinkitServerException | 5xx | Server-side error |
LinkitSerializationException | — | JSON parse failure |
Resilience
Zero Configuration Required
The resilience pipeline is active by default. Transient errors (5xx, 429, timeouts) are automatically retried with exponential backoff + jitter. The circuit breaker trips after 5 consecutive failures and recovers after 60 seconds.
Override defaults via LinkitConfiguration:
var config = new LinkitConfiguration
{
MaxRetries = 5,
RetryBaseDelayMs = 2_000,
CircuitBreakerThreshold = 10,
MaxConcurrentRequests = 20,
};