CL.Campaign.SDK
1.0.0
dotnet add package CL.Campaign.SDK --version 1.0.0
NuGet\Install-Package CL.Campaign.SDK -Version 1.0.0
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="CL.Campaign.SDK" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CL.Campaign.SDK" Version="1.0.0" />
<PackageReference Include="CL.Campaign.SDK" />
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 CL.Campaign.SDK --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: CL.Campaign.SDK, 1.0.0"
#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 CL.Campaign.SDK@1.0.0
#: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=CL.Campaign.SDK&version=1.0.0
#tool nuget:?package=CL.Campaign.SDK&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
CL.Campaign.SDK
Official .NET SDK for CL Campaign API. Provides easy integration for external systems to query cart promotions with built-in validation, preprocessing, and caching capabilities.
Features
- 🚀 Easy integration with CL Campaign API
- 🔒 Built-in authentication (JWT Token or API Key)
- ⚡ Automatic caching and performance optimization
- ✅ Input validation and preprocessing
- 🏢 Multi-tenant support
- 📦 Lightweight and dependency-free
Installation
dotnet add package CL.Campaign.SDK
Quick Start
// 1. Add SDK to your services
services.AddCampaignSdk(options =>
{
options.BaseUrl = "https://your-api-url.com";
options.TenantId = "your-tenant-id";
options.ApiKey = "your-api-key";
options.ApiSecret = "your-api-secret";
options.UseApiKeyAuth = true;
});
// 2. Inject and use the service
public class MyService
{
private readonly ICampaignService _campaignService;
private readonly IEngineService _engineService;
public MyService(ICampaignService campaignService, IEngineService engineService)
{
_campaignService = campaignService;
_engineService = engineService;
}
public async Task<PromotionResultModel> ApplyPromotions(CartModel cart)
{
var cartRequest = new CartRequest { Cart = cart };
var result = await _engineService.ExecuteCampaignsAsync(cartRequest);
return result.Data;
}
}
Configuration
Authentication Options
// JWT Token Authentication
options.JwtToken = "your-jwt-token";
// API Key Authentication
options.UseApiKeyAuth = true;
options.ApiKey = "your-api-key";
options.ApiSecret = "your-api-secret";
Caching Options
options.EnableResponseCaching = true;
options.CacheDurationSeconds = 300; // 5 minutes
API Reference
ICampaignService
GetCampaignsAsync()
- Get all campaignsGetCampaignAsync(id)
- Get specific campaignCreateCampaignAsync(campaign)
- Create new campaignUpdateCampaignAsync(id, campaign)
- Update campaignDeleteCampaignAsync(id)
- Delete campaignToggleCampaignStatusAsync(id)
- Toggle campaign status
IEngineService
ExecuteCampaignsAsync(cartRequest)
- Apply promotions to cartTestCampaignsAsync(cartRequest)
- Test promotions without applyingGetAvailableCampaignsAsync(customerId)
- Get available campaigns for customer
Examples
Basic Cart Promotion
var cart = new CartModel
{
Customer = new CustomerModel { Id = "customer-123" },
Lines = new List<CartLineModel>
{
new CartLineModel
{
ProductId = "product-1",
Quantity = 2,
UnitPrice = 100
}
}
};
var cartRequest = new CartRequest { Cart = cart };
var result = await _engineService.ExecuteCampaignsAsync(cartRequest);
if (result.Success)
{
Console.WriteLine($"Total Discount: {result.Data.TotalDiscount}");
Console.WriteLine($"Final Total: {result.Data.FinalTotal}");
}
Campaign Management
// Get all campaigns
var campaigns = await _campaignService.GetCampaignsAsync();
// Create new campaign
var newCampaign = new CampaignModel
{
Name = "Summer Sale",
Description = "20% off all summer items",
Status = true
};
var created = await _campaignService.CreateCampaignAsync(newCampaign);
License
MIT License - see LICENSE file for details.
Support
For support and questions:
- GitHub Issues: Create an issue
- Documentation: Wiki
- Email: support@commercelab.com
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Microsoft.Extensions.Caching.Memory (>= 9.0.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 9.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0)
- Microsoft.Extensions.Http (>= 9.0.0)
- Microsoft.Extensions.Options (>= 9.0.0)
- System.Text.Json (>= 8.0.5)
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.0 | 149 | 8/16/2025 |