From 6b160e81137ae75713017351537994dc86122308 Mon Sep 17 00:00:00 2001
From: Justintime50 <39606064+Justintime50@users.noreply.github.com>
Date: Mon, 28 Apr 2025 16:10:12 -0600
Subject: [PATCH 1/4] chore: prep v8.0.0 for release
---
CHANGELOG.md | 12 +++++++++---
README.md | 4 ++--
UPGRADE_GUIDE.md | 38 ++++++++++++++++++++++++++++++++++++++
VERSION | 2 +-
pom.xml | 2 +-
5 files changed, 51 insertions(+), 7 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b8bf21543..dc70a6174 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,8 @@
# CHANGELOG
-## Next Release
+## v8.0.0 (2025-04-28)
+
+See our [Upgrade Guide](UPGRADE_GUIDE.md#upgrading-from-7x-to-80) for more details.
- Adds `WebhookCustomHeader` model, allowing `custom_headers` to be passed when creating/updating a webhook
- Adds the following functions to assist ReferralCustomers add credit cards and bank accounts:
@@ -11,6 +13,7 @@
- Adds missing tracker props
- Adds `tracking_codes` param to tracker index endpoint
- Routes `AmazonShippingAccount` to the correct endpoint
+- Corrects payload wrapping for updating a webhook
- 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
@@ -23,7 +26,6 @@
- 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
## v7.4.4 (2025-01-03)
@@ -79,6 +81,8 @@
## v7.0.0 (2023-12-06)
+See our [Upgrade Guide](UPGRADE_GUIDE.md#upgrading-from-6x-to-70) for more details.
+
- Removes `withCarbonOffset` parameter from `create`, `buy`, and `regenerateRates` functions of the Shipment service as EasyPost now offers Carbon Neutral shipments by default for free
- Removes the undocumented `createAndBuy` function from the Batch service. The proper usage is to create a batch first and buy it separately
- Changes return type of `all()` in webhook service from `WebhookCollection` to `a list of webhooks`
@@ -149,6 +153,8 @@
## v6.0.0 (2023-01-05)
+See our [Upgrade Guide](UPGRADE_GUIDE.md#upgrading-from-5x-to-60) for more details.
+
Includes all the changes from `v6.0.0-rc1` listed below in addition to the following:
- All constants are now defined in the top-level `Constants` class (`com.easypost.Constants`)
@@ -292,7 +298,7 @@ Includes all the changes from `v6.0.0-rc1` listed below in addition to the follo
## v5.0.0 (2022-01-14)
-Upgrading major versions of this project? Refer to the [Upgrade Guide](UPGRADE_GUIDE.md).
+See our [Upgrade Guide](UPGRADE_GUIDE.md#upgrading-from-4x-to-50) for more details.
- Bump minimum Java version from 1.5 to 8
- Changed PUT/POST request bodies from url-form encoded to JSON encoded
diff --git a/README.md b/README.md
index ce8bcbb3f..fd6d2e95d 100644
--- a/README.md
+++ b/README.md
@@ -16,7 +16,7 @@ Add this to your project's POM:
com.easyposteasypost-api-client
- 7.4.4
+ 8.0.0
```
@@ -25,7 +25,7 @@ Add this to your project's POM:
Add this to your project's build file:
```groovy
-implementation "com.easypost:easypost-api-client:7.4.4"
+implementation "com.easypost:easypost-api-client:8.0.0"
```
**NOTE:** [Google Gson](http://code.google.com/p/google-gson/) is required.
diff --git a/UPGRADE_GUIDE.md b/UPGRADE_GUIDE.md
index b4a5a3703..9a9bf3652 100644
--- a/UPGRADE_GUIDE.md
+++ b/UPGRADE_GUIDE.md
@@ -2,12 +2,50 @@
Use the following guide to assist in the upgrade process of the `easypost-java` library between major versions.
+- [Upgrading from 7.x to 8.x](#upgrading-from-7x-to-80)
- [Upgrading from 6.x to 7.x](#upgrading-from-6x-to-70)
- [Upgrading from 5.x to 6.0](#upgrading-from-5x-to-60)
- [Upgrading from 4.x to 5.0](#upgrading-from-4x-to-50)
+## Upgrading from 7.x to 8.0
+
+### 8.0 High Impact Changes
+
+- [Error Parsing](#80-error-parsing)
+
+### 8.0 Medium Impact Changes
+
+- [Deprecations](#80-deprecations)
+
+## 8.0 Error Parsing
+
+*Likelihood of Impact: **High***
+
+The `errors` key of an error response can return either a list of `FieldError` objects or a list of strings. The error parsing has been expanded to include both formats. As such, you will now need to check for the format of the `errors` field and handle the errors appropriately for the type that is returned.
+
+The `Error` model has been removed since it is unused and we directly assign properties of an error response to the `ApiError` type.
+
+The `BetaPaymentRefund` now uses a list of `FieldError` instead of `Error` for the `errors` field.
+
+See the `CHANGELOG` for more details.
+
+## 8.0 Deprecations
+
+*Likelihood of Impact: **Medium***
+
+The following deprecated functions have been removed:
+
+- `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)
+
## Upgrading from 6.x to 7.0
+**NOTICE:** v7 is deprecated.
+
### 7.0 High Impact Changes
- [Carbon Offset Removed](#70-carbon-offset-removed)
diff --git a/VERSION b/VERSION
index 4e61aeef9..ae9a76b92 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-7.4.4
+8.0.0
diff --git a/pom.xml b/pom.xml
index 6ad2f5ab2..f5d54eef8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
com.easyposteasypost-api-client
- 7.4.4
+ 8.0.0jarcom.easypost:easypost-api-client
From 12aa350167727b2fa670556404377affabe2962d Mon Sep 17 00:00:00 2001
From: Justintime50 <39606064+Justintime50@users.noreply.github.com>
Date: Tue, 29 Apr 2025 13:33:08 -0600
Subject: [PATCH 2/4] fix: SmartRate namings
---
CHANGELOG.md | 12 ++--
UPGRADE_GUIDE.md | 21 +++---
src/main/java/com/easypost/Constants.java | 27 +++-----
.../AddressVerificationDeserializer.java | 5 +-
.../com/easypost/model/ErrorDeserializer.java | 17 ++---
...teAccuracy.java => SmartRateAccuracy.java} | 8 +--
.../easypost/model/SmartRateCollection.java | 51 +++++++++++++++
...a => SmartRateCollectionDeserializer.java} | 18 ++---
.../easypost/model/SmartrateCollection.java | 51 ---------------
.../com/easypost/model/TimeInTransit.java | 4 +-
.../com/easypost/service/ShipmentService.java | 65 ++++++++++---------
.../java/com/easypost/utils/Utilities.java | 26 ++++----
src/test/java/com/easypost/ShipmentTest.java | 50 +++++++-------
13 files changed, 185 insertions(+), 170 deletions(-)
rename src/main/java/com/easypost/model/{SmartrateAccuracy.java => SmartRateAccuracy.java} (83%)
create mode 100644 src/main/java/com/easypost/model/SmartRateCollection.java
rename src/main/java/com/easypost/model/{SmartrateCollectionDeserializer.java => SmartRateCollectionDeserializer.java} (68%)
delete mode 100644 src/main/java/com/easypost/model/SmartrateCollection.java
diff --git a/CHANGELOG.md b/CHANGELOG.md
index dc70a6174..7b3c3c79e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -20,12 +20,16 @@ See our [Upgrade Guide](UPGRADE_GUIDE.md#upgrading-from-7x-to-80) for more detai
- 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)
+- Replaces deprecated functions
+ - `shipment.lowestSmartRate` (3rd param expects a valid `SmartRateAccuracy`)
+ - `utilities.findLowestSmartRate` (3rd param expects a valid `SmartRateAccuracy`)
+- Renames
+ - `SmartrateAccuracy` is now `SmartRateAccuracy`
+ - `SmartrateCollection` is now `SmartRateCollection`
+ - `shipment.smartrates` is now `shipment.smartRates`
+ - `TimeInTransit.getBySmartrateAccuracy` is now `TimeInTransit.getSmartRateAccuracy`
- Bumps dependencies
## v7.4.4 (2025-01-03)
diff --git a/UPGRADE_GUIDE.md b/UPGRADE_GUIDE.md
index 9a9bf3652..22efd4799 100644
--- a/UPGRADE_GUIDE.md
+++ b/UPGRADE_GUIDE.md
@@ -33,14 +33,19 @@ See the `CHANGELOG` for more details.
*Likelihood of Impact: **Medium***
-The following deprecated functions have been removed:
-
-- `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)
+The following functions have changed:
+
+- Removed deprecated functions
+ - `paymentMethod.all` (use `billing.retrievePaymentMethods` instead)
+ - `user.apiKeys` (use `apiKey.retrieveApiKeysForUser` instead)
+- Changed deprecated functions
+ - `shipment.lowestSmartRate` (3rd param expects a valid `SmartRateAccuracy`)
+ - `utilities.findLowestSmartRate` (3rd param expects a valid `SmartRateAccuracy`)
+- Renames
+ - `SmartrateAccuracy` is now `SmartRateAccuracy`
+ - `SmartrateCollection` is now `SmartRateCollection`
+ - `shipment.smartrates` is now `shipment.smartRates`
+ - `TimeInTransit.getBySmartrateAccuracy` is now `TimeInTransit.getSmartRateAccuracy`
## Upgrading from 6.x to 7.0
diff --git a/src/main/java/com/easypost/Constants.java b/src/main/java/com/easypost/Constants.java
index 53a6c68f5..934685d9d 100644
--- a/src/main/java/com/easypost/Constants.java
+++ b/src/main/java/com/easypost/Constants.java
@@ -5,8 +5,8 @@
import com.easypost.model.AddressVerification;
import com.easypost.model.AddressVerificationDeserializer;
import com.easypost.model.ErrorDeserializer;
-import com.easypost.model.SmartrateCollection;
-import com.easypost.model.SmartrateCollectionDeserializer;
+import com.easypost.model.SmartRateCollection;
+import com.easypost.model.SmartRateCollectionDeserializer;
import com.easypost.model.StatelessRate;
import com.easypost.model.StatelessRateDeserializer;
import com.easypost.model.Webhook;
@@ -24,21 +24,17 @@ public abstract class Constants {
public static final String EASYPOST_SUPPORT_EMAIL = "support@easypost.com";
public abstract static class ErrorMessages {
- public static final String EXTERNAL_API_CALL_FAILED =
- "Could not send card details to %s, please try again later";
+ public static final String EXTERNAL_API_CALL_FAILED = "Could not send card details to %s, please try again later";
public static final String ENCODED_ERROR = "Encode error for %s";
public static final String INVALID_API_KEY_TYPE = "Invalid API key type.";
public static final String INVALID_PARAMETER = "Invalid parameter: %s.";
- public static final String INVALID_PAYMENT =
- "The chosen payment method is not a credit card. Please try again.";
+ public static final String INVALID_PAYMENT = "The chosen payment method is not a credit card. Please try again.";
public static final String INVALID_WEBHOOK_SIGNATURE = "Webhook does not contain a valid HMAC signature.";
public static final String MISSING_REQUIRED_PARAMETER = "Missing required parameter: %s.";
public static final String NO_OBJECT_FOUND = "No %s found.";
- public static final String NO_PAYMENT_METHODS =
- "No payment methods are set up. Please add a payment method and try again.";
+ public static final String NO_PAYMENT_METHODS = "No payment methods are set up. Please add a payment method and try again.";
public static final String API_DID_NOT_RETURN_ERROR_DETAILS = "API did not return error details.";
- public static final String WEBHOOK_DOES_NOT_MATCH =
- "Webhook received did not originate from EasyPost or had a webhook secret mismatch.";
+ public static final String WEBHOOK_DOES_NOT_MATCH = "Webhook received did not originate from EasyPost or had a webhook secret mismatch.";
public static final String NO_MORE_PAGES_TO_RETRIEVE = "There are no more pages to retrieve.";
}
@@ -62,16 +58,13 @@ public abstract static class ErrorCodes {
public abstract static class CarrierAccountTypes {
public static final List CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_WORKFLOW = ImmutableList.of(
- "FedexAccount", "FedexSmartpostAccount"
- );
+ "FedexAccount", "FedexSmartpostAccount");
public static final List UPS_OAUTH_CARRIER_ACCOUNT_TYPES = ImmutableList.of(
- "UpsAccount", "UpsMailInnovationsAccount", "UpsSurepostAccount"
- );
+ "UpsAccount", "UpsMailInnovationsAccount", "UpsSurepostAccount");
public static final List CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH = ImmutableList.of(
- "AmazonShippingAccount"
- );
+ "AmazonShippingAccount");
}
public abstract static class Http {
@@ -83,7 +76,7 @@ public abstract static class Http {
public static final Gson GSON = new GsonBuilder()
.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
.registerTypeAdapter(HashMap.class, new HashMapSerializer())
- .registerTypeAdapter(SmartrateCollection.class, new SmartrateCollectionDeserializer())
+ .registerTypeAdapter(SmartRateCollection.class, new SmartRateCollectionDeserializer())
.registerTypeAdapter(APIException.class, new ErrorDeserializer())
.registerTypeAdapter(AddressVerification.class, new AddressVerificationDeserializer())
.registerTypeAdapter(StatelessRate[].class, new StatelessRateDeserializer())
diff --git a/src/main/java/com/easypost/model/AddressVerificationDeserializer.java b/src/main/java/com/easypost/model/AddressVerificationDeserializer.java
index 1523fe4c8..2986edd44 100644
--- a/src/main/java/com/easypost/model/AddressVerificationDeserializer.java
+++ b/src/main/java/com/easypost/model/AddressVerificationDeserializer.java
@@ -18,11 +18,12 @@ public final class AddressVerificationDeserializer implements JsonDeserializer {
/**
- * Recursively traverse an error JSON element and its sub-element(s), and extracts all
+ * Recursively traverse an error JSON element and its sub-element(s), and
+ * extracts all
* error string values found into the specified string list.
*
- * @param element the JSON element to traverse
+ * @param element the JSON element to traverse
* @param messagesList the list of strings to append found values to
*/
private void traverseJsonElement(JsonElement element, ArrayList messagesList) {
@@ -45,11 +46,12 @@ private void traverseJsonElement(JsonElement element, ArrayList messages
* @param typeOfT Type of the object to deserialize.
* @param context Deserialization context.
* @return Deserialized APIException object.
- * @throws JsonParseException if the JSON object is not a valid SmartrateCollection.
+ * @throws JsonParseException if the JSON object is not a valid
+ * SmartRateCollection.
*/
@Override
public APIException deserialize(final JsonElement json, final Type typeOfT,
- final JsonDeserializationContext context) throws JsonParseException {
+ final JsonDeserializationContext context) throws JsonParseException {
JsonObject jo = json.getAsJsonObject();
String message = null;
@@ -83,7 +85,6 @@ public APIException deserialize(final JsonElement json, final Type typeOfT,
}
JsonElement errorsAsJson = errorData.get("errors");
- List