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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# CHANGELOG

## Next Release
## v8.3.0 (2025-11-10)

- Adds support for `UspsShipAccount`
- Adds `tracker.retrieveBatch` function
- Adds `verify_carrier` address param

## v8.2.0 (2025-06-18)

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Add this to your project's POM:
<dependency>
<groupId>com.easypost</groupId>
<artifactId>easypost-api-client</artifactId>
<version>8.2.0</version>
<version>8.3.0</version>
</dependency>
```

Expand All @@ -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:8.2.0"
implementation "com.easypost:easypost-api-client:8.3.0"
```

**NOTE:** [Google Gson](http://code.google.com/p/google-gson/) is required.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.2.0
8.3.0
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<groupId>com.easypost</groupId>
<artifactId>easypost-api-client</artifactId>

<version>8.2.0</version>
<version>8.3.0</version>
<packaging>jar</packaging>

<name>com.easypost:easypost-api-client</name>
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/com/easypost/service/AddressService.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ public Address create(final Map<String, Object> params) throws EasyPostException
wrappedParams.put("verify_strict", params.remove("verify_strict"));
}

if (params.containsKey("verify_carrier")) {
wrappedParams.put("verify_carrier", params.remove("verify_carrier"));
}

wrappedParams.put("address", params);

String endpoint = "addresses";
Expand Down Expand Up @@ -113,6 +117,11 @@ public AddressCollection apply(Map<String, Object> parameters) {
*/
public Address createAndVerify(final Map<String, Object> params) throws EasyPostException {
Map<String, Object> wrappedParams = new HashMap<String, Object>();

if (params.containsKey("verify_carrier")) {
wrappedParams.put("verify_carrier", params.remove("verify_carrier"));
}

wrappedParams.put("address", params);

String endpoint = "addresses/create_and_verify";
Expand Down
94 changes: 94 additions & 0 deletions src/test/cassettes/address/create_and_verify_carrier.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

94 changes: 94 additions & 0 deletions src/test/cassettes/address/create_verify_carrier.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions src/test/cassettes/address/error_address_creation.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

64 changes: 63 additions & 1 deletion src/test/java/com/easypost/AddressTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,73 @@ public void testVerify() throws EasyPostException {
@Test
public void testInvalidAddressCreation() throws EasyPostException {
vcr.setUpTest("error_address_creation");
Map<String, Object> params = new HashMap<>();
InvalidRequestError exception =
assertThrows(InvalidRequestError.class, () -> vcr.client.address.createAndVerify(null));
assertThrows(InvalidRequestError.class, () -> vcr.client.address.createAndVerify(params));

assertEquals("PARAMETER.REQUIRED", exception.getCode());
assertEquals(422, exception.getStatusCode());
assertEquals("Missing required parameter.", exception.getMessage());
}

/**
* Test creating an address with the verify_carrier param.
* We purposefully pass in slightly incorrect data to get the corrected address
* back once verified.
*
* @throws EasyPostException when the request fails.
*/
@Test
public void testCreateVerifyCarrier() throws EasyPostException {
vcr.setUpTest("create_verify_carrier");

Map<String, Object> addressData = Fixtures.incorrectAddress();

addressData.put("verify", true);
addressData.put("verify_carrier", "UPS");
Address address = vcr.client.address.create(addressData);

assertInstanceOf(Address.class, address);

AddressVerificationFieldError addressVerificationFieldErrorGetDelivery = address.getVerifications()
.getDelivery()
.getErrors()
.get(0);
AddressVerificationFieldError addressVerificationFieldErrorZip4 = address.getVerifications()
.getZip4()
.getErrors()
.get(0);
assertEquals("Address not found", addressVerificationFieldErrorGetDelivery.getMessage());
assertEquals("Address not found", addressVerificationFieldErrorZip4.getMessage());
}

/**
* Test creating and verifying an address with the verify_carrier param.
* We purposefully pass in slightly incorrect data to get the corrected address
* back once verified.
*
* @throws EasyPostException when the request fails.
*/
@Test
public void testCreateAndVerifyCarrier() throws EasyPostException {
vcr.setUpTest("create_and_verify_carrier");

Map<String, Object> addressData = Fixtures.incorrectAddress();

addressData.put("verify_carrier", "UPS");
Address address = vcr.client.address.createAndVerify(addressData);

assertInstanceOf(Address.class, address);

AddressVerificationFieldError addressVerificationFieldErrorGetDelivery = address.getVerifications()
.getDelivery()
.getErrors()
.get(0);
AddressVerificationFieldError addressVerificationFieldErrorZip4 = address.getVerifications()
.getZip4()
.getErrors()
.get(0);
assertEquals("Address not found", addressVerificationFieldErrorGetDelivery.getMessage());
assertEquals("Address not found", addressVerificationFieldErrorZip4.getMessage());
}
}
Loading