Spresso.Sdk.PriceOptimizations 1.1.1

dotnet add package Spresso.Sdk.PriceOptimizations --version 1.1.1                
NuGet\Install-Package Spresso.Sdk.PriceOptimizations -Version 1.1.1                
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="Spresso.Sdk.PriceOptimizations" Version="1.1.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Spresso.Sdk.PriceOptimizations --version 1.1.1                
#r "nuget: Spresso.Sdk.PriceOptimizations, 1.1.1"                
#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.
// Install Spresso.Sdk.PriceOptimizations as a Cake Addin
#addin nuget:?package=Spresso.Sdk.PriceOptimizations&version=1.1.1

// Install Spresso.Sdk.PriceOptimizations as a Cake Tool
#tool nuget:?package=Spresso.Sdk.PriceOptimizations&version=1.1.1                

Spresso.Sdk

This repository contains all of the .net SDKs for calling the Spresso API.

Package Link
Core SDK Nuget (with prereleases)
Price Optimizations Nuget (with prereleases)

Spresso.Sdk.Core

Core SDKs that deal with

  • Authentication
  • Resilient API calls

Note that for best performance, AuthTokenHandler should should be a singleton and live for the lifetime of the application.

Spresso.Sdk.PriceOptimizations

SDK that works with the Spresso Price Optimization APIs to fetch optimal prices for a given set of products.

Note that for best performance, PriceOptimizationsHandler should should be a singleton and live for the lifetime of the application.

By default this SDK tries it's best to always return an answer in a fixed amount of time, using default pricing. The IsSuccess will let you know if the response came from the API or was the fallback price. The Error property will inform you of what went wrong.

Fallback behavior can be disabled by setting PriceOptimizationsHandlerOptions.ThrowOnFailure to true.

This SDK will handle tokens for you and will return the default price if a bot is detected.

Quickstart

var authTokenHandler = new AuthTokenHandler("myClientId", "mySecret");
var priceOptimizationHandler = new PriceOptimizationsHandler(authTokenHandler);

// get a single price optimization
var response = await priceOptimizationHandler.GetPriceAsync(new GetPriceRequest(deviceId: "device123", sku: "sku42", defaultPrice: 9.99m, userId: "9635345345534ad3", overrideToDefaultPrice: false, userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36"));

// get price optimizaitons in a batch
var batchResponse2 = priceOptimizationHandler.GetPricesAsync(
    new GetPricesRequest(new[]
    {
        new GetPriceRequest(deviceId: "123", sku: "abc", defaultPrice: 19.99m, userId: "u42",
            overrideToDefaultPrice: false),
        new GetPriceRequest(deviceId: "456", sku: "xyz", defaultPrice: 11.99m, userId: "u42",
            overrideToDefaultPrice: false)
    }, userAgent: "google-bot"));

Or

var priceOptimizationHandler = new PriceOptimizationsHandler("myClientId", "mySecret");

var response = await priceOptimizationHandler.GetPriceAsync(new GetPriceRequest(deviceId: "device123", sku: "sku42", defaultPrice: 9.99m, userId: "9635345345534ad3", overrideToDefaultPrice: false);

Mock Server

This repository included a Mock Server that can be used for testing different SDKs (in any language), for testing integrations, and for testing error scenarios.

To Run:

cd ./tests/Spresso.MockApi && dotnet run

Forced Error Conditions:

To test different response codes, add the following query parameters to the web request:

status=<status code> - will return the specified status code

example: https://localhost:7176/pim/v1/prices?status=500

To test different response times, add the following query parameters to the web request:

delay=<delay in seconds> - will delay the response by the specified amount of time

example: https://localhost:7176/pim/v1/prices?delay=5

Note: if testing via the SDK, you can use the AdditionalParameters property to add these query parameters to the request.

Building

This solution is setup to use the nuke build system (still a work in progress).

Assuming you have nuke installed, you can run the following commands:

To build the solution, run nuke from the root of the repository.

To target a specific SDK, run nuke --target-project <your sdk of choice>

To build and run tests, run nuke test or nuke test --target-project <your sdk>

To get a list of sdks, run nuke listsdks

For help, run nuke --help

If you do not have nuke installed, you can also substitute nuke with build.cmd, build.ps1, or build.sh, depending on your platform.

Benchmarks

To run benchmarks, build tests/Spresso.Sdk.Benchmarks in Release mode, then run Spresso.Sdk.Benchmarks.

Historical Benchmarks

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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen 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.

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.1.1 153 10/5/2023
1.1.1-beta 138 2/16/2023
1.1.0-beta 128 2/15/2023

Initial release