Skip to content

Latest commit

 

History

History
182 lines (124 loc) · 9.2 KB

README.md

File metadata and controls

182 lines (124 loc) · 9.2 KB

Rates

(rates())

Overview

A rate is the cost to ship a parcel from a carrier. The rate object details the service level including the cost and transit time.

Available Operations

get

Returns an existing rate using a rate object ID.

Example Usage

package hello.world;

import com.shippo.sdk.Shippo;
import com.shippo.sdk.models.operations.GetRateResponse;
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();

        GetRateResponse res = sdk.rates().get()
                .rateId("<value>")
                .shippoApiVersion("2018-02-08")
                .call();

        if (res.rate().isPresent()) {
            // handle response
        }
    }
}

Parameters

Parameter Type Required Description Example
rateId String ✔️ Object ID of the rate
shippoApiVersion Optional String used to pick a non-default API version to use 2018-02-08

Response

GetRateResponse

Errors

Error Object Status Code Content Type
models/errors/SDKError 4xx-5xx */*

listShipmentRates

Returns a paginated list of rates associated with a shipment

Example Usage

package hello.world;

import com.shippo.sdk.Shippo;
import com.shippo.sdk.models.operations.ListShipmentRatesResponse;
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();

        ListShipmentRatesResponse res = sdk.rates().listShipmentRates()
                .shipmentId("<value>")
                .page(1L)
                .results(25L)
                .shippoApiVersion("2018-02-08")
                .call();

        if (res.ratePaginatedList().isPresent()) {
            // handle response
        }
    }
}

Parameters

Parameter Type Required Description Example
shipmentId String ✔️ Object ID of the shipment to update
page Optional The page number you want to select
results Optional The number of results to return per page (max 100)
shippoApiVersion Optional String used to pick a non-default API version to use 2018-02-08

Response

ListShipmentRatesResponse

Errors

Error Object Status Code Content Type
models/errors/SDKError 4xx-5xx */*

listShipmentRatesByCurrencyCode

Returns all available shipping rates for a shipment object.

When you create a new valid shipment object, Shippo automatically calculates all available rates. Depending on your shipment data, there may be none, one or multiple rates.

By default, the calculated rates will return the price in two currencies under the amount and amount_local keys, respectively. The amount key will contain the price of a rate expressed in the currency that is used in the country from where the parcel originates, and the amount_local key will contain the price expressed in the currency that is used in the country the parcel is shipped to. You can request rates with prices expressed in a different currency by adding the currency code to the end of the resource URL. The full list of supported currencies along with their codes can be viewed on open exchange rates.

Note: re-requesting the rates with a different currency code will re-queue the shipment (i.e. set the Shipment's status to QUEUED) and the converted currency rates will only be available when the Shipment's status is set to SUCCESS.

Example Usage

package hello.world;

import com.shippo.sdk.Shippo;
import com.shippo.sdk.models.operations.ListShipmentRatesByCurrencyCodeRequest;
import com.shippo.sdk.models.operations.ListShipmentRatesByCurrencyCodeResponse;
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();

        ListShipmentRatesByCurrencyCodeRequest req = ListShipmentRatesByCurrencyCodeRequest.builder()
                .shipmentId("<value>")
                .currencyCode("USD")
                .build();

        ListShipmentRatesByCurrencyCodeResponse res = sdk.rates().listShipmentRatesByCurrencyCode()
                .request(req)
                .call();

        if (res.ratePaginatedList().isPresent()) {
            // handle response
        }
    }
}

Parameters

Parameter Type Required Description
request ListShipmentRatesByCurrencyCodeRequest ✔️ The request object to use for the request.

Response

ListShipmentRatesByCurrencyCodeResponse

Errors

Error Object Status Code Content Type
models/errors/SDKError 4xx-5xx */*