Skip to content

Latest commit

 

History

History
239 lines (171 loc) · 22.3 KB

File metadata and controls

239 lines (171 loc) · 22.3 KB

UserParcelTemplates

(UserParcelTemplates)

Overview

A user parcel template represents a package used for shipping that has preset dimensions and attributes defined by you. They are useful for capturing attributes of parcel-types you frequently use for shipping, allowing them to be defined once and then used for many shipments. These parcel templates can also be used for live rates.

User parcel templates can also be created using a carrier parcel template, where the dimensions will be copied from the carrier presets, but the weight can be configured by you.

Available Operations

  • List - List all user parcel templates
  • Create - Create a new user parcel template
  • Delete - Delete a user parcel template
  • Get - Retrieves a user parcel template
  • Update - Update an existing user parcel template

List

Returns a list all of all user parcel template 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.UserParcelTemplates.ListAsync(shippoApiVersion: "2018-02-08");

// handle response

Parameters

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

Response

UserParcelTemplateList

Errors

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

Create

Creates a new user parcel template.
You can choose to create a parcel template using a preset carrier template as a starting point, or you can create an entirely custom one. To use a preset carrier template, pass in a unique template token from this list plus the weight fields (weight and weight_unit). Otherwise, omit the template field and pass the other fields, for the weight, length, height, and depth, as well as their units."

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.UserParcelTemplates.CreateAsync(
    userParcelTemplateCreateRequest: UserParcelTemplateCreateRequest.CreateUserParcelTemplateWithCarrierTemplateCreateRequest(
        new UserParcelTemplateWithCarrierTemplateCreateRequest() {
            Weight = "12",
            WeightUnit = Shippo.Models.Components.WeightUnitEnum.Lb,
        }
    ),
    shippoApiVersion: "2018-02-08"
);

// handle response

Parameters

Parameter Type Required Description Example
UserParcelTemplateCreateRequest UserParcelTemplateCreateRequest ✔️ N/A
ShippoApiVersion string Optional string used to pick a non-default API version to use. See our API version guide. 2018-02-08

Response

UserParcelTemplate

Errors

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

Delete

Deletes a user parcel template using an object ID.

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"
);

await sdk.UserParcelTemplates.DeleteAsync(
    userParcelTemplateObjectId: "<id>",
    shippoApiVersion: "2018-02-08"
);

// handle response

Parameters

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

Errors

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

Get

Returns the parcel template information for a specific user parcel template, identified by the object ID.

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.UserParcelTemplates.GetAsync(
    userParcelTemplateObjectId: "<id>",
    shippoApiVersion: "2018-02-08"
);

// handle response

Parameters

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

Response

UserParcelTemplate

Errors

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

Update

Updates an existing user parcel template.

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.UserParcelTemplates.UpdateAsync(
    userParcelTemplateObjectId: "<id>",
    shippoApiVersion: "2018-02-08",
    userParcelTemplateUpdateRequest: new UserParcelTemplateUpdateRequest() {
        DistanceUnit = Shippo.Models.Components.DistanceUnitEnum.In,
        Height = "6",
        Length = "10",
        Name = "My Custom Template",
        Weight = "12",
        WeightUnit = Shippo.Models.Components.WeightUnitEnum.Lb,
        Width = "8",
    }
);

// handle response

Parameters

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

Response

UserParcelTemplate

Errors

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