EasyPost-Extensions
1.7.2
dotnet add package EasyPost-Extensions --version 1.7.2
NuGet\Install-Package EasyPost-Extensions -Version 1.7.2
<PackageReference Include="EasyPost-Extensions" Version="1.7.2" />
paket add EasyPost-Extensions --version 1.7.2
#r "nuget: EasyPost-Extensions, 1.7.2"
// Install EasyPost-Extensions as a Cake Addin #addin nuget:?package=EasyPost-Extensions&version=1.7.2 // Install EasyPost-Extensions as a Cake Tool #tool nuget:?package=EasyPost-Extensions&version=1.7.2
EasyPost Extensions (.NET)
A collection of helper utilities for the EasyPost .NET Client.
This project is unaffiliated with EasyPost.
Installation
The easiest way to install the EasyPost Extensions is via NuGet:
Install-Package EasyPost-Extensions
Usage
The information below is only highlights of this package's capabilities. For full reference, see the docs: http://www.nateharr.is/easypost-extensions-dotnet/api/index.html
Parameter Sets
The EasyPost .NET library provides a set of first-party parameter sets for each API-calling function.
The EasyPost Extensions library provides additional sets for specific functions, including:
- Sets for various forms (label QR codes, RMA QR codes, return packing slips) that can be used in the
myClient.Shipment.GenerateForm()
function - Sets for creating FedEx and UPS carrier accounts
- Sets for updating a
User
,EndShipper
orCarrierAccount
using an existing object - A
Refund
set for simplifying the refunding of a referral customer
Service Extension Methods
The EasyPost Extensions library provides a set of extension methods for EasyPost services to make them easier to work with.
- Create FedEx or UPS accounts with
myClient.CarrierAccount.CreateFedEx()
ormyClient.CarrierAccount.CreateUps()
- Simplify refunding a referral customer with
myClient.ReferralCustomer.Refund()
- Return a shipment with
myClient.Shipment.Return()
- Toggle a webhook with
myClient.Webhook.Toggle()
Model Extension Methods
The EasyPost Extensions library provides a set of extension methods for EasyPost models to make them easier to work with.
- Get the state of a
Batch
object as an enum withmyBatch.BatchStateEnum()
- Get the form type of a
CustomsInfo
object as an enum withmyCustomsInfo.FormTypeEnum()
- Get the non-delivery option of a
CustomsInfo
object as an enum withmyCustomsInfo.NonDeliveryOptionEnum()
- Get the restriction type of a
CustomsItem
object as an enum withmyCustomsItem.RestrictionTypeEnum()
- Get the type of an
Event
object as an enum withmyEvent.Type()
- Get the type of a
Form
object as an enum withmyForm.Type()
Custom Clients
The EasyPost Extensions library provides a set of custom clients to make working with the EasyPost API easier.
ProxyClient
- An extension ofEasyPostClient
that uses a proxy server to make API requestsIntrospectiveClient
- An extension ofEasyPostClient
that supports pre- and post-request hooksMockClient
- An extension ofEasyPostClient
that allows you to mock API requests and responses
Client Manager
The EasyPost Extensions library provides a ClientManager
class to help manage the EasyPost API client.
The ClientManager
class wraps the EasyPost .NET library Client
class, storing both your test and production API keys
to make it easier to switch between the two modes.
// Create a new ClientManager instance
var clientManager = new EasyPost.Extensions.ClientManager("test_123", "prod_123");
// Access the EasyPost .NET library Client instance to use as normal
var address = await clientManager.Client.Address.Create(parameters);
// Switch between test and production modes
clientManager.EnableTestMode();
clientManager.EnableProductionMode();
// It is recommended to always access the Client instance via the Client property directly, rather than storing it as a variable.
// When switching between test and production modes, the Client is re-initialized. Storing the Client as a variable may cause it to not be updated when switching modes.
// Yes
var address = await clientManager.Client.Address.Create(parameters);
// No
var client = clientManager.Client;
var address = await client.Address.Create(parameters);
Webhook Handler
The EasyPost Extensions library provides an EasyPostWebhookController
class to help manage EasyPost webhooks.
The controller, paired with an EasyPostEventProcessor
, will automatically execute specific actions based on the type of event received.
End-users should implement their own controller that inherits from EasyPostWebhookController
and override the WebhookSecret
, EnableTestMode
and EventProcessor
properties.
[Route("api/incoming_easypost_webhook")]
public class MyWebhookController : EasyPostWebhookController
{
protected override string WebhookSecret => "my-webhook-secret";
protected override bool EnableTestMode => false;
protected override EasyPostEventProcessor EventProcessor => new()
{
OnBatchCreated = async (@event) =>
{
// Do something when a "batch.created" event is received
},
};
public MyWebhookController(ILogger<MyWebhookController>? logger) : base(logger)
{
}
}
Test Data Generators
The EasyPost Extensions library provides a set of helper functions to generate test data for you.
// Generate a random shipment
var shipment = EasyPost.Extensions.Testing.DummyData.Shipments.CreateShipment(myEasyPostClient);
This library allows you to generate the following test data:
- Address objects
- Batch objects
- Carrier strings
- CustomsInfo objects
- CustomsItem objects
- Insurance objects
- Parcel objects
- Pickup objects
- Rate objects
- SmartRate objects
- Shipment objects
- TaxIdentifier parameters
- Tracker objects
- Webhook objects
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 is compatible. 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 is compatible. 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 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 is compatible. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.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. |
-
.NETCoreApp 3.1
- EasyPost-Official (>= 6.5.0 && < 7.0.0)
- Microsoft.AspNetCore.Mvc (>= 2.2.0)
- N8.NetTools.Common (>= 0.6.2)
- N8.NetTools.Common.Attributes (>= 1.1.0)
- N8.NetTools.JSON (>= 0.1.0)
-
.NETStandard 2.0
- EasyPost-Official (>= 6.5.0 && < 7.0.0)
- Microsoft.AspNetCore.Mvc (>= 2.2.0)
- N8.NetTools.Common (>= 0.6.2)
- N8.NetTools.Common.Attributes (>= 1.1.0)
- N8.NetTools.JSON (>= 0.1.0)
-
.NETStandard 2.1
- EasyPost-Official (>= 6.5.0 && < 7.0.0)
- Microsoft.AspNetCore.Mvc (>= 2.2.0)
- N8.NetTools.Common (>= 0.6.2)
- N8.NetTools.Common.Attributes (>= 1.1.0)
- N8.NetTools.JSON (>= 0.1.0)
-
net5.0
- EasyPost-Official (>= 6.5.0 && < 7.0.0)
- Microsoft.AspNetCore.Mvc (>= 2.2.0)
- N8.NetTools.Common (>= 0.6.2)
- N8.NetTools.Common.Attributes (>= 1.1.0)
- N8.NetTools.JSON (>= 0.1.0)
-
net6.0
- EasyPost-Official (>= 6.5.0 && < 7.0.0)
- Microsoft.AspNetCore.Mvc (>= 2.2.0)
- N8.NetTools.Common (>= 0.6.2)
- N8.NetTools.Common.Attributes (>= 1.1.0)
- N8.NetTools.JSON (>= 0.1.0)
-
net7.0
- EasyPost-Official (>= 6.5.0 && < 7.0.0)
- Microsoft.AspNetCore.Mvc (>= 2.2.0)
- N8.NetTools.Common (>= 0.6.2)
- N8.NetTools.Common.Attributes (>= 1.1.0)
- N8.NetTools.JSON (>= 0.1.0)
-
net8.0
- EasyPost-Official (>= 6.5.0 && < 7.0.0)
- Microsoft.AspNetCore.Mvc (>= 2.2.0)
- N8.NetTools.Common (>= 0.6.2)
- N8.NetTools.Common.Attributes (>= 1.1.0)
- N8.NetTools.JSON (>= 0.1.0)
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.7.2 | 93 | 11/5/2024 |
1.7.1 | 92 | 10/11/2024 |
1.7.0 | 117 | 10/10/2024 |
1.6.1 | 94 | 10/9/2024 |
1.6.0 | 91 | 10/9/2024 |
1.5.0 | 128 | 6/6/2024 |
1.4.0 | 253 | 11/6/2023 |
1.3.0 | 149 | 8/30/2023 |
1.2.0 | 186 | 7/6/2023 |
1.1.0 | 148 | 6/7/2023 |
1.0.0 | 166 | 5/16/2023 |
0.6.0 | 305 | 1/29/2023 |
0.5.0 | 290 | 1/22/2023 |
0.4.0 | 290 | 1/18/2023 |
0.3.0 | 288 | 1/14/2023 |
0.2.0 | 315 | 12/19/2022 |
0.1.0 | 333 | 10/19/2022 |