ordercloud-dotnet-catalyst
2.1.3
See the version list below for details.
dotnet add package ordercloud-dotnet-catalyst --version 2.1.3
NuGet\Install-Package ordercloud-dotnet-catalyst -Version 2.1.3
<PackageReference Include="ordercloud-dotnet-catalyst" Version="2.1.3" />
paket add ordercloud-dotnet-catalyst --version 2.1.3
#r "nuget: ordercloud-dotnet-catalyst, 2.1.3"
// Install ordercloud-dotnet-catalyst as a Cake Addin #addin nuget:?package=ordercloud-dotnet-catalyst&version=2.1.3 // Install ordercloud-dotnet-catalyst as a Cake Tool #tool nuget:?package=ordercloud-dotnet-catalyst&version=2.1.3
ordercloud-dotnet-catalyst
A foundational library for building OrderCloud middleware, plugins and extensions with .NET. A toolbox of helpers for authentication, performant bulk requests, error handling, jobs, project setup, ect.
See dotnet-catalyst-examples for a starter template of a middleware project that uses this library. Targeted guides are found there.
If you're building solutions for OrderCloud using .NET and find a particular task difficult or tedious, we welcome you to suggest a feature for inclusion in this library.
⚠️ Versions 1.x.x have known security holes. Please only use version 2.0.1 and later.
Features
3rd Party Integrations
Contributing Guide For Integrations → CONTRIBUTING.md
Name | Project Guide | Nuget Library | Contributed By | Interfaces |
---|---|---|---|---|
BlueSnap | README | OrderCloud.Integrations.Payment.BlueSnap | OrderCloud Team | ICreditCardProcessor, ICreditCardSaver |
CardConnect | README | Coming soon | OrderCloud Team | ICreditCardProcessor, ICreditCardSaver |
Stripe | README | Coming soon | OrderCloud Team | ICreditCardProcessor, ICreditCardSaver |
EasyPost | README | OrderCloud.Integrations.Shipping.EasyPost | OrderCloud Team | IShippingRatesCalculator |
Fedex | README | OrderCloud.Integrations.Shipping.Fedex | OrderCloud Team | IShippingRatesCalculator |
UPS | README | OrderCloud.Integrations.Shipping.UPS | OrderCloud Team | IShippingRatesCalculator |
Avalara | README | OrderCloud.Integrations.Tax.Avalara | OrderCloud Team | ITaxCalculator, ITaxCodeProvider |
Vertex | README | OrderCloud.Integrations.Tax.Vertex | OrderCloud Team | ITaxCalculator |
TaxJar | README | OrderCloud.Integrations.Tax.TaxJar | OrderCloud Team | ITaxCalculator, ITaxCodeProvider |
User Authentication
Use Ordercloud's authentication scheme in your own APIs.
[HttpGet("hello"), OrderCloudUserAuth(ApiRole.Shopper)]
public string SayHello() {
return $"Hello {UserContext.Username}"; // UserContext is a property on CatalystController
}
Webhook Authentication
Securely receive push notifications of events from the Ordercloud platform.
[HttpPost("webhook"), OrderCloudWebhookAuth]
public object HandleAddressSave([FromBody] WebhookPayloads.Addresses.Save<MyConfigData> payload) {
...
}
Listing All Pages
If OrderCloud's limit of 100 records per page is a pain point.
var orders = new OrderCloudClient(...).Orders.ListAllAsync();
Proxying Platform List Calls
Receive list requests to your API with user defined filters, search, paging, and sorting.
[HttpGet("orders"), OrderCloudUserAuth(ApiRole.Shopper)]
public async Task<ListPage<Order>> ListOrders(IListArgs args)
{
var user = await _oc.Me.GetAsync(UserContext.AccessToken); // get user details
args.Filters.Add(new ListFilter("FromCompanyID", user.MeUser.Buyer.ID)) // filter using the user's buyer organization ID
args.Filters.Add(new ListFilter("LineItemCount", ">5"))
// list orders from an admin endpoint
var orders = await _oc.Orders.ListAsync(OrderDirection.Incoming, null, null, null, null, args); // apply list args with an extension version of ListAsync()
return orders;
}
Caching
Use Redis or LazyCache. Or, define your own implementation of ISimpleCache.
private ISimpleCache _cache;
[HttpGet("thing")]
public Thing GetThing(string thingID) {
var key = $"thing-{thingID}";
var timeToLive = TimeSpan.FromMinutes(10);
var thing = await _cache.GetOrAddAsync(key, timeToLive, () database.GetThing(thingID));
return thing;
}
[HttpPut("thing")]
public Thing EditThing(string thingID) {
var key = $"thing-{thingID}";
await _cache.RemoveAsync(thingID);
return await database.EditThing(thingID);
}
Throttler
A perfomance helper for multiple async function calls.
var cars = new List<Car>();
var maxConcurency = 20;
var minPause = 100 // ms
var carOwners = await Throttler.RunAsync(cars, minPause, maxConcurency, car => apiClient.GetCarOwner(car.ID);
Error Handling
Handle API errors, including unexpected ones, with a standard JSON response structure. Define your own errors.
public class AgeLimit21Exception : CatalystBaseException
{
public AgeLimit21Exception() : base("AgeLimit21", 403, "You must be 21 years of age or older to buy this product.") { }
}
....
Require.That(user.xp.Age >= 21, new AgeLimit21Exception());
Model Validation
Take advantage of DataAnnotation attributes to specify validation requirements for your own custom models.
[Required(ErrorMessage = "This field is required, please try again.")]
public string RequiredField { get; set; }
Testing helpers
When writing integration tests that hit an endpoint marked with [OrderCloudUserAuth]
, you'll need to pass a properly formatted JWT token in the Authorization header, otherwise the call will fail. Fake tokens are a bit tedious to create, so OrderCloud.Catalyst
provides a helper:
var token = FakeOrderCloudToken.Create(
clientID: "my-client-id",
roles: new List<string> { "Shopper" },
expiresUTC: DateTime.UtcNow + TimeSpan.FromHours(1),
notValidBeforeUTC: DateTime.UtcNow - TimeSpan.FromHours(1)
);
httpClient.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer", token);
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 | 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. |
-
.NETStandard 2.0
- LazyCache (>= 2.1.3)
- Microsoft.AspNetCore.Authentication (>= 2.2.0)
- Microsoft.AspNetCore.Cors (>= 2.2.0)
- Microsoft.AspNetCore.Http (>= 2.2.2)
- Microsoft.AspNetCore.Mvc.Core (>= 2.2.5)
- Microsoft.AspNetCore.Mvc.ViewFeatures (>= 2.2.0)
- Microsoft.Azure.Functions.Extensions (>= 1.1.0)
- Microsoft.Extensions.Configuration.AzureAppConfiguration (>= 4.4.0)
- OrderCloud.SDK (>= 0.10.5)
- System.IdentityModel.Tokens.Jwt (>= 6.11.1)
NuGet packages (10)
Showing the top 5 NuGet packages that depend on ordercloud-dotnet-catalyst:
Package | Downloads |
---|---|
OrderCloud.Integrations.Payment.Stripe
Integrate the OrderCloud ecommerce platform with Stripe for payments. |
|
OrderCloud.Integrations.Tax.Avalara
Integrate the OrderCloud ecommerce platform with Avalara for tax calculation. |
|
OrderCloud.Integrations.Shipping.EasyPost
Integrate the OrderCloud ecommerce platform with EasyPost for Shipping. |
|
OrderCloud.Integrations.Shipping.Fedex
Integrate the OrderCloud ecommerce platform with Fedex for Shipping. |
|
OrderCloud.Integrations.Payment.CardConnect
Integrate the OrderCloud ecommerce platform with CardConnect for payments. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.5.0 | 266 | 10/8/2024 |
2.4.0 | 619 | 10/2/2024 |
2.3.4 | 3,716 | 4/5/2024 |
2.3.3 | 23,517 | 12/2/2022 |
2.3.2 | 898 | 12/2/2022 |
2.3.1 | 9,258 | 11/3/2022 |
2.3.0 | 3,117 | 10/31/2022 |
2.2.3 | 14,062 | 5/27/2022 |
2.1.3 | 2,148 | 5/17/2022 |
2.1.2 | 1,217 | 5/4/2022 |
2.0.2 | 1,891 | 4/20/2022 |
2.0.1 | 2,669 | 4/6/2022 |
1.6.0 | 1,868 | 2/16/2022 |
1.5.1 | 2,823 | 11/10/2021 |
1.5.0 | 4,677 | 10/28/2021 |
1.4.0 | 1,164 | 10/22/2021 |
1.3.3 | 1,076 | 9/13/2021 |
1.3.2 | 1,090 | 8/24/2021 |
1.3.1 | 968 | 8/9/2021 |
1.3.0 | 1,041 | 7/15/2021 |
1.2.0 | 814 | 5/10/2021 |
1.1.2 | 788 | 4/29/2021 |
1.1.1 | 1,801 | 4/14/2021 |
1.1.0 | 766 | 4/13/2021 |
1.0.6 | 2,314 | 4/8/2021 |
1.0.5 | 849 | 4/5/2021 |
1.0.4 | 781 | 3/26/2021 |
1.0.3 | 1,081 | 3/23/2021 |
1.0.2 | 1,019 | 3/4/2021 |
1.0.1 | 809 | 3/2/2021 |
1.0.0 | 817 | 2/11/2021 |