EasyPost-Official
3.6.0
See the version list below for details.
dotnet add package EasyPost-Official --version 3.6.0
NuGet\Install-Package EasyPost-Official -Version 3.6.0
<PackageReference Include="EasyPost-Official" Version="3.6.0" />
paket add EasyPost-Official --version 3.6.0
#r "nuget: EasyPost-Official, 3.6.0"
// Install EasyPost-Official as a Cake Addin #addin nuget:?package=EasyPost-Official&version=3.6.0 // Install EasyPost-Official as a Cake Tool #tool nuget:?package=EasyPost-Official&version=3.6.0
EasyPost .Net Client Library
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.
# Build project
make build
# Lint project
make lint
# Format project
make format
# Run tests (recommended to instead run via an IDE like Visual Studio)
EASYPOST_TEST_API_KEY=123... EASYPOST_PROD_API_KEY=123... make test
# Generate coverage reports
EASYPOST_TEST_API_KEY=123... EASYPOST_PROD_API_KEY=123... make coverage
# Run security analysis
make scan
NuGet Dependencies
The NuGet package dependencies for this project are listed in the .csproj
files. This project
uses NuGet package locks
to keep specific versions of dependencies. The lock files will be used during NuGet restore
, if present.
If you need to update or alter NuGet dependencies, delete the package.lock.json
files first. They will be regenerated
during the next restore
.
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.
Sensitive Data: We've made every attempt to include scrubbers for sensitive data when recording cassettes so that PII or sensitive info does not persist in version control; however, please ensure when recording or re-recording cassettes that prior to committing your changes, no PII or sensitive information gets persisted by inspecting the cassette.
Making Changes: If you make an addition to this project, the request/response will get recorded automatically for
you if a _vcr.SetUpTest("testName");
is included on 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.
Test Data: 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 ( see Unit Test API Keys for more information) which has a fallback value of our internal testing user's ID. Some fixtures use hard-coded dates that may need to be incremented if cassettes get re-recorded (such as reports or pickups).
Unit Test API Keys
The following are required on every test run:
EASYPOST_TEST_API_KEY
EASYPOST_PROD_API_KEY
The following are required when you need to re-record cassettes for applicable tests (fallback values are used otherwise):
USPS_CARRIER_ACCOUNT_ID
(eg: one-call buying a shipment for non-EasyPost employees)REFERRAL_USER_PROD_API_KEY
(eg: adding a credit card to a referral user)
Some tests may require a user with a particular set of enabled features such as a Partner
user when creating referrals. We have attempted to call out these functions in their respective docstrings.
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:
dotnet
reportgenerator
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 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 is compatible. |
.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. |
-
.NETCoreApp 3.1
- Newtonsoft.Json (>= 13.0.1)
- RestSharp (>= 107.3.0)
-
.NETStandard 2.0
- Newtonsoft.Json (>= 13.0.1)
- RestSharp (>= 107.3.0)
-
net5.0
- Newtonsoft.Json (>= 13.0.1)
- RestSharp (>= 107.3.0)
-
net6.0
- Newtonsoft.Json (>= 13.0.1)
- RestSharp (>= 107.3.0)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on EasyPost-Official:
Package | Downloads |
---|---|
YeditepeSoft.Shipment
YeditepeSoft Shipment Library |
|
EasyPost-Extensions
Package Description |
|
Umbraco.Commerce.ShippingProviders.EasyPost
EasyPost shipping provider for Umbraco Commerce |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
6.9.0 | 0 | 11/22/2024 |
6.8.1 | 677 | 10/31/2024 |
6.8.0 | 438 | 10/22/2024 |
6.7.3 | 6,806 | 9/19/2024 |
6.7.2 | 4,782 | 8/16/2024 |
6.7.1 | 913 | 8/9/2024 |
6.7.0 | 3,770 | 7/24/2024 |
6.6.0 | 3,685 | 7/16/2024 |
6.5.2 | 5,772 | 6/12/2024 |
6.5.1 | 249 | 6/10/2024 |
6.5.0 | 1,102 | 6/5/2024 |
6.4.0 | 4,938 | 5/1/2024 |
6.3.1 | 6,470 | 4/12/2024 |
6.3.0 | 177 | 4/10/2024 |
6.2.1 | 2,688 | 3/18/2024 |
6.2.0 | 4,702 | 2/7/2024 |
6.1.0 | 5,541 | 1/8/2024 |
6.0.0 | 4,483 | 12/6/2023 |
5.8.0 | 4,791 | 10/11/2023 |
5.7.0 | 6,704 | 9/5/2023 |
5.6.0 | 664 | 8/31/2023 |
5.5.0 | 624 | 8/29/2023 |
5.4.1 | 2,794 | 8/17/2023 |
5.4.0 | 1,029 | 8/14/2023 |
5.3.0 | 1,144 | 7/28/2023 |
5.2.0 | 1,736 | 7/12/2023 |
5.1.0 | 9,220 | 6/6/2023 |
5.0.0 | 3,757 | 5/15/2023 |
4.6.2 | 2,901 | 5/15/2023 |
4.6.0 | 3,254 | 4/18/2023 |
4.5.0 | 1,875 | 3/22/2023 |
4.4.0 | 2,929 | 2/21/2023 |
4.3.0 | 1,945 | 1/18/2023 |
4.2.0 | 1,118 | 1/13/2023 |
4.1.0 | 4,738 | 12/7/2022 |
4.0.2 | 2,424 | 11/1/2022 |
4.0.1 | 5,762 | 10/24/2022 |
4.0.0 | 2,268 | 10/12/2022 |
3.6.1 | 3,976 | 9/22/2022 |
3.6.0 | 973 | 9/22/2022 |
3.5.0 | 2,921 | 8/25/2022 |
3.4.0 | 1,605 | 8/2/2022 |
3.3.0 | 2,979 | 7/18/2022 |
3.2.0 | 1,028 | 7/11/2022 |
3.1.0 | 11,745 | 5/19/2022 |
3.0.0 | 13,302 | 4/15/2022 |
2.8.3 | 10,067 | 7/1/2022 |
2.8.2 | 33,782 | 2/25/2022 |
2.8.1 | 4,500 | 2/17/2022 |
2.5.1.3 | 107,202 | 1/7/2020 |
2.5.1.2 | 21,294 | 9/29/2019 |
2.5.1.1 | 21,516 | 7/5/2019 |
2.5.1 | 27,333 | 10/9/2018 |
2.5.0.1 | 5,892 | 10/3/2018 |
2.5.0 | 5,706 | 9/28/2018 |
2.4.0 | 14,580 | 6/22/2018 |
2.3.1.4 | 18,447 | 1/9/2018 |
2.3.1.3 | 17,857 | 11/29/2017 |
2.3.1.2 | 29,629 | 5/16/2017 |
2.3.1.1 | 9,588 | 4/20/2017 |
2.3.1 | 6,703 | 3/28/2017 |
2.3.0 | 6,089 | 3/11/2017 |
2.2.7 | 6,131 | 3/7/2017 |
2.2.6 | 7,928 | 1/24/2017 |
2.2.5 | 6,215 | 1/24/2017 |
2.2.4 | 7,044 | 12/15/2016 |
2.2.3 | 6,913 | 12/13/2016 |
2.2.2 | 5,987 | 12/7/2016 |
2.2.1 | 11,666 | 8/26/2016 |
2.2.0 | 6,193 | 8/25/2016 |
2.1.2.1 | 6,376 | 8/19/2016 |
2.1.1 | 6,811 | 7/8/2016 |
2.1.0 | 7,832 | 5/9/2016 |
2.0.3.1 | 7,431 | 3/12/2016 |
2.0.3 | 6,174 | 3/3/2016 |
2.0.2.1 | 6,460 | 2/19/2016 |
2.0.2 | 6,597 | 2/10/2016 |
2.0.1.1 | 10,677 | 1/14/2016 |
2.0.1 | 7,183 | 1/14/2016 |
2.0.0 | 6,405 | 1/12/2016 |
1.2.2.2 | 7,692 | 12/18/2015 |
1.2.2.1 | 6,260 | 11/9/2015 |
1.2.2 | 6,056 | 11/4/2015 |
1.2.1 | 6,879 | 10/27/2015 |
1.2.0.1 | 6,118 | 10/6/2015 |
1.2.0 | 6,752 | 9/15/2015 |
1.1.7.2 | 5,972 | 9/10/2015 |
1.1.7.1 | 6,438 | 8/12/2015 |
1.1.7 | 7,535 | 6/26/2015 |
1.1.6 | 6,060 | 6/11/2015 |
1.1.5.2 | 6,057 | 6/5/2015 |
1.1.5.1 | 6,394 | 5/13/2015 |
1.1.4.5 | 6,223 | 3/20/2015 |
1.1.4.4 | 6,284 | 2/6/2015 |
1.1.4.3 | 6,035 | 2/6/2015 |
1.1.4.1 | 6,184 | 1/29/2015 |
1.1.4 | 6,190 | 1/29/2015 |
1.1.3.2 | 5,965 | 1/20/2015 |
1.1.3 | 6,453 | 12/17/2014 |
1.1.2.6 | 6,469 | 11/19/2014 |
1.1.2.5 | 6,274 | 11/17/2014 |
1.1.2.4 | 6,681 | 11/3/2014 |
1.1.2.3 | 6,413 | 11/3/2014 |
1.1.2.1 | 7,180 | 10/31/2014 |
1.1.2 | 8,940 | 10/31/2014 |
1.1.1.2 | 7,716 | 10/30/2014 |
1.1.0 | 8,590 | 10/7/2014 |
1.0.1.7 | 5,977 | 8/15/2014 |
1.0.1.6 | 5,977 | 7/11/2014 |
1.0.1.4 | 6,175 | 6/10/2014 |
1.0.1.3 | 5,940 | 6/6/2014 |