Linkit
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 LinkitDotNet
dotnet 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

ServiceMethodsDescription
client.SkusCreateAsync, GetByIdAsync, UpdateAsync, UpdateStockAsync, DeleteAsync, ListAsyncStock Keeping Units per branch
client.ProductsCreateAsync, GetByIdAsync, UpdateAsync, DeleteAsync, ListAsyncCentral product catalog
client.BranchesCreateAsync, GetByIdAsync, UpdateAsync, DeleteAsync, ListAsyncPhysical locations
client.CustomersCreateAsync, GetByIdAsync, UpdateAsync, DeleteAsync, ListAsync, CreateAddressAsync, CreateGroupAsyncCustomer profiles
client.OrdersGetByIdAsyncOrder retrieval
client.OffersCreateAsync, GetByIdAsync, UpdateAsync, UpdateStatusAsync, DeleteAsync, ListAsync, BulkUpsertAsyncPromotions & discounts
client.BrandsCreateAsync, GetByIdAsync, UpdateAsync, DeleteAsyncBrand management
client.CategoriesCreateAsync, GetByIdAsync, UpdateAsync, DeleteAsyncProduct categories
client.GenericsCreateAsync, GetByIdAsync, UpdateAsync, DeleteAsyncGeneric entities
client.HealthCheckAsync, PingAsyncSystem health monitoring
client.IntegrationsGetByIdAsync, ExecuteAsync, EnableAsync, DisableAsyncPlatform 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 error

ProductCreateBuilder

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

ExceptionStatusDescription
LinkitExceptionBase for all SDK errors
LinkitInitializationExceptionInvalid configuration
LinkitApiExceptionAnyAPI error responses
LinkitAuthenticationException401Invalid credentials
LinkitAuthorizationException403Insufficient permissions
LinkitNotFoundException404Resource not found
LinkitValidationException400Request validation failed
LinkitConflictException409State conflict
LinkitRateLimitException429Rate limit exceeded
LinkitServerException5xxServer-side error
LinkitSerializationExceptionJSON 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,
};