From 322d627ff71289abf31b571af5fc1633cd517b27 Mon Sep 17 00:00:00 2001
From: Justintime50 <39606064+Justintime50@users.noreply.github.com>
Date: Fri, 7 Nov 2025 11:33:23 -0700
Subject: [PATCH] feat: add verify_carrier address param
---
CHANGELOG.md | 3 +-
README.md | 4 +-
VERSION | 2 +-
pom.xml | 2 +-
.../com/easypost/service/AddressService.java | 9 ++
.../address/create_and_verify_carrier.json | 94 +++++++++++++++++++
.../address/create_verify_carrier.json | 94 +++++++++++++++++++
.../address/error_address_creation.json | 18 ++--
src/test/java/com/easypost/AddressTest.java | 64 ++++++++++++-
9 files changed, 275 insertions(+), 15 deletions(-)
create mode 100644 src/test/cassettes/address/create_and_verify_carrier.json
create mode 100644 src/test/cassettes/address/create_verify_carrier.json
diff --git a/CHANGELOG.md b/CHANGELOG.md
index cb72770da..2b032a15b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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)
diff --git a/README.md b/README.md
index ec4abf695..6454ab37d 100644
--- a/README.md
+++ b/README.md
@@ -16,7 +16,7 @@ Add this to your project's POM:
com.easypost
easypost-api-client
- 8.2.0
+ 8.3.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:8.2.0"
+implementation "com.easypost:easypost-api-client:8.3.0"
```
**NOTE:** [Google Gson](http://code.google.com/p/google-gson/) is required.
diff --git a/VERSION b/VERSION
index fbb9ea12d..2bf50aaf1 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-8.2.0
+8.3.0
diff --git a/pom.xml b/pom.xml
index 10c0cb6e1..a85b92e20 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
com.easypost
easypost-api-client
- 8.2.0
+ 8.3.0
jar
com.easypost:easypost-api-client
diff --git a/src/main/java/com/easypost/service/AddressService.java b/src/main/java/com/easypost/service/AddressService.java
index dd0824d2e..1ad0697c5 100644
--- a/src/main/java/com/easypost/service/AddressService.java
+++ b/src/main/java/com/easypost/service/AddressService.java
@@ -43,6 +43,10 @@ public Address create(final Map 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";
@@ -113,6 +117,11 @@ public AddressCollection apply(Map parameters) {
*/
public Address createAndVerify(final Map params) throws EasyPostException {
Map wrappedParams = new HashMap();
+
+ if (params.containsKey("verify_carrier")) {
+ wrappedParams.put("verify_carrier", params.remove("verify_carrier"));
+ }
+
wrappedParams.put("address", params);
String endpoint = "addresses/create_and_verify";
diff --git a/src/test/cassettes/address/create_and_verify_carrier.json b/src/test/cassettes/address/create_and_verify_carrier.json
new file mode 100644
index 000000000..eced704d3
--- /dev/null
+++ b/src/test/cassettes/address/create_and_verify_carrier.json
@@ -0,0 +1,94 @@
+[
+ {
+ "recordedAt": 1762540176,
+ "request": {
+ "body": "{\n \"address\": {\n \"zip\": \"00001\",\n \"country\": \"US\",\n \"city\": \"Not A City\",\n \"phone\": \"REDACTED\",\n \"company\": \"EasyPost\",\n \"street1\": \"000 unknown street\",\n \"state\": \"ZZ\",\n \"email\": \"test@example.com\"\n },\n \"verify_carrier\": \"UPS\"\n}",
+ "method": "POST",
+ "headers": {
+ "Accept-Charset": [
+ "UTF-8"
+ ],
+ "User-Agent": [
+ "REDACTED"
+ ],
+ "Content-Type": [
+ "application/json"
+ ]
+ },
+ "uri": "https://api.easypost.com/v2/addresses/create_and_verify"
+ },
+ "response": {
+ "body": "{\n \"address\": {\n \"zip\": \"00001\",\n \"country\": \"US\",\n \"city\": \"NOT A CITY\",\n \"created_at\": \"2025-11-07T18:29:36Z\",\n \"verifications\": {\n \"delivery\": {\n \"success\": true,\n \"details\": {\n \"latitude\": null,\n \"time_zone\": null,\n \"longitude\": null\n },\n \"errors\": [\n {\n \"code\": \"E.ADDRESS.NOT_FOUND\",\n \"field\": \"address\",\n \"suggestion\": null,\n \"message\": \"Address not found\"\n }\n ]\n },\n \"verify_carrier\": \"ups\",\n \"zip4\": {\n \"success\": true,\n \"details\": null,\n \"errors\": [\n {\n \"code\": \"E.ADDRESS.NOT_FOUND\",\n \"field\": \"address\",\n \"suggestion\": null,\n \"message\": \"Address not found\"\n }\n ]\n }\n },\n \"mode\": \"test\",\n \"federal_tax_id\": null,\n \"state_tax_id\": null,\n \"carrier_facility\": null,\n \"residential\": null,\n \"updated_at\": \"2025-11-07T18:29:36Z\",\n \"phone\": \"REDACTED\",\n \"name\": null,\n \"company\": \"EASYPOST\",\n \"street1\": \"000 UNKNOWN STREET\",\n \"id\": \"adr_b6c1cfd0bc0711f0ac45ac1f6bc539ae\",\n \"street2\": \"\",\n \"state\": \"ZZ\",\n \"email\": \"TEST@EXAMPLE.COM\",\n \"object\": \"Address\"\n }\n}",
+ "httpVersion": null,
+ "headers": {
+ "null": [
+ "HTTP/1.1 200 OK"
+ ],
+ "content-length": [
+ "820"
+ ],
+ "expires": [
+ "0"
+ ],
+ "x-node": [
+ "bigweb42nuq"
+ ],
+ "x-frame-options": [
+ "SAMEORIGIN"
+ ],
+ "x-download-options": [
+ "noopen"
+ ],
+ "x-permitted-cross-domain-policies": [
+ "none"
+ ],
+ "x-backend": [
+ "easypost"
+ ],
+ "pragma": [
+ "no-cache"
+ ],
+ "strict-transport-security": [
+ "max-age\u003d31536000; includeSubDomains; preload"
+ ],
+ "x-xss-protection": [
+ "1; mode\u003dblock"
+ ],
+ "x-content-type-options": [
+ "nosniff"
+ ],
+ "x-ep-request-uuid": [
+ "bcd43725690e3a8fe786bc4002abc67c"
+ ],
+ "x-proxied": [
+ "intlb6nuq c0061e0a2e",
+ "extlb2nuq cbbd141214"
+ ],
+ "referrer-policy": [
+ "strict-origin-when-cross-origin"
+ ],
+ "x-runtime": [
+ "0.795785"
+ ],
+ "location": [
+ "/api/v2/addresses/adr_b6c1cfd0bc0711f0ac45ac1f6bc539ae"
+ ],
+ "content-type": [
+ "application/json; charset\u003dutf-8"
+ ],
+ "x-version-label": [
+ "easypost-202511071754-85836cab32-master"
+ ],
+ "cache-control": [
+ "private, no-cache, no-store"
+ ]
+ },
+ "status": {
+ "code": 200,
+ "message": "OK"
+ },
+ "uri": "https://api.easypost.com/v2/addresses/create_and_verify"
+ },
+ "duration": 968
+ }
+]
\ No newline at end of file
diff --git a/src/test/cassettes/address/create_verify_carrier.json b/src/test/cassettes/address/create_verify_carrier.json
new file mode 100644
index 000000000..c68a1aa0e
--- /dev/null
+++ b/src/test/cassettes/address/create_verify_carrier.json
@@ -0,0 +1,94 @@
+[
+ {
+ "recordedAt": 1762540174,
+ "request": {
+ "body": "{\n \"address\": {\n \"zip\": \"00001\",\n \"country\": \"US\",\n \"city\": \"Not A City\",\n \"phone\": \"REDACTED\",\n \"company\": \"EasyPost\",\n \"street1\": \"000 unknown street\",\n \"state\": \"ZZ\",\n \"email\": \"test@example.com\"\n },\n \"verify\": true,\n \"verify_carrier\": \"UPS\"\n}",
+ "method": "POST",
+ "headers": {
+ "Accept-Charset": [
+ "UTF-8"
+ ],
+ "User-Agent": [
+ "REDACTED"
+ ],
+ "Content-Type": [
+ "application/json"
+ ]
+ },
+ "uri": "https://api.easypost.com/v2/addresses"
+ },
+ "response": {
+ "body": "{\n \"zip\": \"00001\",\n \"country\": \"US\",\n \"city\": \"NOT A CITY\",\n \"created_at\": \"2025-11-07T18:29:35Z\",\n \"verifications\": {\n \"delivery\": {\n \"success\": true,\n \"details\": {\n \"latitude\": null,\n \"time_zone\": null,\n \"longitude\": null\n },\n \"errors\": [\n {\n \"code\": \"E.ADDRESS.NOT_FOUND\",\n \"field\": \"address\",\n \"suggestion\": null,\n \"message\": \"Address not found\"\n }\n ]\n },\n \"verify_carrier\": \"ups\",\n \"zip4\": {\n \"success\": true,\n \"details\": null,\n \"errors\": [\n {\n \"code\": \"E.ADDRESS.NOT_FOUND\",\n \"field\": \"address\",\n \"suggestion\": null,\n \"message\": \"Address not found\"\n }\n ]\n }\n },\n \"mode\": \"test\",\n \"federal_tax_id\": null,\n \"state_tax_id\": null,\n \"carrier_facility\": null,\n \"residential\": null,\n \"updated_at\": \"2025-11-07T18:29:35Z\",\n \"phone\": \"REDACTED\",\n \"name\": null,\n \"company\": \"EASYPOST\",\n \"street1\": \"000 UNKNOWN STREET\",\n \"id\": \"adr_b5db9a37bc0711f0967fac1f6bc53342\",\n \"street2\": \"\",\n \"state\": \"ZZ\",\n \"email\": \"TEST@EXAMPLE.COM\",\n \"object\": \"Address\"\n}",
+ "httpVersion": null,
+ "headers": {
+ "null": [
+ "HTTP/1.1 201 Created"
+ ],
+ "content-length": [
+ "808"
+ ],
+ "expires": [
+ "0"
+ ],
+ "x-node": [
+ "bigweb53nuq"
+ ],
+ "x-frame-options": [
+ "SAMEORIGIN"
+ ],
+ "x-download-options": [
+ "noopen"
+ ],
+ "x-permitted-cross-domain-policies": [
+ "none"
+ ],
+ "x-backend": [
+ "easypost"
+ ],
+ "pragma": [
+ "no-cache"
+ ],
+ "strict-transport-security": [
+ "max-age\u003d31536000; includeSubDomains; preload"
+ ],
+ "x-xss-protection": [
+ "1; mode\u003dblock"
+ ],
+ "x-content-type-options": [
+ "nosniff"
+ ],
+ "x-ep-request-uuid": [
+ "bcd43726690e3a8ee786bc3b02abc094"
+ ],
+ "x-proxied": [
+ "intlb6nuq c0061e0a2e",
+ "extlb2nuq cbbd141214"
+ ],
+ "referrer-policy": [
+ "strict-origin-when-cross-origin"
+ ],
+ "x-runtime": [
+ "0.780863"
+ ],
+ "location": [
+ "/api/v2/addresses/adr_b5db9a37bc0711f0967fac1f6bc53342"
+ ],
+ "content-type": [
+ "application/json; charset\u003dutf-8"
+ ],
+ "x-version-label": [
+ "easypost-202511071754-85836cab32-master"
+ ],
+ "cache-control": [
+ "private, no-cache, no-store"
+ ]
+ },
+ "status": {
+ "code": 201,
+ "message": "Created"
+ },
+ "uri": "https://api.easypost.com/v2/addresses"
+ },
+ "duration": 998
+ }
+]
\ No newline at end of file
diff --git a/src/test/cassettes/address/error_address_creation.json b/src/test/cassettes/address/error_address_creation.json
index 2d71a45e7..9d777e7e1 100644
--- a/src/test/cassettes/address/error_address_creation.json
+++ b/src/test/cassettes/address/error_address_creation.json
@@ -1,8 +1,8 @@
[
{
- "recordedAt": 1723823867,
+ "recordedAt": 1762540339,
"request": {
- "body": "{}",
+ "body": "{\n \"address\": {}\n}",
"method": "POST",
"headers": {
"Accept-Charset": [
@@ -31,7 +31,7 @@
"0"
],
"x-node": [
- "bigweb38nuq"
+ "bigweb67nuq"
],
"x-frame-options": [
"SAMEORIGIN"
@@ -58,23 +58,23 @@
"nosniff"
],
"x-ep-request-uuid": [
- "8a4bf43c66bf76fbe786bd270035cdd0"
+ "bcd43726690e3b33e786c9e602acee37"
],
"x-proxied": [
- "intlb3nuq c0f5e722d1",
- "extlb1nuq b6e1b5034c"
+ "intlb4nuq c0061e0a2e",
+ "extlb2nuq cbbd141214"
],
"referrer-policy": [
"strict-origin-when-cross-origin"
],
"x-runtime": [
- "0.020909"
+ "0.018362"
],
"content-type": [
"application/json; charset\u003dutf-8"
],
"x-version-label": [
- "easypost-202408152333-48cda4a73e-master"
+ "easypost-202511071754-85836cab32-master"
],
"cache-control": [
"private, no-cache, no-store"
@@ -86,6 +86,6 @@
},
"uri": "https://api.easypost.com/v2/addresses/create_and_verify"
},
- "duration": 227
+ "duration": 199
}
]
\ No newline at end of file
diff --git a/src/test/java/com/easypost/AddressTest.java b/src/test/java/com/easypost/AddressTest.java
index 87b3dae58..1aa8ba8a0 100644
--- a/src/test/java/com/easypost/AddressTest.java
+++ b/src/test/java/com/easypost/AddressTest.java
@@ -278,11 +278,73 @@ public void testVerify() throws EasyPostException {
@Test
public void testInvalidAddressCreation() throws EasyPostException {
vcr.setUpTest("error_address_creation");
+ Map 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 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 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());
+ }
}