Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
31 changes: 0 additions & 31 deletions src/main/java/com/easypost/model/TimeInTransit.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/easypost/model/TrackerCollection.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ public class TrackerCollection extends PaginatedCollection<Tracker> {
@Setter
private String trackingCode;

@Setter
private List<String> trackingCodes;

@Setter
private String carrier;

Expand All @@ -33,6 +36,9 @@ protected final Map<String, Object> buildNextPageParameters(List<Tracker> tracke
if (trackingCode != null) {
parameters.put("tracking_code", trackingCode);
}
if (trackingCodes != null) {
parameters.put("tracking_codes", trackingCodes);
}
if (carrier != null) {
parameters.put("carrier", carrier);
}
Expand Down
29 changes: 0 additions & 29 deletions src/main/java/com/easypost/service/PaymentMethodService.java
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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;
}
}
77 changes: 0 additions & 77 deletions src/main/java/com/easypost/service/ShipmentService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -139,23 +138,6 @@ public Shipment newRates(final String id, final Map<String, Object> 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<SmartRate> getSmartrates(final String id, final Map<String, Object> params)
throws EasyPostException {
return this.smartrates(id, params);
}

/**
* Get SmartRate for this Shipment.
*
Expand Down Expand Up @@ -300,28 +282,6 @@ public Shipment insure(final String id, final Map<String, Object> 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.
*
Expand All @@ -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<SmartRate> 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<SmartRate> smartRates,
int deliveryDay, String deliveryAccuracy) throws EasyPostException {
return findLowestSmartrate(smartRates, deliveryDay, SmartrateAccuracy.getByKeyName(deliveryAccuracy));
}

/**
* Find the lowest SmartRate from a list of SmartRates.
*
Expand Down
30 changes: 0 additions & 30 deletions src/main/java/com/easypost/service/UserService.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
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;

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 {
Expand Down Expand Up @@ -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<ApiKey> 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.
*
Expand Down
22 changes: 0 additions & 22 deletions src/main/java/com/easypost/utils/Utilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -139,27 +138,6 @@ public static Event validateWebhook(byte[] eventBody, Map<String, Object> 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<SmartRate> smartrates, int deliveryDay,
String deliveryAccuracy) throws EasyPostException {
return findLowestSmartrate(smartrates, deliveryDay, SmartrateAccuracy.getByKeyName(deliveryAccuracy));
}

/**
* Find the lowest Smartrate from a list of Smartrates.
*
Expand Down
18 changes: 0 additions & 18 deletions src/test/java/com/easypost/ShipmentTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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"));
}

/**
Expand Down Expand Up @@ -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);
});
}

/**
Expand Down