diff --git a/README.md b/README.md index 6a11f0fc4..02941c2b6 100644 --- a/README.md +++ b/README.md @@ -97,8 +97,8 @@ Users can subscribe to HTTP requests and responses via the `RequestHook` and `Re EasyPostClient client = new EasyPostClient(System.getenv("EASYPOST_API_KEY")); // For request hook custom function, make sure you have RequestHookResponses in the parameter - public static Object requestHookFunction(RequestHookResponses datas) { - // Pass your code here, the information about the request/response is available within the datas parameter. + public static Object requestHookFunction(RequestHookResponses data) { + // Pass your code here, the information about the request/response is available within the data parameter. return true; } @@ -106,13 +106,13 @@ Users can subscribe to HTTP requests and responses via the `RequestHook` and `Re client.unsubscribeToRequestHook(requestHookFunction); // unsubscribe from request hook // For response hook custom function, make sure you have ResponseHookResponses in the parameter - public static Object responseHookFunction(ResponseHookResponses datas) { - // Pass your code here, the information about the request/response is available within the datas parameter. + public static Object responseHookFunction(ResponseHookResponses data) { + // Pass your code here, the information about the request/response is available within the data parameter. return true; } - client.subscribeToRequestHook(responseHookFunction); // subscribe to response hook by passing your custom function - client.unsubscribeToRequestHook(responseHookFunction); // unsubscribe from response hook + client.subscribeToResponseHook(responseHookFunction); // subscribe to response hook by passing your custom function + client.unsubscribeToResponseHook(responseHookFunction); // unsubscribe from response hook ``` ## Documentation diff --git a/src/main/java/com/easypost/exception/APIException.java b/src/main/java/com/easypost/exception/APIException.java index fb8256b0b..5bed1bed8 100644 --- a/src/main/java/com/easypost/exception/APIException.java +++ b/src/main/java/com/easypost/exception/APIException.java @@ -91,6 +91,7 @@ public String getCode() { * * @return message the message of the error object */ + @Override public String getMessage() { return message; } diff --git a/src/main/java/com/easypost/hooks/RequestHook.java b/src/main/java/com/easypost/hooks/RequestHook.java index 2df3dad42..1b5cafedf 100644 --- a/src/main/java/com/easypost/hooks/RequestHook.java +++ b/src/main/java/com/easypost/hooks/RequestHook.java @@ -29,6 +29,7 @@ public void removeEventHandler(Function handler) { */ public void executeEventHandler(RequestHookResponses datas) { for (Function eventHandler : eventHandlers) { + @SuppressWarnings("unused") Object result = eventHandler.apply(datas); } } diff --git a/src/main/java/com/easypost/hooks/ResponseHook.java b/src/main/java/com/easypost/hooks/ResponseHook.java index 965b9c989..47d0452c6 100644 --- a/src/main/java/com/easypost/hooks/ResponseHook.java +++ b/src/main/java/com/easypost/hooks/ResponseHook.java @@ -29,6 +29,7 @@ public void removeEventHandler(Function handler) */ public void executeEventHandler(ResponseHookResponses datas) { for (Function eventHandler : eventHandlers) { + @SuppressWarnings("unused") Object result = eventHandler.apply(datas); } } diff --git a/src/main/java/com/easypost/http/Requestor.java b/src/main/java/com/easypost/http/Requestor.java index 980eba3ca..3b9444d84 100644 --- a/src/main/java/com/easypost/http/Requestor.java +++ b/src/main/java/com/easypost/http/Requestor.java @@ -50,6 +50,7 @@ import java.net.URL; import java.net.URLEncoder; import java.net.URLStreamHandler; +import java.nio.charset.Charset; import java.time.Instant; import java.util.HashMap; import java.util.List; @@ -78,7 +79,7 @@ private static String urlEncodePair(final String key, final String value) throws * * @param apiKey API of this HTTP request. * @return HTTP header - * @throws MissingParameterError + * @throws MissingParameterError When the request fails. */ private static Map generateHeaders(String apiKey) throws MissingParameterError { Map headers = new HashMap(); @@ -159,7 +160,7 @@ private static javax.net.ssl.HttpsURLConnection createEasyPostConnection(final S * @param conn EasyPost HttpsURLConnection * @param body Input body * @return HttpsURLConnection - * @throws IOException + * @throws IOException When the request fails. */ private static javax.net.ssl.HttpsURLConnection writeBody(final javax.net.ssl.HttpsURLConnection conn, final JsonObject body) throws IOException { @@ -276,7 +277,7 @@ private static JsonObject createBody(final Map params) { * * @param params Map of parameter for the HTTP request body. * @return Query string of the Map object. - * @throws UnsupportedEncodingException + * @throws UnsupportedEncodingException When the request fails. */ private static String createQuery(final Map params) throws UnsupportedEncodingException { Map flatParams = flattenParams(params); @@ -329,7 +330,7 @@ private static Map flattenParams(final Map param * * @param responseStream The InputStream from the response body. * @return InputStream in string value. - * @throws IOException + * @throws IOException When the request fails. */ private static String getResponseBody(final InputStream responseStream) throws IOException { if (responseStream.available() == 0) { @@ -583,8 +584,7 @@ private static T httpRequest(final RequestMethod method, final String url, f } Instant requestTimestamp = Instant.now(); UUID requestUuid = UUID.randomUUID(); - Map headers = new HashMap(); - headers = generateHeaders(client.getApiKey()); + Map headers = generateHeaders(client.getApiKey()); RequestHookResponses requestResponse = new RequestHookResponses(headers, method.toString(), url, body, requestTimestamp.toString(), requestUuid.toString()); @@ -744,7 +744,8 @@ private static EasyPostResponse makeAppEngineRequest(final RequestMethod method, if ((method == RequestMethod.POST || method == RequestMethod.PUT) && body != null) { String bodyString = body.toString(); - requestClass.getDeclaredMethod("setPayload", byte[].class).invoke(request, bodyString.getBytes()); + requestClass.getDeclaredMethod("setPayload", byte[].class) + .invoke(request, bodyString.getBytes(Charset.defaultCharset())); } for (Map.Entry header : generateHeaders(client.getApiKey()).entrySet()) { diff --git a/src/main/java/com/easypost/model/CarrierMetadata.java b/src/main/java/com/easypost/model/CarrierMetadata.java index 073393236..6b9b7a025 100644 --- a/src/main/java/com/easypost/model/CarrierMetadata.java +++ b/src/main/java/com/easypost/model/CarrierMetadata.java @@ -9,7 +9,7 @@ public class CarrierMetadata extends EasyPostResource { private List carriers; @Getter - public class Carrier { + public static class Carrier { private String name; private String humanReadable; private List predefinedPackages; @@ -19,7 +19,7 @@ public class Carrier { } @Getter - public class PredefinedPackage { + public static class PredefinedPackage { private String carrier; private String description; private List dimensions; @@ -29,7 +29,7 @@ public class PredefinedPackage { } @Getter - public class ServiceLevels { + public static class ServiceLevels { private String carrier; private String description; private List dimensions; @@ -39,7 +39,7 @@ public class ServiceLevels { } @Getter - public class ShipmentOption { + public static class ShipmentOption { private String carrier; private boolean deprecated; private String description; @@ -49,7 +49,7 @@ public class ShipmentOption { } @Getter - public class SupportedFeatures { + public static class SupportedFeatures { private String carrier; private String description; private String name; diff --git a/src/main/java/com/easypost/model/Error.java b/src/main/java/com/easypost/model/Error.java index 8f1ee3efc..c6b18a143 100644 --- a/src/main/java/com/easypost/model/Error.java +++ b/src/main/java/com/easypost/model/Error.java @@ -4,6 +4,7 @@ import lombok.Getter; @Getter +@SuppressWarnings("JavaLangClash") public final class Error { private String message; private String code; diff --git a/src/main/java/com/easypost/service/AddressService.java b/src/main/java/com/easypost/service/AddressService.java index bc0e6b18a..83e8eb388 100644 --- a/src/main/java/com/easypost/service/AddressService.java +++ b/src/main/java/com/easypost/service/AddressService.java @@ -97,7 +97,7 @@ public AddressCollection getNextPage(AddressCollection collection) throws EndOfP */ public AddressCollection getNextPage(AddressCollection collection, Integer pageSize) throws EndOfPaginationError { return collection.getNextPage(new Function, AddressCollection>() { - @SneakyThrows + @Override @SneakyThrows public AddressCollection apply(Map parameters) { return all(parameters); } diff --git a/src/main/java/com/easypost/service/BetaCarrierMetadataService.java b/src/main/java/com/easypost/service/BetaCarrierMetadataService.java index 98b087088..d5c30be16 100644 --- a/src/main/java/com/easypost/service/BetaCarrierMetadataService.java +++ b/src/main/java/com/easypost/service/BetaCarrierMetadataService.java @@ -24,7 +24,7 @@ public class BetaCarrierMetadataService { * Retrieves all carrier metadata. * * @return CarrierMetadata object - * @throws EasyPostException + * @throws EasyPostException When the request fails. * @deprecated Use carrierMetadata.retrieve instead */ public CarrierMetadata retrieveCarrierMetadata() throws EasyPostException { @@ -36,7 +36,7 @@ public CarrierMetadata retrieveCarrierMetadata() throws EasyPostException { * * @param carriers The list of carriers in string. * @return CarrierMetadata object - * @throws EasyPostException + * @throws EasyPostException When the request fails. * @deprecated Use carrierMetadata.retrieve instead */ public CarrierMetadata retrieveCarrierMetadata(List carriers) throws EasyPostException { @@ -49,7 +49,7 @@ public CarrierMetadata retrieveCarrierMetadata(List carriers) throws Eas * @param carriers The list of carriers in string. * @param types The list of types in string. * @return CarrierMetadata object - * @throws EasyPostException + * @throws EasyPostException When the request fails. * @deprecated Use carrierMetadata.retrieve instead */ public CarrierMetadata retrieveCarrierMetadata(List carriers, List types) throws EasyPostException { diff --git a/src/main/java/com/easypost/service/BetaReferralCustomerService.java b/src/main/java/com/easypost/service/BetaReferralCustomerService.java index aa2196a2c..474312c40 100644 --- a/src/main/java/com/easypost/service/BetaReferralCustomerService.java +++ b/src/main/java/com/easypost/service/BetaReferralCustomerService.java @@ -27,7 +27,7 @@ public class BetaReferralCustomerService { * @param stripeCustomerId ID of the Stripe account. * @param paymentMethodReference Reference of Stripe payment method. * @return PaymentMethodObject object. - * @throws EasyPostException + * @throws EasyPostException When the request fails. */ public PaymentMethodObject addPaymentMethod(String stripeCustomerId, String paymentMethodReference) throws EasyPostException { @@ -41,7 +41,7 @@ public PaymentMethodObject addPaymentMethod(String stripeCustomerId, String paym * @param paymentMethodReference Reference of Stripe payment method. * @param primaryOrSecondary Primary or secondary of this payment method. * @return PaymentMethodObject object. - * @throws EasyPostException + * @throws EasyPostException When the request fails. */ public PaymentMethodObject addPaymentMethod(String stripeCustomerId, String paymentMethodReference, PaymentMethod.Priority primaryOrSecondary) throws EasyPostException { @@ -64,7 +64,7 @@ public PaymentMethodObject addPaymentMethod(String stripeCustomerId, String paym * * @param refundAmount Amount to be refunded by cents. * @return BetaPaymentRefund object. - * @throws EasyPostException + * @throws EasyPostException When the request fails. */ public BetaPaymentRefund refundByAmount(int refundAmount) throws EasyPostException { HashMap params = new HashMap<>(); @@ -81,7 +81,7 @@ public BetaPaymentRefund refundByAmount(int refundAmount) throws EasyPostExcepti * * @param paymentLogId ID of the payment log. * @return BetaPaymentRefund object. - * @throws EasyPostException + * @throws EasyPostException When the request fails. */ public BetaPaymentRefund refundByPaymentLog(String paymentLogId) throws EasyPostException { HashMap params = new HashMap<>(); diff --git a/src/main/java/com/easypost/service/CarrierMetadataService.java b/src/main/java/com/easypost/service/CarrierMetadataService.java index b6bf04ba0..df3466d7b 100644 --- a/src/main/java/com/easypost/service/CarrierMetadataService.java +++ b/src/main/java/com/easypost/service/CarrierMetadataService.java @@ -24,7 +24,7 @@ public class CarrierMetadataService { * Retrieves all carrier metadata. * * @return CarrierMetadata object - * @throws EasyPostException + * @throws EasyPostException When the request fails. */ public CarrierMetadata retrieve() throws EasyPostException { return retrieve(null); @@ -35,7 +35,7 @@ public CarrierMetadata retrieve() throws EasyPostException { * * @param carriers The list of carriers in string. * @return CarrierMetadata object - * @throws EasyPostException + * @throws EasyPostException When the request fails. */ public CarrierMetadata retrieve(List carriers) throws EasyPostException { return retrieve(carriers, null); @@ -47,7 +47,7 @@ public CarrierMetadata retrieve(List carriers) throws EasyPostException * @param carriers The list of carriers in string. * @param types The list of types in string. * @return CarrierMetadata object - * @throws EasyPostException + * @throws EasyPostException When the request fails. */ public CarrierMetadata retrieve(List carriers, List types) throws EasyPostException { HashMap params = new HashMap<>(); diff --git a/src/main/java/com/easypost/service/EasyPostClient.java b/src/main/java/com/easypost/service/EasyPostClient.java index 4447a0ebe..9a4f78acf 100644 --- a/src/main/java/com/easypost/service/EasyPostClient.java +++ b/src/main/java/com/easypost/service/EasyPostClient.java @@ -54,7 +54,7 @@ public class EasyPostClient { * EasyPostClient constructor. * * @param apiKey API key for API calls. - * @throws MissingParameterError + * @throws MissingParameterError When the request fails. */ public EasyPostClient(String apiKey) throws MissingParameterError { this(apiKey, Constants.Http.DEFAULT_CONNECT_TIMEOUT_MILLISECONDS); @@ -65,7 +65,7 @@ public EasyPostClient(String apiKey) throws MissingParameterError { * * @param apiKey API key for API calls. * @param apiBase API base for API calls. - * @throws MissingParameterError + * @throws MissingParameterError When the request fails. */ public EasyPostClient(String apiKey, String apiBase) throws MissingParameterError { this(apiKey, Constants.Http.DEFAULT_CONNECT_TIMEOUT_MILLISECONDS, @@ -77,7 +77,7 @@ public EasyPostClient(String apiKey, String apiBase) throws MissingParameterErro * * @param apiKey API key for API calls. * @param connectTimeoutMilliseconds Timeout for connection. - * @throws MissingParameterError + * @throws MissingParameterError When the request fails. */ public EasyPostClient(String apiKey, int connectTimeoutMilliseconds) throws MissingParameterError { this(apiKey, connectTimeoutMilliseconds, Constants.Http.API_BASE); @@ -89,7 +89,7 @@ public EasyPostClient(String apiKey, int connectTimeoutMilliseconds) throws Miss * @param apiKey API key for API calls. * @param connectTimeoutMilliseconds Timeout for connection. * @param apiBase API base for API calls. - * @throws MissingParameterError + * @throws MissingParameterError When the request fails. */ public EasyPostClient(String apiKey, int connectTimeoutMilliseconds, String apiBase) throws MissingParameterError { this(apiKey, connectTimeoutMilliseconds, Constants.Http.DEFAULT_READ_TIMEOUT_MILLISECONDS, apiBase); @@ -101,7 +101,7 @@ public EasyPostClient(String apiKey, int connectTimeoutMilliseconds, String apiB * @param apiKey API key for API calls. * @param connectTimeoutMilliseconds Timeout for connection. * @param readTimeoutMilliseconds Timeout for read. - * @throws MissingParameterError + * @throws MissingParameterError When the request fails. */ public EasyPostClient(String apiKey, int connectTimeoutMilliseconds, int readTimeoutMilliseconds) throws MissingParameterError { @@ -115,7 +115,7 @@ public EasyPostClient(String apiKey, int connectTimeoutMilliseconds, int readTim * @param connectTimeoutMilliseconds Timeout for connection. * @param readTimeoutMilliseconds Timeout for read. * @param apiBase API base for API calls. - * @throws MissingParameterError + * @throws MissingParameterError When the request fails. */ public EasyPostClient(String apiKey, int connectTimeoutMilliseconds, int readTimeoutMilliseconds, String apiBase) throws MissingParameterError { @@ -159,7 +159,7 @@ public EasyPostClient(String apiKey, int connectTimeoutMilliseconds, int readTim /** * Subscribes to a request hook from the given function. - * @param function + * @param function The function to be subscribed to the request hook */ public void subscribeToRequestHook(Function function) { this.requestHooks.addEventHandler(function); @@ -167,7 +167,7 @@ public void subscribeToRequestHook(Function functi /** * Unsubscribes to a request hook from the given function. - * @param function + * @param function The function to be unsubscribed from the request hook */ public void unsubscribeFromRequestHook(Function function) { this.requestHooks.removeEventHandler(function); @@ -175,7 +175,7 @@ public void unsubscribeFromRequestHook(Function fu /** * Subscribes to a response hook from the given function. - * @param function + * @param function The function to be subscribed to the response hook */ public void subscribeToResponseHook(Function function) { this.responseHooks.addEventHandler(function); @@ -183,7 +183,7 @@ public void subscribeToResponseHook(Function func /** * Unubscribes to a response hook from the given function. - * @param function + * @param function The function to be unsubscribed from the response hook */ public void unsubscribeFromResponseHook(Function function) { this.responseHooks.removeEventHandler(function); diff --git a/src/main/java/com/easypost/service/EventService.java b/src/main/java/com/easypost/service/EventService.java index 7c6545504..3981f996b 100644 --- a/src/main/java/com/easypost/service/EventService.java +++ b/src/main/java/com/easypost/service/EventService.java @@ -73,7 +73,7 @@ public EventCollection getNextPage(EventCollection collection) throws EndOfPagin */ public EventCollection getNextPage(EventCollection collection, Integer pageSize) throws EndOfPaginationError { return collection.getNextPage(new Function, EventCollection>() { - @SneakyThrows + @Override @SneakyThrows public EventCollection apply(Map parameters) { return all(parameters); } diff --git a/src/main/java/com/easypost/service/InsuranceService.java b/src/main/java/com/easypost/service/InsuranceService.java index 510a027e8..375980752 100644 --- a/src/main/java/com/easypost/service/InsuranceService.java +++ b/src/main/java/com/easypost/service/InsuranceService.java @@ -88,7 +88,7 @@ public InsuranceCollection getNextPage(InsuranceCollection collection) throws En public InsuranceCollection getNextPage( InsuranceCollection collection, Integer pageSize) throws EndOfPaginationError { return collection.getNextPage(new Function, InsuranceCollection>() { - @SneakyThrows + @Override @SneakyThrows public InsuranceCollection apply(Map parameters) { return all(parameters); } diff --git a/src/main/java/com/easypost/service/PickupService.java b/src/main/java/com/easypost/service/PickupService.java index e8540287c..b0feeb89d 100644 --- a/src/main/java/com/easypost/service/PickupService.java +++ b/src/main/java/com/easypost/service/PickupService.java @@ -59,7 +59,7 @@ public PickupCollection getNextPage(PickupCollection collection) throws EndOfPag */ public PickupCollection getNextPage(PickupCollection collection, Integer pageSize) throws EndOfPaginationError { return collection.getNextPage(new Function, PickupCollection>() { - @SneakyThrows + @Override @SneakyThrows public PickupCollection apply(Map parameters) { return all(parameters); } diff --git a/src/main/java/com/easypost/service/ReferralCustomerService.java b/src/main/java/com/easypost/service/ReferralCustomerService.java index 3b4977923..92c0b4309 100644 --- a/src/main/java/com/easypost/service/ReferralCustomerService.java +++ b/src/main/java/com/easypost/service/ReferralCustomerService.java @@ -20,6 +20,7 @@ import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; import java.util.function.Function; @@ -110,7 +111,7 @@ public ReferralCustomerCollection getNextPage(ReferralCustomerCollection collect public ReferralCustomerCollection getNextPage( ReferralCustomerCollection collection, Integer pageSize) throws EndOfPaginationError { return collection.getNextPage(new Function, ReferralCustomerCollection>() { - @SneakyThrows + @Override @SneakyThrows public ReferralCustomerCollection apply(Map parameters) { return all(parameters); } @@ -220,8 +221,8 @@ private static String createStripeToken(final String number, final int expiratio StringBuilder response; - try (BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()))) { - + try (BufferedReader br = new BufferedReader( + new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8))) { String line; response = new StringBuilder(); diff --git a/src/main/java/com/easypost/service/RefundService.java b/src/main/java/com/easypost/service/RefundService.java index cf686431e..49ac2638f 100644 --- a/src/main/java/com/easypost/service/RefundService.java +++ b/src/main/java/com/easypost/service/RefundService.java @@ -91,7 +91,7 @@ public RefundCollection getNextPage(RefundCollection collection) throws EndOfPag */ public RefundCollection getNextPage(RefundCollection collection, Integer pageSize) throws EndOfPaginationError { return collection.getNextPage(new Function, RefundCollection>() { - @SneakyThrows + @Override @SneakyThrows public RefundCollection apply(Map parameters) { return all(parameters); } diff --git a/src/main/java/com/easypost/service/ReportService.java b/src/main/java/com/easypost/service/ReportService.java index b2da1b402..1e029eb83 100644 --- a/src/main/java/com/easypost/service/ReportService.java +++ b/src/main/java/com/easypost/service/ReportService.java @@ -119,7 +119,7 @@ public ReportCollection getNextPage(ReportCollection collection) throws EndOfPag */ public ReportCollection getNextPage(ReportCollection collection, Integer pageSize) throws EndOfPaginationError { return collection.getNextPage(new Function, ReportCollection>() { - @SneakyThrows + @Override @SneakyThrows public ReportCollection apply(Map parameters) { return all(parameters); } diff --git a/src/main/java/com/easypost/service/ScanformService.java b/src/main/java/com/easypost/service/ScanformService.java index 5d275e056..a3f95e07a 100644 --- a/src/main/java/com/easypost/service/ScanformService.java +++ b/src/main/java/com/easypost/service/ScanformService.java @@ -83,7 +83,7 @@ public ScanFormCollection getNextPage(ScanFormCollection collection) throws EndO */ public ScanFormCollection getNextPage(ScanFormCollection collection, Integer pageSize) throws EndOfPaginationError { return collection.getNextPage(new Function, ScanFormCollection>() { - @SneakyThrows + @Override @SneakyThrows public ScanFormCollection apply(Map parameters) { return all(parameters); } diff --git a/src/main/java/com/easypost/service/ShipmentService.java b/src/main/java/com/easypost/service/ShipmentService.java index f317535d5..e033352e3 100644 --- a/src/main/java/com/easypost/service/ShipmentService.java +++ b/src/main/java/com/easypost/service/ShipmentService.java @@ -90,6 +90,7 @@ public ShipmentCollection all(final Map params) throws EasyPostE ShipmentCollection shipmentCollection = Requestor.request(RequestMethod.GET, endpoint, params, ShipmentCollection.class, client); // we store the params in the collection so that we can use them to get the next page + shipmentCollection.setPurchased(InternalUtilities.getOrDefault(params, "purchased", null)); shipmentCollection.setIncludeChildren(InternalUtilities.getOrDefault(params, "include_children", null)); @@ -117,7 +118,7 @@ public ShipmentCollection getNextPage(ShipmentCollection collection) throws EndO */ public ShipmentCollection getNextPage(ShipmentCollection collection, Integer pageSize) throws EndOfPaginationError { return collection.getNextPage(new Function, ShipmentCollection>() { - @SneakyThrows + @Override @SneakyThrows public ShipmentCollection apply(Map parameters) { return all(parameters); } @@ -397,8 +398,7 @@ public Shipment insure(final String id, final Map params) throws * filtering. * @return lowest SmartRate object * @throws EasyPostException when the request fails. - * @deprecated use {@link #lowestSmartRate(String, int, SmartrateAccuracy)} - * instead. + * @deprecated use {@link #lowestSmartRate(String, int, SmartrateAccuracy)} instead. * Deprecated: v5.5.0 - v7.0.0 */ @Deprecated @@ -449,8 +449,7 @@ public List getSmartrates(final String id) throws EasyPostException { * filtering. * @return lowest SmartRate object * @throws EasyPostException when the request fails. - * @deprecated Use {@link #findLowestSmartrate(List, int, SmartrateAccuracy)} - * instead. + * @deprecated Use {@link #findLowestSmartrate(List, int, SmartrateAccuracy)} instead. * Deprecated: v5.5.0 - v7.0.0 */ @Deprecated @@ -532,7 +531,7 @@ public Shipment generateForm(final String id, final String formType, final Map retrieveEstimatedDeliveryDate(final String id, final String plannedShipDate) throws EasyPostException { diff --git a/src/main/java/com/easypost/service/TrackerService.java b/src/main/java/com/easypost/service/TrackerService.java index f8409b8f1..d5f2ca7a9 100644 --- a/src/main/java/com/easypost/service/TrackerService.java +++ b/src/main/java/com/easypost/service/TrackerService.java @@ -94,7 +94,7 @@ public TrackerCollection getNextPage(TrackerCollection collection) throws EndOfP */ public TrackerCollection getNextPage(TrackerCollection collection, Integer pageSize) throws EndOfPaginationError { return collection.getNextPage(new Function, TrackerCollection>() { - @SneakyThrows + @Override @SneakyThrows public TrackerCollection apply(Map parameters) { return all(parameters); } diff --git a/src/main/java/com/easypost/utils/Utilities.java b/src/main/java/com/easypost/utils/Utilities.java index 9044dd665..849ad0a44 100644 --- a/src/main/java/com/easypost/utils/Utilities.java +++ b/src/main/java/com/easypost/utils/Utilities.java @@ -147,9 +147,8 @@ public static Event validateWebhook(byte[] eventBody, Map header * filtering. * @return lowest Smartrate object * @throws EasyPostException when the request fails. - * @deprecated Use {@link #findLowestSmartrate(List, int, SmartrateAccuracy)} - * instead. - * Deprecated: v5.5.0 - v7.0.0 + * @deprecated Use {@link #findLowestSmartrate(List, int, SmartrateAccuracy)} instead. + * Deprecated: v5.5.0 - v7.0.0 */ @Deprecated public static SmartRate getLowestSmartRate(final List smartrates, int deliveryDay, diff --git a/src/test/java/com/easypost/BetaRateTest.java b/src/test/java/com/easypost/BetaRateTest.java index 95c6d2008..00428c109 100644 --- a/src/test/java/com/easypost/BetaRateTest.java +++ b/src/test/java/com/easypost/BetaRateTest.java @@ -40,7 +40,7 @@ public void testRetrieveStatelessRates() throws EasyPostException { List rates = vcr.client.betaRate.retrieveStatelessRates(shipment); - assertTrue(rates.stream().allMatch(rate -> rate instanceof StatelessRate)); + assertTrue(rates.stream().allMatch(rate -> rate != null)); } /** diff --git a/src/test/java/com/easypost/BetaReferralCustomerTest.java b/src/test/java/com/easypost/BetaReferralCustomerTest.java index b25e53907..7e2b02623 100644 --- a/src/test/java/com/easypost/BetaReferralCustomerTest.java +++ b/src/test/java/com/easypost/BetaReferralCustomerTest.java @@ -24,7 +24,7 @@ public static void setup() throws EasyPostException { /** * Test add Stripe payment method for referral customer. * - * @throws EasyPostException + * @throws EasyPostException When the request fails. */ @Test public void testAddPaymentMethod() throws EasyPostException { diff --git a/src/test/java/com/easypost/Fixtures.java b/src/test/java/com/easypost/Fixtures.java index 244c15ae9..62e7c523e 100644 --- a/src/test/java/com/easypost/Fixtures.java +++ b/src/test/java/com/easypost/Fixtures.java @@ -7,6 +7,7 @@ import java.io.IOException; import java.lang.reflect.Type; +import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; @@ -279,7 +280,8 @@ public static byte[] eventBytes() { byte[] data = null; try { - data = Files.readAllLines(Paths.get(fullFilePath), StandardCharsets.UTF_8).get(0).getBytes(); + data = Files.readAllLines(Paths.get(fullFilePath), StandardCharsets.UTF_8) + .get(0).getBytes(Charset.defaultCharset()); } catch (IOException error) { error.printStackTrace(); } diff --git a/src/test/java/com/easypost/HookTest.java b/src/test/java/com/easypost/HookTest.java index 0b72ace97..0e6e6ea12 100644 --- a/src/test/java/com/easypost/HookTest.java +++ b/src/test/java/com/easypost/HookTest.java @@ -29,11 +29,10 @@ public static void setup() throws EasyPostException { /** * Test failing a hook if we subscribed to a request hook. * - * @param datas The RequestHookResponses object representing the hook data. + * @param data The RequestHookResponses object representing the hook data. * @return The result of the test. - * @throws EasyPostException when the request fails. */ - public static Object failIfSubscribedToRequest(RequestHookResponses datas) { + public static Object failIfSubscribedToRequest(RequestHookResponses data) { fail("Test failed"); return false; @@ -42,11 +41,10 @@ public static Object failIfSubscribedToRequest(RequestHookResponses datas) { /** * Test failing a hook if we subscribed to a response hook. * - * @param datas The ResponseHookResponses object representing the hook data. + * @param data The ResponseHookResponses object representing the hook data. * @return The result of the test. - * @throws EasyPostException when the request fails. */ - public static Object failIfSubscribedToResponse(ResponseHookResponses datas) { + public static Object failIfSubscribedToResponse(ResponseHookResponses data) { fail("Test failed"); return false; @@ -55,17 +53,16 @@ public static Object failIfSubscribedToResponse(ResponseHookResponses datas) { /** * Test subscribing a request hook. * - * @param datas The RequestHookResponses object representing the hook data. + * @param data The RequestHookResponses object representing the hook data. * @return The result of the test. - * @throws EasyPostException when the request fails. */ - public static Object testRequestHooks(RequestHookResponses datas) { - assertEquals("https://api.easypost.com/v2/parcels", datas.getPath()); - assertEquals("POST", datas.getMethod()); - assertNotNull(datas.getHeaders()); - assertNotNull(datas.getRequestBody()); - assertNotNull(datas.getRequestTimestamp()); - assertNotNull(datas.getRequestUuid()); + public static Object testRequestHooks(RequestHookResponses data) { + assertEquals("https://api.easypost.com/v2/parcels", data.getPath()); + assertEquals("POST", data.getMethod()); + assertNotNull(data.getHeaders()); + assertNotNull(data.getRequestBody()); + assertNotNull(data.getRequestTimestamp()); + assertNotNull(data.getRequestUuid()); return true; } @@ -73,19 +70,18 @@ public static Object testRequestHooks(RequestHookResponses datas) { /** * Test subscribing a response hook. * - * @param datas The ResponseHookResponses object representing the hook data. + * @param data The ResponseHookResponses object representing the hook data. * @return The result of the test. - * @throws EasyPostException when the request fails. */ - public static Object testResponseHooks(ResponseHookResponses datas) { - assertEquals("https://api.easypost.com/v2/parcels", datas.getPath()); - assertEquals("POST", datas.getMethod()); - assertEquals(201, datas.getHttpStatus()); - assertNotNull(datas.getHeaders()); - assertNotNull(datas.getResponseBody()); - assertNotNull(datas.getRequestTimestamp()); - assertNotNull(datas.getRequestTimestamp()); - assertNotNull(datas.getRequestUuid()); + public static Object testResponseHooks(ResponseHookResponses data) { + assertEquals("https://api.easypost.com/v2/parcels", data.getPath()); + assertEquals("POST", data.getMethod()); + assertEquals(201, data.getHttpStatus()); + assertNotNull(data.getHeaders()); + assertNotNull(data.getResponseBody()); + assertNotNull(data.getRequestTimestamp()); + assertNotNull(data.getRequestTimestamp()); + assertNotNull(data.getRequestUuid()); return true; }