shippingapi 1.1.3
See the version list below for details.
dotnet add package shippingapi --version 1.1.3
NuGet\Install-Package shippingapi -Version 1.1.3
<PackageReference Include="shippingapi" Version="1.1.3" />
paket add shippingapi --version 1.1.3
#r "nuget: shippingapi, 1.1.3"
// Install shippingapi as a Cake Addin #addin nuget:?package=shippingapi&version=1.1.3 // Install shippingapi as a Cake Tool #tool nuget:?package=shippingapi&version=1.1.3
Pitney Bowes Shipping API C# Client
This project has the code for a NuGet package that provides a fluent C# interface to the Pitney Bowes Shipping API. The package uses the .NET Standard 2.0 framework, meaning it is compatible with:
- .NET core 2.0
- .NET framework 4.6.1 and above
Mono and Xamarin are also supported.
Features:
- full wrapping of the API. Hides (encapsulates) all protocol details, including authentication and report pagination..
- strong typing – objects for all entities. Enums for all options – which really helps in visual studio intellisense.
- Contract via interfaces as well as DTOs to reduce the need to copy data
- Linq provider for reports
- Fluent interface - less typing and really good way to extend with extension methods
- Support for the metadata provided by the carrier rules method. Use this for local validation/UI options/rate shop.
- Mocking and recording of live messages to disk for capture or later playback in mock mode. Mocking for unit and regression testing.
- Example console app.
- Plug in your own configuration and log providers
- Keeps the API secret out of cleartext
Latest changes - CHANGES
Prerequisites
To use the C# client to generate shipping labels, you will need a Pitney Bowes Shipping API sandbox account. The account is free and gives access to a fully functional sandbox environment. Sign up for the account here: Shipping API Signup.
You will need the following information from your Shipping API account. To get the information, see Getting Started.
- Your API key
- API secret
- Developer ID
- Shipper ID
VSCode or Visual Studio. The Community Edition of Visual Studio is fine.
dotnet core 2.0 or later
git command line (required if building the system out-of-box)
Getting Started
You can get started by doing either of the following:
Using the NuGet Package
If you just want to use the solution without building it, download it from on nuget.org.
If you are developing on Windows, I'd recommend that you install Telerik Fiddler, which will let you see the messages with the Pitney Bowes servers.
Build an example app:
$ mkdir myshippingprojdir $ cd myshippingprojdir $ dotnet new console $ dotnet add package ShippingAPI
In Visual Studio create a new console app, and then in the package manager console
PM> install-package ShippingAPI
Replace your Program.cs file with one of the following from the provided examples:
The MyShip.cs sample file. This builds an app that generates a label. The remainder of these steps explain how to configure this app.
The Program.cs sample file. This builds an app that that integrates your logging and configuration systems. This also uses all the API's methods. If you use this file, plug in your logging and configuration information appropriately and skip the rest of these steps.
Add your own IDs. IDs are case-sensitive. Do one of the following:
- Replace the values in the code below:
sandbox.AddConfigItem("ApiKey", "your api key"); sandbox.AddConfigItem("ApiSecret", "your api secret"); sandbox.AddConfigItem("ShipperID", "your shipper id"); sandbox.AddConfigItem("DeveloperID", "your developer id");
- Or create a shippingapisettings.json file in
%APPDATA%
on Windows, or ~ on OSX and Linux:{ "ApiKey": "!###", "ApiSecret": "###", "ShipperID": "1234567890", "DeveloperID": "1234567890" }
- Replace the values in the code below:
To create a shipping label:
var shipment = ShipmentFluent<Shipment>.Create() .ToAddress((Address)AddressFluent<Address>.Create() .AddressLines("643 Greenway Rd") .PostalCode("28607") .CountryCode("US") .Verify()) .FromAddress((Address)AddressFluent<Address>.Create() .Company("Pitney Bowes Inc") .AddressLines("27 Waterview Drive") .CityTown("Shelton").StateProvince("CT").PostalCode("06484") .CountryCode("US") ) .Parcel((Parcel)ParcelFluent<Parcel>.Create() .Dimension(12, 12, 10) .Weight(16m, UnitOfWeight.OZ)) .Rates(RatesArrayFluent<Rates>.Create() .USPSPriority<Rates, Parameter>()) .Documents((List<IDocument>)DocumentsArrayFluent<Document>.Create() .ShippingLabel(ContentType.URL, Size.DOC_4X6, FileFormat.PDF)) .ShipmentOptions(ShipmentOptionsArrayFluent<ShipmentOptions>.Create() .ShipperId("your shipper id") // ******* dont forget this one too ******* ) .TransactionId(Guid.NewGuid().ToString().Substring(15)); var label = Api.CreateShipment((Shipment)shipment).GetAwaiter().GetResult(); if (label.Success) { var sw = new StreamWriter("label.pdf"); foreach (var d in label.APIResponse.Documents) { Api.WriteToStream(d, sw.BaseStream).GetAwaiter().GetResult(); } }
Support
If you encounter problems, please contact Support at ShippingAPISupport@pb.com.
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
- Newtonsoft.Json (>= 10.0.3)
- System.Linq.Queryable (>= 4.3.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.6.0 | 849 | 4/26/2021 |
1.5.1 | 895 | 9/29/2020 |
1.5.0 | 497 | 9/25/2020 |
1.4.0 | 790 | 9/24/2020 |
1.3.3 | 571 | 8/21/2020 |
1.3.2 | 510 | 8/16/2020 |
1.3.1 | 492 | 8/12/2020 |
1.3.0 | 857 | 6/26/2020 |
1.2.2 | 528 | 6/19/2020 |
1.2.1 | 649 | 5/29/2020 |
1.2.0 | 565 | 4/27/2020 |
1.1.5 | 813 | 2/13/2020 |
1.1.4 | 742 | 11/11/2019 |
1.1.3 | 538 | 11/5/2019 |
1.1.2 | 522 | 11/4/2019 |
1.1.1 | 537 | 11/4/2019 |
1.1.0 | 948 | 3/5/2019 |
1.1.0-prerelease | 686 | 2/4/2019 |
1.0.12 | 1,200 | 7/3/2018 |
1.0.11 | 1,044 | 3/8/2018 |
1.0.10 | 964 | 3/6/2018 |
1.0.9 | 1,023 | 3/6/2018 |
1.0.8 | 1,004 | 3/6/2018 |
1.0.7 | 1,260 | 1/3/2018 |
1.0.6-beta | 988 | 12/28/2017 |
1.0.5-beta | 863 | 12/28/2017 |