Class ShipmentService

java.lang.Object
com.easypost.service.ShipmentService

public class ShipmentService extends Object
  • Method Details

    • create

      public Shipment create(Map<String,Object> params) throws EasyPostException
      Create a new Shipment object from a map of parameters.
      Parameters:
      params - The map of parameters.
      Returns:
      Shipment object
      Throws:
      EasyPostException - when the request fails.
    • retrieve

      public Shipment retrieve(String id) throws EasyPostException
      Retrieve a Shipment from the API.
      Parameters:
      id - The ID of the Shipment to retrieve.
      Returns:
      Shipment object
      Throws:
      EasyPostException - when the request fails.
    • all

      public ShipmentCollection all(Map<String,Object> params) throws EasyPostException
      Get a list of all Shipment objects.
      Parameters:
      params - The options for the query.
      Returns:
      ShipmentCollection object
      Throws:
      EasyPostException - when the request fails.
    • getNextPage

      public ShipmentCollection getNextPage(ShipmentCollection collection) throws EndOfPaginationError
      Get the next page of an ShipmentCollection.
      Parameters:
      collection - ShipmentCollection to get next page of.
      Returns:
      ShipmentCollection object.
      Throws:
      EndOfPaginationError - when there are no more pages to retrieve.
    • getNextPage

      public ShipmentCollection getNextPage(ShipmentCollection collection, Integer pageSize) throws EndOfPaginationError
      Get the next page of an ShipmentCollection.
      Parameters:
      collection - ShipmentCollection to get next page of.
      pageSize - The number of results to return on the next page.
      Returns:
      ShipmentCollection object.
      Throws:
      EndOfPaginationError - when there are no more pages to retrieve.
    • newRates

      public Shipment newRates(String id) throws EasyPostException
      Get new rates for this Shipment.
      Parameters:
      id - The ID of shipment.
      Returns:
      Shipment object
      Throws:
      EasyPostException - when the request fails.
    • newRates

      public Shipment newRates(String id, Map<String,Object> params) throws EasyPostException
      Get new rates for this Shipment.
      Parameters:
      id - The ID of shipment.
      params - The options for the query.
      Returns:
      Shipment object
      Throws:
      EasyPostException - when the request fails.
    • getSmartrates

      @Deprecated @InlineMe(replacement="this.smartrates(id, params)") public final List<SmartRate> getSmartrates(String id, Map<String,Object> params) throws EasyPostException
      Deprecated.
      Use smartrates(String, Map) instead. Deprecated: v5.5.0 - v7.0.0
      Get SmartRates for this Shipment.
      Parameters:
      id - The ID of shipment.
      params - The options for the query.
      Returns:
      List of SmartRate objects
      Throws:
      EasyPostException - when the request fails.
    • smartrates

      public List<SmartRate> smartrates(String id) throws EasyPostException
      Get SmartRate for this Shipment.
      Parameters:
      id - The ID of shipment.
      Returns:
      List of SmartRate objects
      Throws:
      EasyPostException - when the request fails.
    • smartrates

      public List<SmartRate> smartrates(String id, Map<String,Object> params) throws EasyPostException
      Get SmartRates for this Shipment.
      Parameters:
      id - The ID of shipment.
      params - The options for the query.
      Returns:
      List of SmartRate objects
      Throws:
      EasyPostException - when the request fails.
    • buy

      public Shipment buy(String id, Map<String,Object> params) throws EasyPostException
      Buy this Shipment.
      Parameters:
      id - The ID of shipment.
      params - The options for the query.
      Returns:
      Shipment object
      Throws:
      EasyPostException - when the request fails.
    • buy

      public Shipment buy(String id, Rate rate) throws EasyPostException
      Buy this Shipment.
      Parameters:
      id - The ID of shipment.
      rate - The Rate to use for this Shipment.
      Returns:
      Shipment object
      Throws:
      EasyPostException - when the request fails.
    • buy

      public Shipment buy(String id, Rate rate, String endShipperId) throws EasyPostException
      Buy this Shipment.
      Parameters:
      id - The ID of shipment.
      rate - The Rate to use for this Shipment.
      endShipperId - The id of the end shipper to use for this purchase.
      Returns:
      Shipment object
      Throws:
      EasyPostException - when the request fails.
    • buy

      public Shipment buy(String id, Map<String,Object> params, String endShipperId) throws EasyPostException
      Buy this Shipment.
      Parameters:
      id - The ID of shipment.
      params - The options for the query.
      endShipperId - The id of the end shipper to use for this purchase.
      Returns:
      Shipment object
      Throws:
      EasyPostException - when the request fails.
    • refund

      public Shipment refund(String id) throws EasyPostException
      Refund this Shipment.
      Parameters:
      id - The ID of shipment.
      Returns:
      Shipment object
      Throws:
      EasyPostException - when the request fails.
    • refund

      public Shipment refund(String id, Map<String,Object> params) throws EasyPostException
      Refund this Shipment.
      Parameters:
      id - The ID of shipment.
      params - The options for the query.
      Returns:
      Shipment object
      Throws:
      EasyPostException - when the request fails.
    • label

      public Shipment label(String id, Map<String,Object> params) throws EasyPostException
      Label this Shipment.
      Parameters:
      id - The ID of shipment.
      params - The options for the query.
      Returns:
      Shipment object
      Throws:
      EasyPostException - when the request fails.
    • insure

      public Shipment insure(String id, Map<String,Object> params) throws EasyPostException
      Insure this Shipment.
      Parameters:
      id - The ID of shipment.
      params - The options for the query.
      Returns:
      Shipment object
      Throws:
      EasyPostException - when the request fails.
    • lowestSmartRate

      @Deprecated @InlineMe(replacement="this.lowestSmartRate(id, deliveryDay, SmartrateAccuracy.getByKeyName(deliveryAccuracy))", imports="com.easypost.model.SmartrateAccuracy") public final SmartRate lowestSmartRate(String id, int deliveryDay, String deliveryAccuracy) throws EasyPostException
      Deprecated.
      use lowestSmartRate(String, int, SmartrateAccuracy) instead. Deprecated: v5.5.0 - v7.0.0
      Get the lowest SmartRate for this Shipment.
      Parameters:
      id - The ID of shipment.
      deliveryDay - Delivery days restriction to use when filtering.
      deliveryAccuracy - Delivery days accuracy restriction to use when filtering.
      Returns:
      lowest SmartRate object
      Throws:
      EasyPostException - when the request fails.
    • lowestSmartRate

      public SmartRate lowestSmartRate(String id, int deliveryDay, SmartrateAccuracy deliveryAccuracy) throws EasyPostException
      Get the lowest SmartRate for this Shipment.
      Parameters:
      id - The ID of shipment.
      deliveryDay - Delivery days restriction to use when filtering.
      deliveryAccuracy - Delivery days accuracy restriction to use when filtering.
      Returns:
      lowest SmartRate object
      Throws:
      EasyPostException - when the request fails.
    • getSmartrates

      @Deprecated @InlineMe(replacement="this.smartrates(id, null)") public final List<SmartRate> getSmartrates(String id) throws EasyPostException
      Deprecated.
      Use smartrates(String, Map) instead. Deprecated: v5.5.0 - v7.0.0
      Get SmartRates for this Shipment.
      Parameters:
      id - The ID of shipment.
      Returns:
      List of SmartRate objects
      Throws:
      EasyPostException - when the request fails.
    • getLowestSmartRate

      @Deprecated @InlineMe(replacement="this.findLowestSmartrate(smartRates, deliveryDay, SmartrateAccuracy.getByKeyName(deliveryAccuracy))", imports="com.easypost.model.SmartrateAccuracy") public final SmartRate getLowestSmartRate(List<SmartRate> smartRates, int deliveryDay, String deliveryAccuracy) throws EasyPostException
      Deprecated.
      Use findLowestSmartrate(List, int, SmartrateAccuracy) instead. Deprecated: v5.5.0 - v7.0.0
      Get the lowest SmartRate from a list of SmartRates.
      Parameters:
      smartRates - List of SmartRates to filter from.
      deliveryDay - Delivery days restriction to use when filtering.
      deliveryAccuracy - Delivery days accuracy restriction to use when filtering.
      Returns:
      lowest SmartRate object
      Throws:
      EasyPostException - when the request fails.
    • findLowestSmartrate

      public SmartRate findLowestSmartrate(List<SmartRate> smartRates, int deliveryDay, SmartrateAccuracy deliveryAccuracy) throws EasyPostException
      Find the lowest SmartRate from a list of SmartRates.
      Parameters:
      smartRates - List of SmartRates to filter from.
      deliveryDay - Delivery days restriction to use when filtering.
      deliveryAccuracy - Delivery days accuracy restriction to use when filtering.
      Returns:
      lowest Smartrate object
      Throws:
      EasyPostException - when the request fails.
    • generateForm

      public Shipment generateForm(String id, String formType) throws EasyPostException
      Generate a form for this shipment.
      Parameters:
      id - The ID of shipment.
      formType - The form type for this shipment.
      Returns:
      Return a shipment object.
      Throws:
      EasyPostException - when the request fails.
    • generateForm

      public Shipment generateForm(String id, String formType, Map<String,Object> formOptions) throws EasyPostException
      Generate a form for this shipment.
      Parameters:
      id - The ID of shipment.
      formType - The form type for this shipment.
      formOptions - The form options for this shipment.
      Returns:
      Return a shipment object.
      Throws:
      EasyPostException - when the request fails.
    • retrieveEstimatedDeliveryDate

      public List<EstimatedDeliveryDate> retrieveEstimatedDeliveryDate(String id, String plannedShipDate) throws EasyPostException
      Retrieves the estimated delivery date of each Rate via SmartRate.
      Parameters:
      id - The id of the shipment.
      plannedShipDate - The planned shipment date.
      Returns:
      EstimatedDeliveryDate object.
      Throws:
      EasyPostException - When the request fails.
    • recommendShipDate

      public List<RecommendShipDateForShipmentResult> recommendShipDate(String id, String desiredDeliveryDate) throws EasyPostException
      Retrieve a recommended ship date for an existing Shipment via the Precision Shipping API, based on a specific desired delivery date.
      Parameters:
      id - The id of the shipment.
      desiredDeliveryDate - The desired delivery date.
      Returns:
      EstimatedDeliveryDate object.
      Throws:
      EasyPostException - When the request fails.