SpressoAI.Sdk.Core
1.0.0
See the version list below for details.
dotnet add package SpressoAI.Sdk.Core --version 1.0.0
NuGet\Install-Package SpressoAI.Sdk.Core -Version 1.0.0
<PackageReference Include="SpressoAI.Sdk.Core" Version="1.0.0" />
paket add SpressoAI.Sdk.Core --version 1.0.0
#r "nuget: SpressoAI.Sdk.Core, 1.0.0"
// Install SpressoAI.Sdk.Core as a Cake Addin #addin nuget:?package=SpressoAI.Sdk.Core&version=1.0.0 // Install SpressoAI.Sdk.Core as a Cake Tool #tool nuget:?package=SpressoAI.Sdk.Core&version=1.0.0
SpressoAI.Sdk
This repository contains all of the .net SDKs for calling the Spresso API.
Package | Link |
---|---|
Core SDK | |
Pricing SDK |
SpressoAI.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.
SpressoAI.Sdk.Pricing
SDK that works with the Spresso Price Optimization APIs to fetch optimal prices for a given set of products.
Note that for best performance, SpressoHandler
should should be a singleton and live for the lifetime of the application.
By default this SDK tries its best to always return an answer in a fixed amount of time. The IsSuccess
flag will let you know if the response succeeded. The Error
property will inform you of what went wrong.
Fallback behavior can be disabled by setting SpressoHandlerOptions.ThrowOnFailure
to true
.
This SDK will handle tokens for you and for any price optimization queries, will return the default price if a bot is detected.
Quickstart
var spressoHandler = new SpressoHandler("myClientId", "mySecret");
// get a single price optimization
var response = await spressoHandler.GetPriceAsync(
new GetPriceRequest(
deviceId: "Device-123",
itemId: "itemId42",
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 = spressoHandler.GetPricesAsync(
new GetPricesRequest(new[]
{
new GetPriceRequest(deviceId: "Device-123", itemId: "abc", defaultPrice: 19.99m, userId: "u42", overrideToDefaultPrice: false),
new GetPriceRequest(deviceId: "Device-123", itemId: "xyz", defaultPrice: 11.99m, userId: "u42", overrideToDefaultPrice: false)
}, userAgent: "google-bot"));
// update a catalog entry
var updateRequest = new CatalogUpdatesRequest(new []
{ new CatalogUpdateRequest("SKU-1", "my amazing product", 12.34m, 9.87m) }
);
var catalogUpdateResponse = await spressoHandler.UpdateCatalogAsync(updateRequest);
// verify a price
var verificationRequest = new PriceVerificationsRequest(new []
{ new PriceVerificationRequest("SKU-1", 1.23m, "Device-123") }
);
var verificationResponse = await spressoHandler.VerifyPricesAsync(verificationRequest);
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/SpressoAI.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/SpressoAI.Sdk.Benchmarks
in Release
mode, then run SpressoAI.Sdk.Benchmarks
.
Product | Versions 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. |
-
.NETStandard 2.1
- HttpClientFactoryLite (>= 0.4.0)
- Microsoft.Extensions.Caching.Abstractions (>= 7.0.0)
- Microsoft.Extensions.Caching.Memory (>= 7.0.0)
- Microsoft.Extensions.Http (>= 7.0.0)
- Newtonsoft.Json (>= 13.0.2)
- Polly (>= 7.2.3)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on SpressoAI.Sdk.Core:
Package | Downloads |
---|---|
SpressoAI.Sdk.Pricing
SDK that works with the Spresso Price Optimization APIs to fetch optimal prices for a given set of products. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Initial release