OloLabs.Promotions.SDK 3.0.3

Prefix Reserved
dotnet add package OloLabs.Promotions.SDK --version 3.0.3
                    
NuGet\Install-Package OloLabs.Promotions.SDK -Version 3.0.3
                    
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="OloLabs.Promotions.SDK" Version="3.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="OloLabs.Promotions.SDK" Version="3.0.3" />
                    
Directory.Packages.props
<PackageReference Include="OloLabs.Promotions.SDK" />
                    
Project file
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 OloLabs.Promotions.SDK --version 3.0.3
                    
#r "nuget: OloLabs.Promotions.SDK, 3.0.3"
                    
#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 OloLabs.Promotions.SDK@3.0.3
                    
#: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=OloLabs.Promotions.SDK&version=3.0.3
                    
Install as a Cake Addin
#tool nuget:?package=OloLabs.Promotions.SDK&version=3.0.3
                    
Install as a Cake Tool

OloLabs.Promotions.SDK

OloLabs.Promotions.SDK is a NuGet package that provides models and tools for integrating with the Olo Promotions Specification.

View the Promotions Spec at https://developer.olo.com/docs.

Use of the SDK is subject to the terms of the Olo Promotions SDK License.

Table of Contents

Getting Started

Install from NuGet.org

This SDK is available on NuGet.org: OloLabs.Promotions.SDK

This can be installed via the NuGet command line:

  • nuget install OloLabs.Promotions.SDK

Or added to an existing project using the dotnet CLI:

  • dotnet add package OloLabs.Promotions.SDK

Or added via Visual Studio's NuGet Package Manager:

Install from .nupkg file

  1. Download the latest release of our NuGet package GitHub or NuGet.org.
  2. Create a local feed for NuGet.
  3. Add the OloLabs.Promotions.SDK package to the local feed.
  4. Install the package to your application.
    • nuget install OloLabs.Promotions.SDK

Structure

The SDK includes three primary directories/namespaces:

├───OloLabs.Promotions.SDK
│   ├───Authentication
│   ├───Requests
│   └───Responses

These areas include:

  • Authentication helpers
  • Models for Requests
  • Models for Responses

How to Use

Authentication

bool ValidateSignature(string signatureFromRequest)
{
    // Build the RequestAuthenticator.
    var requestAuthenticator = new RequestAuthenticator();

    // Generate a signature using the URL and body from the incoming request, along with the shared secret between you and Olo.
    var expectedSignature = requestAuthenticator.CreateSignature(
        url: "https://your-promotions-api.local/promotions/validate",
        body: "{the-request-body}",
        secret: "YOUR_SECRET");

    // Compare the request's signature (provided in the header X-Promo-Signature) with your generated signature.
    // If they match, then the signature is valid and the request is successfully authenticated.
    // If they don't match, then the signature is invalid and the request fails authentication.
    return signatureFromRequest == expectedSignature;
}

You can register the RequestAuthenticator for dependency injection using the IRequestAuthenticator interface.

builder.Services.AddSingleton<IRequestAuthenticator, RequestAuthenticator>();

Then you can inject it in your controllers/services/etc.

public class PromotionsRequestAuthenticatorMiddleware
{
    private readonly IRequestAuthenticator _requestAuthenticator;

    public PromotionsRequestAuthenticatorMiddleware(IRequestAuthenticator requestAuthenticator)
    {
        _requestAuthenticator = requestAuthenticator;
    }

    bool ValidateSignature(string signatureFromRequest)
    {
        var expectedSignature = _requestAuthenticator.CreateSignature(...);

        ...
    }
}

Requests

The following request models are provided:

  • AccruePointsRequest
  • CreateAccountRequest
  • RedeemPromotionsRequest
  • ValidatePromotionsRequest
  • VoidAccrualRequest
  • VoidRedemptionRequest

You can use the relevant models in your API configuration to accept incoming Promotions requests that specify a request body.

public class ValidatePromotionsController
{
    [HttpPost]
    public IActionResult ValidatePromotions([FromBody] ValidatePromotionsRequest request)
    {
        Console.WriteLine(JsonSerializer.Serialize(request));
    }
}

// Output:
// {
//    "orderId": null,
//    "accountId": "391528477",
//    "source": "Web",
//    "handoff": "delivery",
//    "currency": "USD",
//    "placed": "2023-02-01T18:00:00.000Z",
//    "wanted": "2023-02-01T19:30:00.000Z",
//    ...
// }

No request models are provided for the endpoints "Find Accounts" and "Get Account" since they only accept query and path parameters via the URL and do not accept request bodies.

To accept these parameters, specify them in your API route configuration.

[Route("/promotions/accounts/{accountId}")]
public class GetAccountController
{
    ...
}

Responses

Successful Responses

The following response models are provided:

  • AccruePointsResponse
  • CreateAccountResponse
  • FindAccountsResponse
  • GetAccountResponse
  • RedeemPromotionsResponse
  • ValidatePromotionsResponse
  • VoidAccrualResponse
  • VoidRedemptionResponse

You can use the relevant models to return successful responses from your API.

public class VoidAccrualController
{
    [HttpDelete]
    public IActionResult VoidAccrual(...)
    {
        ...

        return Ok(new VoidAccrualResponse
        {
            Transaction = new Transaction
            {
                ...
            }
        });
    }
}
Error Responses

Two error response models are provided:

  • ErrorCodeResponse
    • For 400 Bad Request error responses that require a code.
    • Use ErrorCode to specify the value for code
      • ErrorCode.InvalidAccount → INVALID_ACCOUNT
      • ErrorCode.InvalidPromotion → INVALID_PROMOTION
      • etc.
  • ErrorResponse
    • For all other error responses.

Example for ErrorCodeResponse:

public class VoidAccrualController
{
    [HttpDelete]
    [Route("/promotions/accruals/{accrualId}")]
    public IActionResult VoidAccrual(string accrualId, [FromBody] VoidAccrualRequest request)
    {
        ...

        return BadRequest(new ErrorCodeResponse
        {
            Id = Guid.NewGuid().ToString(),
            Code = ErrorCode.InvalidAccount // "INVALID_ACCOUNT",
            Details = $"Account ID '{request.AccountId}' could not be found.",
            Message = "There was a problem with your loyalty account. Please try again later."
        });
    }
}

Example for ErrorResponse:

public class VoidAccrualController
{
    [HttpDelete]
    [Route("/promotions/accruals/{accrualId}")]
    public IActionResult VoidAccrual(string accrualId, [FromBody] VoidAccrualRequest request)
    {
        ...

        return NotFound(new ErrorResponse
        {
            Id = Guid.NewGuid().ToString(),
            Details = $"Transaction ID {accrualId} could not be found.",
            Message = "There was a problem voiding the loyalty transaction. Please try again later."
        });
    }
}
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

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
3.0.3 244 9/4/2025
3.0.2 288 8/7/2025
3.0.1 295 8/6/2025
3.0.0 301 8/5/2025