Skip to content

Commit d1a0020

Browse files
authored
Merge pull request #350 from EasyPost/v8.0.0
chore: prep v8.0.0 for release
2 parents 6a74138 + 7356672 commit d1a0020

16 files changed

+221
-155
lines changed

CHANGELOG.md

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# CHANGELOG
22

3-
## Next Release
3+
## v8.0.0 (2025-04-28)
4+
5+
See our [Upgrade Guide](UPGRADE_GUIDE.md#upgrading-from-7x-to-80) for more details.
46

57
- Adds `WebhookCustomHeader` model, allowing `custom_headers` to be passed when creating/updating a webhook
68
- Adds the following functions to assist ReferralCustomers add credit cards and bank accounts:
@@ -11,19 +13,23 @@
1113
- Adds missing tracker props
1214
- Adds `tracking_codes` param to tracker index endpoint
1315
- Routes `AmazonShippingAccount` to the correct endpoint
16+
- Corrects payload wrapping for updating a webhook
1417
- Fixes error parsing
1518
- 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)
1619
- Removed the unused `Error` model
1720
- Added an explicit `AddressVerificationFieldError` model
1821
- The `BetaPaymentRefund` now uses a list of `FieldError` instead of `Error` for the `errors` field
1922
- Removes deprecated functions
20-
- `TimeInTransit.getSmartRateAccuracy` (use `TimeInTransit.getSmartrateAccuracy` instead)
2123
- `paymentMethod.all` (use `billing.retrievePaymentMethods` instead)
22-
- `shipment.getSmartrates` (use `shipment.smartrates` instead)
23-
- String overload for `shipment.lowestSmartRate`, 3rd param requires a valid `SmartrateAccuracy`
2424
- `user.apiKeys` (use `apiKey.retrieveApiKeysForUser` instead)
25-
- `utilities.getLowestSmartRate` (use `utilities.findLowestSmartrate` instead)
26-
- Corrects payload wrapping for updating a webhook
25+
- Replaces deprecated functions
26+
- `shipment.lowestSmartRate` (3rd param expects a valid `SmartRateAccuracy`)
27+
- `utilities.findLowestSmartRate` (3rd param expects a valid `SmartRateAccuracy`)
28+
- Renames
29+
- `SmartrateAccuracy` is now `SmartRateAccuracy`
30+
- `SmartrateCollection` is now `SmartRateCollection`
31+
- `shipment.smartrates` is now `shipment.smartRates`
32+
- `TimeInTransit.getBySmartrateAccuracy` is now `TimeInTransit.getSmartRateAccuracy`
2733
- Bumps dependencies
2834

2935
## v7.4.4 (2025-01-03)
@@ -79,6 +85,8 @@
7985

8086
## v7.0.0 (2023-12-06)
8187

88+
See our [Upgrade Guide](UPGRADE_GUIDE.md#upgrading-from-6x-to-70) for more details.
89+
8290
- Removes `withCarbonOffset` parameter from `create`, `buy`, and `regenerateRates` functions of the Shipment service as EasyPost now offers Carbon Neutral shipments by default for free
8391
- Removes the undocumented `createAndBuy` function from the Batch service. The proper usage is to create a batch first and buy it separately
8492
- Changes return type of `all()` in webhook service from `WebhookCollection` to `a list of webhooks`
@@ -149,6 +157,8 @@
149157

150158
## v6.0.0 (2023-01-05)
151159

160+
See our [Upgrade Guide](UPGRADE_GUIDE.md#upgrading-from-5x-to-60) for more details.
161+
152162
Includes all the changes from `v6.0.0-rc1` listed below in addition to the following:
153163

154164
- All constants are now defined in the top-level `Constants` class (`com.easypost.Constants`)
@@ -292,7 +302,7 @@ Includes all the changes from `v6.0.0-rc1` listed below in addition to the follo
292302

293303
## v5.0.0 (2022-01-14)
294304

295-
Upgrading major versions of this project? Refer to the [Upgrade Guide](UPGRADE_GUIDE.md).
305+
See our [Upgrade Guide](UPGRADE_GUIDE.md#upgrading-from-4x-to-50) for more details.
296306

297307
- Bump minimum Java version from 1.5 to 8
298308
- Changed PUT/POST request bodies from url-form encoded to JSON encoded

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Add this to your project's POM:
1616
<dependency>
1717
<groupId>com.easypost</groupId>
1818
<artifactId>easypost-api-client</artifactId>
19-
<version>7.4.4</version>
19+
<version>8.0.0</version>
2020
</dependency>
2121
```
2222

@@ -25,7 +25,7 @@ Add this to your project's POM:
2525
Add this to your project's build file:
2626

2727
```groovy
28-
implementation "com.easypost:easypost-api-client:7.4.4"
28+
implementation "com.easypost:easypost-api-client:8.0.0"
2929
```
3030

3131
**NOTE:** [Google Gson](http://code.google.com/p/google-gson/) is required.

UPGRADE_GUIDE.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,55 @@
22

33
Use the following guide to assist in the upgrade process of the `easypost-java` library between major versions.
44

5+
- [Upgrading from 7.x to 8.x](#upgrading-from-7x-to-80)
56
- [Upgrading from 6.x to 7.x](#upgrading-from-6x-to-70)
67
- [Upgrading from 5.x to 6.0](#upgrading-from-5x-to-60)
78
- [Upgrading from 4.x to 5.0](#upgrading-from-4x-to-50)
89

10+
## Upgrading from 7.x to 8.0
11+
12+
### 8.0 High Impact Changes
13+
14+
- [Error Parsing](#80-error-parsing)
15+
16+
### 8.0 Medium Impact Changes
17+
18+
- [Deprecations](#80-deprecations)
19+
20+
## 8.0 Error Parsing
21+
22+
*Likelihood of Impact: **High***
23+
24+
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.
25+
26+
The `Error` model has been removed since it is unused and we directly assign properties of an error response to the `ApiError` type.
27+
28+
The `BetaPaymentRefund` now uses a list of `FieldError` instead of `Error` for the `errors` field.
29+
30+
See the `CHANGELOG` for more details.
31+
32+
## 8.0 Deprecations
33+
34+
*Likelihood of Impact: **Medium***
35+
36+
The following functions have changed:
37+
38+
- Removed deprecated functions
39+
- `paymentMethod.all` (use `billing.retrievePaymentMethods` instead)
40+
- `user.apiKeys` (use `apiKey.retrieveApiKeysForUser` instead)
41+
- Changed deprecated functions
42+
- `shipment.lowestSmartRate` (3rd param expects a valid `SmartRateAccuracy`)
43+
- `utilities.findLowestSmartRate` (3rd param expects a valid `SmartRateAccuracy`)
44+
- Renames
45+
- `SmartrateAccuracy` is now `SmartRateAccuracy`
46+
- `SmartrateCollection` is now `SmartRateCollection`
47+
- `shipment.smartrates` is now `shipment.smartRates`
48+
- `TimeInTransit.getBySmartrateAccuracy` is now `TimeInTransit.getSmartRateAccuracy`
49+
950
## Upgrading from 6.x to 7.0
1051

52+
**NOTICE:** v7 is deprecated.
53+
1154
### 7.0 High Impact Changes
1255

1356
- [Carbon Offset Removed](#70-carbon-offset-removed)

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.4.4
1+
8.0.0

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<groupId>com.easypost</groupId>
77
<artifactId>easypost-api-client</artifactId>
88

9-
<version>7.4.4</version>
9+
<version>8.0.0</version>
1010
<packaging>jar</packaging>
1111

1212
<name>com.easypost:easypost-api-client</name>

src/main/java/com/easypost/Constants.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import com.easypost.model.AddressVerification;
66
import com.easypost.model.AddressVerificationDeserializer;
77
import com.easypost.model.ErrorDeserializer;
8-
import com.easypost.model.SmartrateCollection;
9-
import com.easypost.model.SmartrateCollectionDeserializer;
8+
import com.easypost.model.SmartRateCollection;
9+
import com.easypost.model.SmartRateCollectionDeserializer;
1010
import com.easypost.model.StatelessRate;
1111
import com.easypost.model.StatelessRateDeserializer;
1212
import com.easypost.model.Webhook;
@@ -83,7 +83,7 @@ public abstract static class Http {
8383
public static final Gson GSON = new GsonBuilder()
8484
.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
8585
.registerTypeAdapter(HashMap.class, new HashMapSerializer())
86-
.registerTypeAdapter(SmartrateCollection.class, new SmartrateCollectionDeserializer())
86+
.registerTypeAdapter(SmartRateCollection.class, new SmartRateCollectionDeserializer())
8787
.registerTypeAdapter(APIException.class, new ErrorDeserializer())
8888
.registerTypeAdapter(AddressVerification.class, new AddressVerificationDeserializer())
8989
.registerTypeAdapter(StatelessRate[].class, new StatelessRateDeserializer())

src/main/java/com/easypost/model/AddressVerificationDeserializer.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ public final class AddressVerificationDeserializer implements JsonDeserializer<A
1818
* @param typeOfT Type of the object to deserialize.
1919
* @param context Deserialization context.
2020
* @return Deserialized AddressVerification object.
21-
* @throws JsonParseException if the JSON object is not a valid SmartrateCollection.
21+
* @throws JsonParseException if the JSON object is not a valid
22+
* SmartRateCollection.
2223
*/
2324
@Override
2425
public AddressVerification deserialize(final JsonElement json, final Type typeOfT,
25-
final JsonDeserializationContext context) throws JsonParseException {
26+
final JsonDeserializationContext context) throws JsonParseException {
2627
JsonObject jo = json.getAsJsonObject();
2728

2829
AddressVerification addressVerification = new AddressVerification();

src/main/java/com/easypost/model/ErrorDeserializer.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@
1616

1717
public final class ErrorDeserializer implements JsonDeserializer<APIException> {
1818
/**
19-
* Recursively traverse an error JSON element and its sub-element(s), and extracts all
19+
* Recursively traverse an error JSON element and its sub-element(s), and
20+
* extracts all
2021
* error string values found into the specified string list.
2122
*
22-
* @param element the JSON element to traverse
23+
* @param element the JSON element to traverse
2324
* @param messagesList the list of strings to append found values to
2425
*/
2526
private void traverseJsonElement(JsonElement element, ArrayList<String> messagesList) {
@@ -45,11 +46,12 @@ private void traverseJsonElement(JsonElement element, ArrayList<String> messages
4546
* @param typeOfT Type of the object to deserialize.
4647
* @param context Deserialization context.
4748
* @return Deserialized APIException object.
48-
* @throws JsonParseException if the JSON object is not a valid SmartrateCollection.
49+
* @throws JsonParseException if the JSON object is not a valid
50+
* SmartRateCollection.
4951
*/
5052
@Override
5153
public APIException deserialize(final JsonElement json, final Type typeOfT,
52-
final JsonDeserializationContext context) throws JsonParseException {
54+
final JsonDeserializationContext context) throws JsonParseException {
5355
JsonObject jo = json.getAsJsonObject();
5456

5557
String message = null;
@@ -83,7 +85,6 @@ public APIException deserialize(final JsonElement json, final Type typeOfT,
8385
}
8486

8587
JsonElement errorsAsJson = errorData.get("errors");
86-
List<Object> errorList = new ArrayList<>();
8788
if (errorsAsJson != null) {
8889
JsonArray errorsAsArray = errorsAsJson.getAsJsonArray();
8990
for (JsonElement errorAsJson : errorsAsArray) {
@@ -106,13 +107,13 @@ public APIException deserialize(final JsonElement json, final Type typeOfT,
106107
fieldError.setSuggestion(suggestion.getAsString());
107108
}
108109

109-
errorList.add(fieldError);
110+
errors.add(fieldError);
110111
} else {
111-
errorList.add(errorAsJson.getAsString());
112+
errors.add(errorAsJson.getAsString());
112113
}
113114
}
114115
}
115116

116-
return new APIException(message, code, errorList);
117+
return new APIException(message, code, errors);
117118
}
118119
}

src/main/java/com/easypost/model/SmartrateAccuracy.java renamed to src/main/java/com/easypost/model/SmartRateAccuracy.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import lombok.Getter;
77

88
@Getter
9-
public enum SmartrateAccuracy {
9+
public enum SmartRateAccuracy {
1010
Percentile50("percentile_50"),
1111
Percentile75("percentile_75"),
1212
Percentile85("percentile_85"),
@@ -22,7 +22,7 @@ public enum SmartrateAccuracy {
2222
*
2323
* @param keyName the internal key name
2424
*/
25-
SmartrateAccuracy(String keyName) {
25+
SmartRateAccuracy(String keyName) {
2626
this.keyName = keyName;
2727
}
2828

@@ -33,8 +33,8 @@ public enum SmartrateAccuracy {
3333
* @return the enum value
3434
* @throws EasyPostException if the key name is not found
3535
*/
36-
public static SmartrateAccuracy getByKeyName(String keyName) throws EasyPostException {
37-
for (SmartrateAccuracy smartrateAccuracy : values()) {
36+
public static SmartRateAccuracy getByKeyName(String keyName) throws EasyPostException {
37+
for (SmartRateAccuracy smartrateAccuracy : values()) {
3838
if (smartrateAccuracy.getKeyName().equals(keyName)) {
3939
return smartrateAccuracy;
4040
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package com.easypost.model;
2+
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
6+
public final class SmartRateCollection {
7+
private List<SmartRate> smartRates;
8+
9+
/**
10+
* Get this SmartRateCollection's Smartrate objects.
11+
*
12+
* @return List of Smartrate objects.
13+
*/
14+
public List<SmartRate> getSmartRates() {
15+
return this.smartRates;
16+
}
17+
18+
/**
19+
* Set this SmartRateCollection's Smartrate objects.
20+
*
21+
* @param smartRates List of Smartrate objects.
22+
*/
23+
public void setSmartRates(final List<SmartRate> smartRates) {
24+
this.smartRates = smartRates;
25+
}
26+
27+
/**
28+
* Constructor.
29+
*/
30+
public SmartRateCollection() {
31+
this.smartRates = new ArrayList<SmartRate>();
32+
}
33+
34+
/**
35+
* Create a SmartRateCollection from a list of rates.
36+
*
37+
* @param smartRates List of Smartrate objects
38+
*/
39+
public SmartRateCollection(final List<SmartRate> smartRates) {
40+
setSmartRates(smartRates);
41+
}
42+
43+
/**
44+
* Add a SmartRate object to this SmartRateCollection.
45+
*
46+
* @param rate Rate object
47+
*/
48+
public void addRate(final SmartRate rate) {
49+
smartRates.add(rate);
50+
}
51+
}

0 commit comments

Comments
 (0)