shippingapi 1.1.3

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

  1. Build an example app:

    $ mkdir myshippingprojdir
    $ cd myshippingprojdir
    $ dotnet new console
    $ dotnet add package ShippingAPI
    
  2. In Visual Studio create a new console app, and then in the package manager console

    PM> install-package ShippingAPI
    
  3. 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.

  4. 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" 
      }
      
  5. 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 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. 
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.6.0 627 4/26/2021
1.5.1 830 9/29/2020
1.5.0 474 9/25/2020
1.4.0 709 9/24/2020
1.3.3 546 8/21/2020
1.3.2 487 8/16/2020
1.3.1 465 8/12/2020
1.3.0 769 6/26/2020
1.2.2 506 6/19/2020
1.2.1 613 5/29/2020
1.2.0 529 4/27/2020
1.1.5 775 2/13/2020
1.1.4 714 11/11/2019
1.1.3 515 11/5/2019
1.1.2 497 11/4/2019
1.1.1 513 11/4/2019
1.1.0 921 3/5/2019
1.1.0-prerelease 658 2/4/2019
1.0.12 1,165 7/3/2018
1.0.11 1,031 3/8/2018
1.0.10 927 3/6/2018
1.0.9 989 3/6/2018
1.0.8 983 3/6/2018
1.0.7 1,230 1/3/2018
1.0.6-beta 965 12/28/2017
1.0.5-beta 842 12/28/2017