EasyPost-Official 3.1.0

.NET 5.0 .NET Core 3.1 .NET Standard 2.0
Install-Package EasyPost-Official -Version 3.1.0
dotnet add package EasyPost-Official --version 3.1.0
<PackageReference Include="EasyPost-Official" Version="3.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add EasyPost-Official --version 3.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: EasyPost-Official, 3.1.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install EasyPost-Official as a Cake Addin
#addin nuget:?package=EasyPost-Official&version=3.1.0

// Install EasyPost-Official as a Cake Tool
#tool nuget:?package=EasyPost-Official&version=3.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

EasyPost .Net Client Library

CI NuGet version

EasyPost, the simple shipping solution. You can sign up for an account at https://easypost.com.

Install

Install-Package EasyPost-Official

See NuGet docs for additional instructions on installing via the dialog or the console.

Usage

A simple create & buy shipment example:

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using EasyPost;
using Newtonsoft.Json;

namespace example
{
    class exampleClass
    {
        static async Task Main()
        {
            EasyPost.ClientManager.SetCurrent(Environment.GetEnvironmentVariable("EASYPOST_API_KEY"));

            Dictionary<string, object> fromAddress = new Dictionary<string, object>() {
                { "name", "Dr. Steve Brule" },
                { "street1", "417 Montgomery Street" },
                { "street2", "5th Floor" },
                { "city", "San Francisco" },
                { "state", "CA" },
                { "country", "US" },
                { "zip", "94104" },
                { "phone", "4153334444" }
            };

            Dictionary<string, object> toAddress = new Dictionary<string, object>() {
                { "company", "EasyPost" },
                { "street1", "417 Montgomery Street" },
                { "street2", "Floor 5" },
                { "city", "San Francisco" },
                { "state", "CA" },
                { "country", "US" },
                { "zip", "94104" },
                { "phone", "415-379-7678" }
            };

            Dictionary<string, object> parcel = new Dictionary<string, object>() {
                { "length", 8 },
                { "width", 6 },
                { "height", 5 },
                { "weight", 10 },
            }

            Shipment shipment = await Shipment.Create(new Dictionary<string, object>() {
                { "from_address", fromAddress },
                { "to_address", toAddress },
                { "parcel", parcel },
            });

            await shipment.Buy(shipment.LowestRate());

            Console.WriteLine(JsonConvert.SerializeObject(shipment, Formatting.Indented));
        }
    }
}

Configuration

Single API Key

If you are operating with a single EasyPost API key, during the initialization of your application add the following to configure EasyPost.

using EasyPost;

ClientManager.SetCurrent("ApiKey");

Multiple API Keys

If you are operating with multiple EasyPost API keys, or wish to delegate the construction of the client requests, configure the ClientManager with a delegate at application initialization.

using EasyPost;

ClientManager.SetCurrent(() => new Client(new ClientConfiguration("yourApiKeyHere")));

Warning about Threads

NOTE: The EasyPost .NET client library (in particular, the ClientManager global object) is not threadsafe; do not attempt to perform requests from multiple threads in parallel. This can be particularly problematic if using multiple API keys; make sure to always use a Mutex, Monitor, or other synchronization method to ensure that concurrent requests do not enter the EasyPost library from different threads.

Documentation

API Documentation can be found at: https://easypost.com/docs/api.

Upgrading major versions of this project? Refer to the Upgrade Guide.

Development

It is highly recommended to use a purpose-built IDE when working with this project such as Visual Studio. Most actions such as building, cleaning, and testing can be done via the GUI.

# Lint project
dotnet-format

# Run tests (recommended to instead run via an IDE like Visual Studio)
dotnet test

# Pull EasyVCR submodule
git submodule init
git submodule update --recursive

Testing

The test suite in this project was specifically built to produce consistent results on every run, regardless of when they run or who is running them. This project uses EasyVCR to record and replay HTTP requests and responses via "cassettes". When the suite is run, the HTTP requests and responses for each test function will be saved to a cassette if they do not exist already and replayed from this saved file if they do, which saves the need to make live API calls on every test run.

If you make an addition to this project, the request/response will get recorded automatically for you if a _vcr.SetUpTest("testName"); is included in the test function. When making changes to this project, you'll need to re-record the associated cassette to force a new live API call for that test which will then record the request/response used on the next run.

The test suite has been populated with various helpful fixtures that are available for use, each completely independent from a particular user with the exception of the USPS carrier account ID which has a fallback value to our internal testing user's ID. If you are a non-EasyPost employee and are re-recording cassettes, you may need to provide the USPS_CARRIER_ACCOUNT_ID environment variable with the ID associated with your USPS account (which will be associated with your API keys in use) for tests that use this fixture.

Note on dates: Some fixtures use hard-coded dates that may need to be incremented if cassettes get re-recorded (such as reports or pickups).

Test Coverage

Unit test coverage reports can be generated by running the generate_test_reports.sh Bash script from the root of this repository.

A report will be generated for each version of the library. Final reports will be stored in the coveragereport folder in the root of the repository following generation.

The script requires the following tools installed in your PATH:

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on EasyPost-Official:

Repository Stars
nopSolutions/nopCommerce
ASP.NET Core eCommerce software. nopCommerce is a free and open-source shopping cart.
Version Downloads Last updated
3.1.0 284 5/19/2022
3.0.0 2,553 4/15/2022
2.8.2 5,145 2/25/2022
2.8.1 448 2/17/2022
2.5.1.3 59,761 1/7/2020
2.5.1.2 16,807 9/29/2019
2.5.1.1 17,900 7/5/2019
2.5.1 17,041 10/9/2018
2.5.0.1 5,017 10/3/2018
2.5.0 4,827 9/28/2018
2.4.0 10,162 6/22/2018
2.3.1.4 15,403 1/9/2018
2.3.1.3 15,600 11/29/2017
2.3.1.2 13,651 5/16/2017
2.3.1.1 5,778 4/20/2017
2.3.1 5,613 3/28/2017
2.3.0 5,178 3/11/2017
2.2.7 5,147 3/7/2017
2.2.6 6,931 1/24/2017
2.2.5 5,230 1/24/2017
2.2.4 5,996 12/15/2016
2.2.3 5,897 12/13/2016
2.2.2 5,056 12/7/2016
2.2.1 7,909 8/26/2016
2.2.0 5,315 8/25/2016
2.1.2.1 5,394 8/19/2016
2.1.1 5,986 7/8/2016
2.1.0 6,546 5/9/2016
2.0.3.1 6,510 3/12/2016
2.0.3 5,297 3/3/2016
2.0.2.1 5,518 2/19/2016
2.0.2 5,666 2/10/2016
2.0.1.1 9,739 1/14/2016
2.0.1 6,193 1/14/2016
2.0.0 5,437 1/12/2016
1.2.2.2 6,713 12/18/2015
1.2.2.1 5,350 11/9/2015
1.2.2 5,193 11/4/2015
1.2.1 5,963 10/27/2015
1.2.0.1 5,214 10/6/2015
1.2.0 5,892 9/15/2015
1.1.7.2 5,102 9/10/2015
1.1.7.1 5,596 8/12/2015
1.1.7 6,657 6/26/2015
1.1.6 5,222 6/11/2015
1.1.5.2 5,206 6/5/2015
1.1.5.1 5,365 5/13/2015
1.1.4.5 5,355 3/20/2015
1.1.4.4 5,342 2/6/2015
1.1.4.3 5,129 2/6/2015
1.1.4.1 5,331 1/29/2015
1.1.4 5,344 1/29/2015
1.1.3.2 5,133 1/20/2015
1.1.3 5,568 12/17/2014
1.1.2.6 5,546 11/19/2014
1.1.2.5 5,379 11/17/2014
1.1.2.4 5,793 11/3/2014
1.1.2.3 5,485 11/3/2014
1.1.2.1 6,275 10/31/2014
1.1.2 8,065 10/31/2014
1.1.1.2 6,860 10/30/2014
1.1.0 5,226 10/7/2014
1.0.1.7 5,150 8/15/2014
1.0.1.6 5,141 7/11/2014
1.0.1.4 5,277 6/10/2014
1.0.1.3 5,058 6/6/2014