EasyPost-Extensions 1.7.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package EasyPost-Extensions --version 1.7.1                
NuGet\Install-Package EasyPost-Extensions -Version 1.7.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="EasyPost-Extensions" Version="1.7.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add EasyPost-Extensions --version 1.7.1                
#r "nuget: EasyPost-Extensions, 1.7.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 EasyPost-Extensions as a Cake Addin
#addin nuget:?package=EasyPost-Extensions&version=1.7.1

// Install EasyPost-Extensions as a Cake Tool
#tool nuget:?package=EasyPost-Extensions&version=1.7.1                

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 or CarrierAccount 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() or myClient.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 with myBatch.BatchStateEnum()
  • Get the form type of a CustomsInfo object as an enum with myCustomsInfo.FormTypeEnum()
  • Get the non-delivery option of a CustomsInfo object as an enum with myCustomsInfo.NonDeliveryOptionEnum()
  • Get the restriction type of a CustomsItem object as an enum with myCustomsItem.RestrictionTypeEnum()
  • Get the type of an Event object as an enum with myEvent.Type()
  • Get the type of a Form object as an enum with myForm.Type()

Custom Clients

The EasyPost Extensions library provides a set of custom clients to make working with the EasyPost API easier.

  • ProxyClient - An extension of EasyPostClient that uses a proxy server to make API requests
  • IntrospectiveClient - An extension of EasyPostClient that supports pre- and post-request hooks
  • MockClient - An extension of EasyPostClient 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 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. 
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.7.2 0 11/5/2024
1.7.1 74 10/11/2024
1.7.0 99 10/10/2024
1.6.1 81 10/9/2024
1.6.0 78 10/9/2024
1.5.0 121 6/6/2024
1.4.0 248 11/6/2023
1.3.0 142 8/30/2023
1.2.0 180 7/6/2023
1.1.0 141 6/7/2023
1.0.0 158 5/16/2023
0.6.0 300 1/29/2023
0.5.0 285 1/22/2023
0.4.0 285 1/18/2023
0.3.0 283 1/14/2023
0.2.0 310 12/19/2022
0.1.0 327 10/19/2022