(parcels())
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.
The following values are supported for the extra
field of the parcel object.
Returns a list of all parcel objects.
package hello.world;
import com.goshippo.shippo_sdk.Shippo;
import com.goshippo.shippo_sdk.models.operations.ListParcelsResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws Exception {
Shippo sdk = Shippo.builder()
.apiKeyHeader("<YOUR_API_KEY_HERE>")
.shippoApiVersion("2018-02-08")
.build();
ListParcelsResponse res = sdk.parcels().list()
.page(1L)
.results(25L)
.shippoApiVersion("2018-02-08")
.call();
if (res.parcelPaginatedList().isPresent()) {
// handle response
}
}
}
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
page |
Optional<Long> | ➖ | The page number you want to select | |
results |
Optional<Long> | ➖ | The number of results to return per page (max 100) | |
shippoApiVersion |
Optional<String> | ➖ | Optional string used to pick a non-default API version to use. See our API version guide. | 2018-02-08 |
Error Type | Status Code | Content Type |
---|---|---|
models/errors/SDKError | 4XX, 5XX | */* |
Creates a new parcel object.
package hello.world;
import com.goshippo.shippo_sdk.Shippo;
import com.goshippo.shippo_sdk.models.components.Cod;
import com.goshippo.shippo_sdk.models.components.DistanceUnitEnum;
import com.goshippo.shippo_sdk.models.components.ParcelCreateRequest;
import com.goshippo.shippo_sdk.models.components.ParcelExtra;
import com.goshippo.shippo_sdk.models.components.ParcelInsurance;
import com.goshippo.shippo_sdk.models.components.ParcelInsuranceProvider;
import com.goshippo.shippo_sdk.models.components.PaymentMethod;
import com.goshippo.shippo_sdk.models.components.WeightUnitEnum;
import com.goshippo.shippo_sdk.models.operations.CreateParcelRequestBody;
import com.goshippo.shippo_sdk.models.operations.CreateParcelResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws Exception {
Shippo sdk = Shippo.builder()
.apiKeyHeader("<YOUR_API_KEY_HERE>")
.shippoApiVersion("2018-02-08")
.build();
CreateParcelResponse res = sdk.parcels().create()
.shippoApiVersion("2018-02-08")
.requestBody(CreateParcelRequestBody.of(ParcelCreateRequest.builder()
.massUnit(WeightUnitEnum.LB)
.weight("1")
.distanceUnit(DistanceUnitEnum.IN)
.height("1")
.length("1")
.width("1")
.extra(ParcelExtra.builder()
.cod(Cod.builder()
.amount("5.5")
.currency("USD")
.paymentMethod(PaymentMethod.CASH)
.build())
.insurance(ParcelInsurance.builder()
.amount("5.5")
.content("Laptop")
.currency("USD")
.provider(ParcelInsuranceProvider.UPS)
.build())
.build())
.metadata("Customer ID 123456")
.build()))
.call();
if (res.parcel().isPresent()) {
// handle response
}
}
}
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
shippoApiVersion |
Optional<String> | ➖ | Optional string used to pick a non-default API version to use. See our API version guide. | 2018-02-08 |
requestBody |
CreateParcelRequestBody | ✔️ | Parcel details. |
Error Type | Status Code | Content Type |
---|---|---|
models/errors/SDKError | 4XX, 5XX | */* |
Returns parcel details using an existing parcel object ID (this will not return parcel details associated with un-purchased shipment/rate parcel object IDs).
package hello.world;
import com.goshippo.shippo_sdk.Shippo;
import com.goshippo.shippo_sdk.models.operations.GetParcelResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws Exception {
Shippo sdk = Shippo.builder()
.apiKeyHeader("<YOUR_API_KEY_HERE>")
.shippoApiVersion("2018-02-08")
.build();
GetParcelResponse res = sdk.parcels().get()
.parcelId("<id>")
.shippoApiVersion("2018-02-08")
.call();
if (res.parcel().isPresent()) {
// handle response
}
}
}
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
parcelId |
String | ✔️ | Object ID of the parcel | |
shippoApiVersion |
Optional<String> | ➖ | Optional string used to pick a non-default API version to use. See our API version guide. | 2018-02-08 |
Error Type | Status Code | Content Type |
---|---|---|
models/errors/SDKError | 4XX, 5XX | */* |