Skip to content

Commit 38f73b3

Browse files
authored
Merge pull request #346 from EasyPost/breaking_changes
chore: remove deprecated functions
2 parents f3f9d17 + 265b9c4 commit 38f73b3

File tree

10 files changed

+19
-212
lines changed

10 files changed

+19
-212
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- uses: actions/setup-java@v4
1818
with:
1919
distribution: "zulu"
20-
java-version: "21" # Always use the latest stable JDK for building
20+
java-version: "21" # Always use the most recent LTS JDK for building
2121
cache: "maven"
2222
- name: Install dependencies
2323
run: make install
@@ -37,7 +37,7 @@ jobs:
3737
- uses: actions/setup-java@v4
3838
with:
3939
distribution: "zulu"
40-
java-version: "21" # Always use the latest stable JDK for building
40+
java-version: "21" # Always use the most recent LTS JDK for building
4141
cache: "maven"
4242
- name: Install dependencies
4343
run: make install
@@ -65,7 +65,7 @@ jobs:
6565
- uses: actions/setup-java@v4
6666
with:
6767
distribution: "zulu"
68-
java-version: "21" # Always use the latest stable JDK for building
68+
java-version: "21" # Always use the most recent LTS JDK for building
6969
cache: "maven"
7070
- name: Install checkstyle and style guide
7171
run: make install-checkstyle
@@ -84,7 +84,7 @@ jobs:
8484
- uses: actions/setup-java@v4
8585
with:
8686
distribution: "zulu"
87-
java-version: "21" # Always use the latest stable JDK for building
87+
java-version: "21" # Always use the most recent LTS JDK for building
8888
cache: "maven"
8989
- name: Install Dependencies
9090
run: make install

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
uses: actions/setup-java@v4
3737
with:
3838
distribution: "zulu"
39-
java-version: "21" # Always use the latest stable JDK for building
39+
java-version: "21" # Always use the most recent LTS JDK for building
4040
server-id: "ossrh"
4141
# define environmental variable names
4242
server-username: MAVEN_USERNAME

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,19 @@
33
## Next Release
44

55
- Adds `WebhookCustomHeader` model, allowing `custom_headers` to be passed when creating/updating a webhook
6+
- Adds `tracking_codes` param to tracker index endpoint
67
- Fixes error parsing
78
- 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)
89
- Removed the unused `Error` model
910
- Added an explicit `AddressVerificationFieldError` model
1011
- The `BetaPaymentRefund` now uses a list of `FieldError` instead of `Error` for the `errors` field
12+
- Removes deprecated functions
13+
- `TimeInTransit.getSmartRateAccuracy` (use `TimeInTransit.getSmartrateAccuracy` instead)
14+
- `paymentMethod.all` (use `billing.retrievePaymentMethods` instead)
15+
- `shipment.getSmartrates` (use `shipment.smartrates` instead)
16+
- String overload for `shipment.lowestSmartRate`, 3rd param requires a valid `SmartrateAccuracy`
17+
- `user.apiKeys` (use `apiKey.retrieveApiKeysForUser` instead)
18+
- `utilities.getLowestSmartRate` (use `utilities.findLowestSmartrate` instead)
1119
- Corrects payload wrapping for updating a webhook
1220
- Bumps dependencies
1321

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

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -24,37 +24,6 @@ public final class TimeInTransit {
2424
@SerializedName("percentile_99")
2525
private Integer percentile99;
2626

27-
/**
28-
* Get the delivery accuracy of a specific percentile of this TimeInTransit.
29-
*
30-
* @param percentile the percentile to find the corresponding accuracy for
31-
* @return the delivery accuracy of the specified percentile
32-
* @throws EasyPostException when the percentile is not valid
33-
* @deprecated Use {@link #getBySmartrateAccuracy(SmartrateAccuracy)} instead.
34-
* Deprecated: v5.5.0 - v7.0.0
35-
*/
36-
@Deprecated
37-
public int getSmartRateAccuracy(final String percentile) throws EasyPostException {
38-
switch (percentile) {
39-
case "percentile_50":
40-
return this.percentile50;
41-
case "percentile_75":
42-
return this.percentile75;
43-
case "percentile_85":
44-
return this.percentile85;
45-
case "percentile_90":
46-
return this.percentile90;
47-
case "percentile_95":
48-
return this.percentile95;
49-
case "percentile_97":
50-
return this.percentile97;
51-
case "percentile_99":
52-
return this.percentile99;
53-
default:
54-
throw new InvalidParameterError("percentile");
55-
}
56-
}
57-
5827
/**
5928
* Get the delivery accuracy of a specific percentile of this TimeInTransit.
6029
*

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ public class TrackerCollection extends PaginatedCollection<Tracker> {
1414
@Setter
1515
private String trackingCode;
1616

17+
@Setter
18+
private List<String> trackingCodes;
19+
1720
@Setter
1821
private String carrier;
1922

@@ -33,6 +36,9 @@ protected final Map<String, Object> buildNextPageParameters(List<Tracker> tracke
3336
if (trackingCode != null) {
3437
parameters.put("tracking_code", trackingCode);
3538
}
39+
if (trackingCodes != null) {
40+
parameters.put("tracking_codes", trackingCodes);
41+
}
3642
if (carrier != null) {
3743
parameters.put("carrier", carrier);
3844
}
Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
package com.easypost.service;
22

3-
import com.easypost.Constants;
4-
import com.easypost.exception.EasyPostException;
5-
import com.easypost.exception.General.InvalidObjectError;
6-
import com.easypost.http.Requestor;
7-
import com.easypost.http.Requestor.RequestMethod;
8-
import com.easypost.model.PaymentMethod;
9-
103
public class PaymentMethodService {
114
private final EasyPostClient client;
125

@@ -18,26 +11,4 @@ public class PaymentMethodService {
1811
PaymentMethodService(EasyPostClient client) {
1912
this.client = client;
2013
}
21-
22-
/**
23-
* List all payment methods.
24-
*
25-
* @return Billing object.
26-
* @throws EasyPostException when the request fails.
27-
* @deprecated Use {@link com.easypost.service.BillingService#retrievePaymentMethods()} instead.
28-
* Deprecated: v5.5.0 - v7.0.0
29-
*/
30-
@Deprecated
31-
public PaymentMethod all() throws EasyPostException {
32-
String endpoint = "payment_methods";
33-
34-
PaymentMethod response =
35-
Requestor.request(RequestMethod.GET, endpoint, null, PaymentMethod.class, client);
36-
37-
if (response.getId() == null) {
38-
throw new InvalidObjectError(Constants.ErrorMessages.NO_PAYMENT_METHODS);
39-
}
40-
41-
return response;
42-
}
4314
}

src/main/java/com/easypost/service/ShipmentService.java

Lines changed: 0 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import java.util.List;
2424
import java.util.Map;
2525
import java.util.function.Function;
26-
import com.google.errorprone.annotations.InlineMe;
2726

2827
public class ShipmentService {
2928
private final EasyPostClient client;
@@ -139,23 +138,6 @@ public Shipment newRates(final String id, final Map<String, Object> params) thro
139138
return Requestor.request(RequestMethod.POST, endpoint, params, Shipment.class, client);
140139
}
141140

142-
/**
143-
* Get SmartRates for this Shipment.
144-
*
145-
* @param params The options for the query.
146-
* @param id The ID of shipment.
147-
* @return List of SmartRate objects
148-
* @throws EasyPostException when the request fails.
149-
* @deprecated Use {@link #smartrates(String, Map)} instead.
150-
* Deprecated: v5.5.0 - v7.0.0
151-
*/
152-
@Deprecated
153-
@InlineMe(replacement = "this.smartrates(id, params)")
154-
public final List<SmartRate> getSmartrates(final String id, final Map<String, Object> params)
155-
throws EasyPostException {
156-
return this.smartrates(id, params);
157-
}
158-
159141
/**
160142
* Get SmartRate for this Shipment.
161143
*
@@ -300,28 +282,6 @@ public Shipment insure(final String id, final Map<String, Object> params) throws
300282
return Requestor.request(RequestMethod.POST, endpoint, params, Shipment.class, client);
301283
}
302284

303-
/**
304-
* Get the lowest SmartRate for this Shipment.
305-
*
306-
* @param id The ID of shipment.
307-
* @param deliveryDay Delivery days restriction to use when filtering.
308-
* @param deliveryAccuracy Delivery days accuracy restriction to use when
309-
* filtering.
310-
* @return lowest SmartRate object
311-
* @throws EasyPostException when the request fails.
312-
* @deprecated use {@link #lowestSmartRate(String, int, SmartrateAccuracy)} instead.
313-
* Deprecated: v5.5.0 - v7.0.0
314-
*/
315-
@Deprecated
316-
@InlineMe(
317-
replacement = "this.lowestSmartRate(id, deliveryDay, SmartrateAccuracy.getByKeyName(deliveryAccuracy))",
318-
imports = "com.easypost.model.SmartrateAccuracy"
319-
)
320-
public final SmartRate lowestSmartRate(final String id, int deliveryDay, String deliveryAccuracy)
321-
throws EasyPostException {
322-
return this.lowestSmartRate(id, deliveryDay, SmartrateAccuracy.getByKeyName(deliveryAccuracy));
323-
}
324-
325285
/**
326286
* Get the lowest SmartRate for this Shipment.
327287
*
@@ -341,43 +301,6 @@ public SmartRate lowestSmartRate(final String id, final int deliveryDay, Smartra
341301
return lowestSmartrate;
342302
}
343303

344-
/**
345-
* Get SmartRates for this Shipment.
346-
*
347-
* @param id The ID of shipment.
348-
* @return List of SmartRate objects
349-
* @throws EasyPostException when the request fails.
350-
* @deprecated Use {@link #smartrates(String, Map)} instead.
351-
* Deprecated: v5.5.0 - v7.0.0
352-
*/
353-
@Deprecated
354-
@InlineMe(replacement = "this.smartrates(id, null)")
355-
public final List<SmartRate> getSmartrates(final String id) throws EasyPostException {
356-
return this.smartrates(id, null);
357-
}
358-
359-
/**
360-
* Get the lowest SmartRate from a list of SmartRates.
361-
*
362-
* @param smartRates List of SmartRates to filter from.
363-
* @param deliveryDay Delivery days restriction to use when filtering.
364-
* @param deliveryAccuracy Delivery days accuracy restriction to use when
365-
* filtering.
366-
* @return lowest SmartRate object
367-
* @throws EasyPostException when the request fails.
368-
* @deprecated Use {@link #findLowestSmartrate(List, int, SmartrateAccuracy)} instead.
369-
* Deprecated: v5.5.0 - v7.0.0
370-
*/
371-
@Deprecated
372-
@InlineMe(replacement =
373-
"this.findLowestSmartrate(smartRates, deliveryDay, SmartrateAccuracy.getByKeyName(deliveryAccuracy))",
374-
imports = "com.easypost.model.SmartrateAccuracy"
375-
)
376-
public final SmartRate getLowestSmartRate(final List<SmartRate> smartRates,
377-
int deliveryDay, String deliveryAccuracy) throws EasyPostException {
378-
return findLowestSmartrate(smartRates, deliveryDay, SmartrateAccuracy.getByKeyName(deliveryAccuracy));
379-
}
380-
381304
/**
382305
* Find the lowest SmartRate from a list of SmartRates.
383306
*

src/main/java/com/easypost/service/UserService.java

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,17 @@
11
package com.easypost.service;
22

3-
import com.easypost.Constants;
43
import com.easypost.exception.EasyPostException;
54
import com.easypost.exception.General.EndOfPaginationError;
6-
import com.easypost.exception.General.FilteringError;
75
import com.easypost.http.Requestor;
86
import com.easypost.http.Requestor.RequestMethod;
9-
import com.easypost.model.ApiKey;
10-
import com.easypost.model.ApiKeys;
117
import com.easypost.model.Brand;
128
import com.easypost.model.ChildUserCollection;
139
import com.easypost.model.User;
1410

1511
import lombok.SneakyThrows;
1612

1713
import java.util.HashMap;
18-
import java.util.List;
1914
import java.util.Map;
20-
import java.util.Objects;
2115
import java.util.function.Function;
2216

2317
public class UserService {
@@ -102,30 +96,6 @@ public void delete(final String id) throws EasyPostException {
10296
Requestor.request(RequestMethod.DELETE, endpoint, null, User.class, client);
10397
}
10498

105-
/**
106-
* Get this User's API keys.
107-
*
108-
* @deprecated Use {@link ApiKeyService#retrieveApiKeysForUser(String)} instead.
109-
* @param id The ID of the user.
110-
* @return List of ApiKey objects.
111-
* @throws EasyPostException when the request fails.
112-
*/
113-
public List<ApiKey> apiKeys(final String id) throws EasyPostException {
114-
ApiKeys parentKeys = client.apiKey.all();
115-
116-
if (Objects.equals(id, parentKeys.getId())) {
117-
return parentKeys.getKeys();
118-
}
119-
120-
for (int i = 0; i < parentKeys.getChildren().size(); i++) {
121-
if (id.equals(parentKeys.getChildren().get(i).getId())) {
122-
return parentKeys.getChildren().get(i).getKeys();
123-
}
124-
}
125-
126-
throw new FilteringError(String.format(Constants.ErrorMessages.NO_OBJECT_FOUND, "API keys"));
127-
}
128-
12999
/**
130100
* Update the user brand.
131101
*

src/main/java/com/easypost/utils/Utilities.java

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import com.easypost.model.SmartRate;
1010
import com.easypost.model.SmartrateAccuracy;
1111
import com.easypost.model.StatelessRate;
12-
import com.google.errorprone.annotations.InlineMe;
1312

1413
import java.util.List;
1514
import java.util.Map;
@@ -139,27 +138,6 @@ public static Event validateWebhook(byte[] eventBody, Map<String, Object> header
139138
}
140139
}
141140

142-
/**
143-
* Get the lowest Smartrate from a list of Smartrates.
144-
*
145-
* @param smartrates List of Smartrates to filter from.
146-
* @param deliveryDay Delivery days restriction to use when filtering.
147-
* @param deliveryAccuracy Delivery days accuracy restriction to use when
148-
* filtering.
149-
* @return lowest Smartrate object
150-
* @throws EasyPostException when the request fails.
151-
* @deprecated Use {@link #findLowestSmartrate(List, int, SmartrateAccuracy)} instead.
152-
* Deprecated: v5.5.0 - v7.0.0
153-
*/
154-
@Deprecated
155-
@InlineMe(replacement =
156-
"Utilities.findLowestSmartrate(smartrates, deliveryDay, SmartrateAccuracy.getByKeyName(deliveryAccuracy))",
157-
imports = {"com.easypost.model.SmartrateAccuracy", "com.easypost.utils.Utilities"})
158-
public static SmartRate getLowestSmartRate(final List<SmartRate> smartrates, int deliveryDay,
159-
String deliveryAccuracy) throws EasyPostException {
160-
return findLowestSmartrate(smartrates, deliveryDay, SmartrateAccuracy.getByKeyName(deliveryAccuracy));
161-
}
162-
163141
/**
164142
* Find the lowest Smartrate from a list of Smartrates.
165143
*

src/test/java/com/easypost/ShipmentTest.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import com.easypost.exception.EasyPostException;
44
import com.easypost.exception.General.EndOfPaginationError;
5-
import com.easypost.exception.General.InvalidParameterError;
65
import com.easypost.model.Address;
76
import com.easypost.model.EndShipper;
87
import com.easypost.model.EstimatedDeliveryDate;
@@ -392,9 +391,6 @@ public void testSmartRate() throws EasyPostException {
392391
assertNotNull(smartRate.getTimeInTransit().getPercentile95());
393392
assertNotNull(smartRate.getTimeInTransit().getPercentile97());
394393
assertNotNull(smartRate.getTimeInTransit().getPercentile99());
395-
396-
assertThrows(InvalidParameterError.class,
397-
() -> smartRate.getTimeInTransit().getSmartRateAccuracy("percentile_100"));
398394
}
399395

400396
/**
@@ -536,20 +532,6 @@ public void testInstanceLowestSmartRate() throws EasyPostException {
536532
assertThrows(EasyPostException.class, () -> {
537533
vcr.client.shipment.lowestSmartRate(shipment.getId(), 0, SmartrateAccuracy.Percentile90);
538534
});
539-
540-
SmartRate deprecatedLowestSmartRateFilters = vcr.client.shipment.lowestSmartRate(shipment.getId(), 3,
541-
SmartrateAccuracy.Percentile90);
542-
543-
// Test lowest smartrate with valid filters
544-
assertEquals("GroundAdvantage", deprecatedLowestSmartRateFilters.getService());
545-
assertEquals(5.93, deprecatedLowestSmartRateFilters.getRate(), 0.01);
546-
assertEquals("USPS", deprecatedLowestSmartRateFilters.getCarrier());
547-
548-
// Test lowest smartrate with invalid filters (should error due to strict
549-
// delivery days)
550-
assertThrows(EasyPostException.class, () -> {
551-
vcr.client.shipment.lowestSmartRate(shipment.getId(), 0, SmartrateAccuracy.Percentile90);
552-
});
553535
}
554536

555537
/**

0 commit comments

Comments
 (0)