Skip to content

Latest commit

 

History

History
165 lines (121 loc) · 14.5 KB

README.md

File metadata and controls

165 lines (121 loc) · 14.5 KB

Parcels

(Parcels)

Overview

A parcel is an item you are shipping. The parcel object includes details about its physical make-up of the parcel. It includes dimensions and weight that Shippo uses to calculate rates.

Parcel Extras

The following values are supported for the extra field of the parcel object.

Available Operations

  • List - List all parcels
  • Create - Create a new parcel
  • Get - Retrieve an existing parcel

List

Returns a list of all parcel objects.

Example Usage

using Shippo;
using Shippo.Models.Requests;
using Shippo.Models.Components;

var sdk = new ShippoSDK(
    apiKeyHeader: "<YOUR_API_KEY_HERE>",
    shippoApiVersion: "2018-02-08"
);

var res = await sdk.Parcels.ListAsync(
    page: 1,
    results: 25,
    shippoApiVersion: "2018-02-08"
);

// handle response

Parameters

Parameter Type Required Description Example
Page long The page number you want to select
Results long The number of results to return per page (max 100)
ShippoApiVersion string Optional string used to pick a non-default API version to use. See our API version guide. 2018-02-08

Response

ParcelPaginatedList

Errors

Error Type Status Code Content Type
Shippo.Models.Errors.SDKException 4XX, 5XX */*

Create

Creates a new parcel object.

Example Usage

using Shippo;
using Shippo.Models.Requests;
using Shippo.Models.Components;

var sdk = new ShippoSDK(
    apiKeyHeader: "<YOUR_API_KEY_HERE>",
    shippoApiVersion: "2018-02-08"
);

var res = await sdk.Parcels.CreateAsync(
    requestBody: CreateParcelRequestBody.CreateParcelCreateRequest(
        new ParcelCreateRequest() {
            Extra = new ParcelExtra() {
                Cod = new Cod() {
                    Amount = "5.5",
                    Currency = "USD",
                    PaymentMethod = Shippo.Models.Components.PaymentMethod.Cash,
                },
                Insurance = new ParcelInsurance() {
                    Amount = "5.5",
                    Content = "Laptop",
                    Currency = "USD",
                    Provider = Shippo.Models.Components.ParcelInsuranceProvider.Ups,
                },
            },
            Metadata = "Customer ID 123456",
            MassUnit = Shippo.Models.Components.WeightUnitEnum.Lb,
            Weight = "1",
            DistanceUnit = Shippo.Models.Components.DistanceUnitEnum.In,
            Height = "1",
            Length = "1",
            Width = "1",
        }
    ),
    shippoApiVersion: "2018-02-08"
);

// handle response

Parameters

Parameter Type Required Description Example
RequestBody CreateParcelRequestBody ✔️ Parcel details.
ShippoApiVersion string Optional string used to pick a non-default API version to use. See our API version guide. 2018-02-08

Response

Parcel

Errors

Error Type Status Code Content Type
Shippo.Models.Errors.SDKException 4XX, 5XX */*

Get

Returns parcel details using an existing parcel object ID (this will not return parcel details associated with un-purchased shipment/rate parcel object IDs).

Example Usage

using Shippo;
using Shippo.Models.Requests;
using Shippo.Models.Components;

var sdk = new ShippoSDK(
    apiKeyHeader: "<YOUR_API_KEY_HERE>",
    shippoApiVersion: "2018-02-08"
);

var res = await sdk.Parcels.GetAsync(
    parcelId: "<id>",
    shippoApiVersion: "2018-02-08"
);

// handle response

Parameters

Parameter Type Required Description Example
ParcelId string ✔️ Object ID of the parcel
ShippoApiVersion string Optional string used to pick a non-default API version to use. See our API version guide. 2018-02-08

Response

Parcel

Errors

Error Type Status Code Content Type
Shippo.Models.Errors.SDKException 4XX, 5XX */*