diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5a908e50b..f447570c5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ jobs: - uses: actions/setup-java@v4 with: distribution: "zulu" - java-version: "21" # Always use the latest stable JDK for building + java-version: "21" # Always use the most recent LTS JDK for building cache: "maven" - name: Install dependencies run: make install @@ -37,7 +37,7 @@ jobs: - uses: actions/setup-java@v4 with: distribution: "zulu" - java-version: "21" # Always use the latest stable JDK for building + java-version: "21" # Always use the most recent LTS JDK for building cache: "maven" - name: Install dependencies run: make install @@ -65,7 +65,7 @@ jobs: - uses: actions/setup-java@v4 with: distribution: "zulu" - java-version: "21" # Always use the latest stable JDK for building + java-version: "21" # Always use the most recent LTS JDK for building cache: "maven" - name: Install checkstyle and style guide run: make install-checkstyle @@ -84,7 +84,7 @@ jobs: - uses: actions/setup-java@v4 with: distribution: "zulu" - java-version: "21" # Always use the latest stable JDK for building + java-version: "21" # Always use the most recent LTS JDK for building cache: "maven" - name: Install Dependencies run: make install diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 03140bcf9..b83130a6b 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -36,7 +36,7 @@ jobs: uses: actions/setup-java@v4 with: distribution: "zulu" - java-version: "21" # Always use the latest stable JDK for building + java-version: "21" # Always use the most recent LTS JDK for building server-id: "ossrh" # define environmental variable names server-username: MAVEN_USERNAME diff --git a/CHANGELOG.md b/CHANGELOG.md index 46be9d20d..7a05adbe7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,11 +3,19 @@ ## Next Release - Adds `WebhookCustomHeader` model, allowing `custom_headers` to be passed when creating/updating a webhook +- Adds `tracking_codes` param to tracker index endpoint - Fixes error parsing - Allows for alternative format of `errors` field (previously we deserialized the `errors` field into a list of `Error` objects; however, sometimes the errors are simply a list of strings. This change make the `errors` field a list of `Object` allowing for either the new `FieldError` object or a list of strings. Users will need to check for the type of error returned and handle appropriately) - Removed the unused `Error` model - Added an explicit `AddressVerificationFieldError` model - The `BetaPaymentRefund` now uses a list of `FieldError` instead of `Error` for the `errors` field +- Removes deprecated functions + - `TimeInTransit.getSmartRateAccuracy` (use `TimeInTransit.getSmartrateAccuracy` instead) + - `paymentMethod.all` (use `billing.retrievePaymentMethods` instead) + - `shipment.getSmartrates` (use `shipment.smartrates` instead) + - String overload for `shipment.lowestSmartRate`, 3rd param requires a valid `SmartrateAccuracy` + - `user.apiKeys` (use `apiKey.retrieveApiKeysForUser` instead) + - `utilities.getLowestSmartRate` (use `utilities.findLowestSmartrate` instead) - Corrects payload wrapping for updating a webhook - Bumps dependencies diff --git a/src/main/java/com/easypost/model/TimeInTransit.java b/src/main/java/com/easypost/model/TimeInTransit.java index e4b4fcdaa..8283945f9 100644 --- a/src/main/java/com/easypost/model/TimeInTransit.java +++ b/src/main/java/com/easypost/model/TimeInTransit.java @@ -24,37 +24,6 @@ public final class TimeInTransit { @SerializedName("percentile_99") private Integer percentile99; - /** - * Get the delivery accuracy of a specific percentile of this TimeInTransit. - * - * @param percentile the percentile to find the corresponding accuracy for - * @return the delivery accuracy of the specified percentile - * @throws EasyPostException when the percentile is not valid - * @deprecated Use {@link #getBySmartrateAccuracy(SmartrateAccuracy)} instead. - * Deprecated: v5.5.0 - v7.0.0 - */ - @Deprecated - public int getSmartRateAccuracy(final String percentile) throws EasyPostException { - switch (percentile) { - case "percentile_50": - return this.percentile50; - case "percentile_75": - return this.percentile75; - case "percentile_85": - return this.percentile85; - case "percentile_90": - return this.percentile90; - case "percentile_95": - return this.percentile95; - case "percentile_97": - return this.percentile97; - case "percentile_99": - return this.percentile99; - default: - throw new InvalidParameterError("percentile"); - } - } - /** * Get the delivery accuracy of a specific percentile of this TimeInTransit. * diff --git a/src/main/java/com/easypost/model/TrackerCollection.java b/src/main/java/com/easypost/model/TrackerCollection.java index 0d49464c9..843abd1f1 100644 --- a/src/main/java/com/easypost/model/TrackerCollection.java +++ b/src/main/java/com/easypost/model/TrackerCollection.java @@ -14,6 +14,9 @@ public class TrackerCollection extends PaginatedCollection { @Setter private String trackingCode; + @Setter + private List trackingCodes; + @Setter private String carrier; @@ -33,6 +36,9 @@ protected final Map buildNextPageParameters(List tracke if (trackingCode != null) { parameters.put("tracking_code", trackingCode); } + if (trackingCodes != null) { + parameters.put("tracking_codes", trackingCodes); + } if (carrier != null) { parameters.put("carrier", carrier); } diff --git a/src/main/java/com/easypost/service/PaymentMethodService.java b/src/main/java/com/easypost/service/PaymentMethodService.java index c2b75715b..8216ee6c8 100644 --- a/src/main/java/com/easypost/service/PaymentMethodService.java +++ b/src/main/java/com/easypost/service/PaymentMethodService.java @@ -1,12 +1,5 @@ package com.easypost.service; -import com.easypost.Constants; -import com.easypost.exception.EasyPostException; -import com.easypost.exception.General.InvalidObjectError; -import com.easypost.http.Requestor; -import com.easypost.http.Requestor.RequestMethod; -import com.easypost.model.PaymentMethod; - public class PaymentMethodService { private final EasyPostClient client; @@ -18,26 +11,4 @@ public class PaymentMethodService { PaymentMethodService(EasyPostClient client) { this.client = client; } - - /** - * List all payment methods. - * - * @return Billing object. - * @throws EasyPostException when the request fails. - * @deprecated Use {@link com.easypost.service.BillingService#retrievePaymentMethods()} instead. - * Deprecated: v5.5.0 - v7.0.0 - */ - @Deprecated - public PaymentMethod all() throws EasyPostException { - String endpoint = "payment_methods"; - - PaymentMethod response = - Requestor.request(RequestMethod.GET, endpoint, null, PaymentMethod.class, client); - - if (response.getId() == null) { - throw new InvalidObjectError(Constants.ErrorMessages.NO_PAYMENT_METHODS); - } - - return response; - } } diff --git a/src/main/java/com/easypost/service/ShipmentService.java b/src/main/java/com/easypost/service/ShipmentService.java index d6619ac85..ddc7cbee2 100644 --- a/src/main/java/com/easypost/service/ShipmentService.java +++ b/src/main/java/com/easypost/service/ShipmentService.java @@ -23,7 +23,6 @@ import java.util.List; import java.util.Map; import java.util.function.Function; -import com.google.errorprone.annotations.InlineMe; public class ShipmentService { private final EasyPostClient client; @@ -139,23 +138,6 @@ public Shipment newRates(final String id, final Map params) thro return Requestor.request(RequestMethod.POST, endpoint, params, Shipment.class, client); } - /** - * Get SmartRates for this Shipment. - * - * @param params The options for the query. - * @param id The ID of shipment. - * @return List of SmartRate objects - * @throws EasyPostException when the request fails. - * @deprecated Use {@link #smartrates(String, Map)} instead. - * Deprecated: v5.5.0 - v7.0.0 - */ - @Deprecated - @InlineMe(replacement = "this.smartrates(id, params)") - public final List getSmartrates(final String id, final Map params) - throws EasyPostException { - return this.smartrates(id, params); - } - /** * Get SmartRate for this Shipment. * @@ -300,28 +282,6 @@ public Shipment insure(final String id, final Map params) throws return Requestor.request(RequestMethod.POST, endpoint, params, Shipment.class, client); } - /** - * Get the lowest SmartRate for this Shipment. - * - * @param id The ID of shipment. - * @param deliveryDay Delivery days restriction to use when filtering. - * @param deliveryAccuracy Delivery days accuracy restriction to use when - * filtering. - * @return lowest SmartRate object - * @throws EasyPostException when the request fails. - * @deprecated use {@link #lowestSmartRate(String, int, SmartrateAccuracy)} instead. - * Deprecated: v5.5.0 - v7.0.0 - */ - @Deprecated - @InlineMe( - replacement = "this.lowestSmartRate(id, deliveryDay, SmartrateAccuracy.getByKeyName(deliveryAccuracy))", - imports = "com.easypost.model.SmartrateAccuracy" - ) - public final SmartRate lowestSmartRate(final String id, int deliveryDay, String deliveryAccuracy) - throws EasyPostException { - return this.lowestSmartRate(id, deliveryDay, SmartrateAccuracy.getByKeyName(deliveryAccuracy)); - } - /** * Get the lowest SmartRate for this Shipment. * @@ -341,43 +301,6 @@ public SmartRate lowestSmartRate(final String id, final int deliveryDay, Smartra return lowestSmartrate; } - /** - * Get SmartRates for this Shipment. - * - * @param id The ID of shipment. - * @return List of SmartRate objects - * @throws EasyPostException when the request fails. - * @deprecated Use {@link #smartrates(String, Map)} instead. - * Deprecated: v5.5.0 - v7.0.0 - */ - @Deprecated - @InlineMe(replacement = "this.smartrates(id, null)") - public final List getSmartrates(final String id) throws EasyPostException { - return this.smartrates(id, null); - } - - /** - * Get the lowest SmartRate from a list of SmartRates. - * - * @param smartRates List of SmartRates to filter from. - * @param deliveryDay Delivery days restriction to use when filtering. - * @param deliveryAccuracy Delivery days accuracy restriction to use when - * 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 - @InlineMe(replacement = - "this.findLowestSmartrate(smartRates, deliveryDay, SmartrateAccuracy.getByKeyName(deliveryAccuracy))", - imports = "com.easypost.model.SmartrateAccuracy" - ) - public final SmartRate getLowestSmartRate(final List smartRates, - int deliveryDay, String deliveryAccuracy) throws EasyPostException { - return findLowestSmartrate(smartRates, deliveryDay, SmartrateAccuracy.getByKeyName(deliveryAccuracy)); - } - /** * Find the lowest SmartRate from a list of SmartRates. * diff --git a/src/main/java/com/easypost/service/UserService.java b/src/main/java/com/easypost/service/UserService.java index 44d67a57f..d437b73d5 100644 --- a/src/main/java/com/easypost/service/UserService.java +++ b/src/main/java/com/easypost/service/UserService.java @@ -1,13 +1,9 @@ package com.easypost.service; -import com.easypost.Constants; import com.easypost.exception.EasyPostException; import com.easypost.exception.General.EndOfPaginationError; -import com.easypost.exception.General.FilteringError; import com.easypost.http.Requestor; import com.easypost.http.Requestor.RequestMethod; -import com.easypost.model.ApiKey; -import com.easypost.model.ApiKeys; import com.easypost.model.Brand; import com.easypost.model.ChildUserCollection; import com.easypost.model.User; @@ -15,9 +11,7 @@ import lombok.SneakyThrows; import java.util.HashMap; -import java.util.List; import java.util.Map; -import java.util.Objects; import java.util.function.Function; public class UserService { @@ -102,30 +96,6 @@ public void delete(final String id) throws EasyPostException { Requestor.request(RequestMethod.DELETE, endpoint, null, User.class, client); } - /** - * Get this User's API keys. - * - * @deprecated Use {@link ApiKeyService#retrieveApiKeysForUser(String)} instead. - * @param id The ID of the user. - * @return List of ApiKey objects. - * @throws EasyPostException when the request fails. - */ - public List apiKeys(final String id) throws EasyPostException { - ApiKeys parentKeys = client.apiKey.all(); - - if (Objects.equals(id, parentKeys.getId())) { - return parentKeys.getKeys(); - } - - for (int i = 0; i < parentKeys.getChildren().size(); i++) { - if (id.equals(parentKeys.getChildren().get(i).getId())) { - return parentKeys.getChildren().get(i).getKeys(); - } - } - - throw new FilteringError(String.format(Constants.ErrorMessages.NO_OBJECT_FOUND, "API keys")); - } - /** * Update the user brand. * diff --git a/src/main/java/com/easypost/utils/Utilities.java b/src/main/java/com/easypost/utils/Utilities.java index 7cbbad66e..e01848563 100644 --- a/src/main/java/com/easypost/utils/Utilities.java +++ b/src/main/java/com/easypost/utils/Utilities.java @@ -9,7 +9,6 @@ import com.easypost.model.SmartRate; import com.easypost.model.SmartrateAccuracy; import com.easypost.model.StatelessRate; -import com.google.errorprone.annotations.InlineMe; import java.util.List; import java.util.Map; @@ -139,27 +138,6 @@ public static Event validateWebhook(byte[] eventBody, Map header } } - /** - * Get the lowest Smartrate from a list of Smartrates. - * - * @param smartrates List of Smartrates to filter from. - * @param deliveryDay Delivery days restriction to use when filtering. - * @param deliveryAccuracy Delivery days accuracy restriction to use when - * 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 - @InlineMe(replacement = - "Utilities.findLowestSmartrate(smartrates, deliveryDay, SmartrateAccuracy.getByKeyName(deliveryAccuracy))", - imports = {"com.easypost.model.SmartrateAccuracy", "com.easypost.utils.Utilities"}) - public static SmartRate getLowestSmartRate(final List smartrates, int deliveryDay, - String deliveryAccuracy) throws EasyPostException { - return findLowestSmartrate(smartrates, deliveryDay, SmartrateAccuracy.getByKeyName(deliveryAccuracy)); - } - /** * Find the lowest Smartrate from a list of Smartrates. * diff --git a/src/test/java/com/easypost/ShipmentTest.java b/src/test/java/com/easypost/ShipmentTest.java index fe27bd213..8da0cff38 100644 --- a/src/test/java/com/easypost/ShipmentTest.java +++ b/src/test/java/com/easypost/ShipmentTest.java @@ -2,7 +2,6 @@ import com.easypost.exception.EasyPostException; import com.easypost.exception.General.EndOfPaginationError; -import com.easypost.exception.General.InvalidParameterError; import com.easypost.model.Address; import com.easypost.model.EndShipper; import com.easypost.model.EstimatedDeliveryDate; @@ -392,9 +391,6 @@ public void testSmartRate() throws EasyPostException { assertNotNull(smartRate.getTimeInTransit().getPercentile95()); assertNotNull(smartRate.getTimeInTransit().getPercentile97()); assertNotNull(smartRate.getTimeInTransit().getPercentile99()); - - assertThrows(InvalidParameterError.class, - () -> smartRate.getTimeInTransit().getSmartRateAccuracy("percentile_100")); } /** @@ -536,20 +532,6 @@ public void testInstanceLowestSmartRate() throws EasyPostException { assertThrows(EasyPostException.class, () -> { vcr.client.shipment.lowestSmartRate(shipment.getId(), 0, SmartrateAccuracy.Percentile90); }); - - SmartRate deprecatedLowestSmartRateFilters = vcr.client.shipment.lowestSmartRate(shipment.getId(), 3, - SmartrateAccuracy.Percentile90); - - // Test lowest smartrate with valid filters - assertEquals("GroundAdvantage", deprecatedLowestSmartRateFilters.getService()); - assertEquals(5.93, deprecatedLowestSmartRateFilters.getRate(), 0.01); - assertEquals("USPS", deprecatedLowestSmartRateFilters.getCarrier()); - - // Test lowest smartrate with invalid filters (should error due to strict - // delivery days) - assertThrows(EasyPostException.class, () -> { - vcr.client.shipment.lowestSmartRate(shipment.getId(), 0, SmartrateAccuracy.Percentile90); - }); } /**