Class Utilities
java.lang.Object
com.easypost.utils.Utilities
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic SmartRate
findLowestSmartrate
(List<SmartRate> smartrates, int deliveryDay, SmartrateAccuracy deliveryAccuracy) Find the lowest Smartrate from a list of Smartrates.static Rate
Get the lowest rate from a list of rates.static SmartRate
getLowestSmartRate
(List<SmartRate> smartrates, int deliveryDay, String deliveryAccuracy) Deprecated.static StatelessRate
getLowestStatelessRate
(List<StatelessRate> rates, List<String> carriers, List<String> services) Get the lowest stateless rate from a list of stateless rates.static Event
validateWebhook
(byte[] eventBody, Map<String, Object> headers, String webhookSecret) Validate a webhook by comparing the HMAC signature header sent from EasyPost to your shared secret.
-
Constructor Details
-
Utilities
public Utilities()
-
-
Method Details
-
getLowestStatelessRate
public static StatelessRate getLowestStatelessRate(List<StatelessRate> rates, List<String> carriers, List<String> services) throws FilteringError, NumberFormatException Get the lowest stateless rate from a list of stateless rates.- Parameters:
rates
- the list of stateless rates.carriers
- the carriers to use in the filter.services
- the services to use in the filter.- Returns:
- lowest StatelessRate object
- Throws:
FilteringError
- when the filters could not be applied.NumberFormatException
-
getLowestObjectRate
public static Rate getLowestObjectRate(List<Rate> rates, List<String> carriers, List<String> services) throws FilteringError Get the lowest rate from a list of rates.- Parameters:
rates
- the list of rates.carriers
- the carriers to use in the filter.services
- the services to use in the filter.- Returns:
- lowest Rate object
- Throws:
FilteringError
- when the filters could not be applied.
-
validateWebhook
public static Event validateWebhook(byte[] eventBody, Map<String, Object> headers, String webhookSecret) throws EasyPostExceptionValidate a webhook by comparing the HMAC signature header sent from EasyPost to your shared secret. If the signatures do not match, an error will be raised signifying the webhook either did not originate from EasyPost or the secrets do not match. If the signatures do match, the `event_body` will be returned as JSON.- Parameters:
eventBody
- Data to validateheaders
- Headers received from the webhookwebhookSecret
- Shared secret to use in validation- Returns:
- JSON string of the event body if the signatures match, otherwise an error will be raised.
- Throws:
EasyPostException
- when the request fails.
-
getLowestSmartRate
@Deprecated @InlineMe(replacement="Utilities.findLowestSmartrate(smartrates, deliveryDay, SmartrateAccuracy.getByKeyName(deliveryAccuracy))", imports={"com.easypost.model.SmartrateAccuracy","com.easypost.utils.Utilities"}) public static SmartRate getLowestSmartRate(List<SmartRate> smartrates, int deliveryDay, String deliveryAccuracy) throws EasyPostException Deprecated.UsefindLowestSmartrate(List, int, SmartrateAccuracy)
instead. Deprecated: v5.5.0 - v7.0.0Get 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 static 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.
-
findLowestSmartrate(List, int, SmartrateAccuracy)
instead.