Skip to content

Commit 706d343

Browse files
authored
Merge pull request #359 from EasyPost/SHPE-484_verify_carrier
feat: add verify_carrier address param
2 parents 3dc4a0b + 322d627 commit 706d343

File tree

9 files changed

+275
-15
lines changed

9 files changed

+275
-15
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# CHANGELOG
22

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

55
- Adds support for `UspsShipAccount`
66
- Adds `tracker.retrieveBatch` function
7+
- Adds `verify_carrier` address param
78

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

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>8.2.0</version>
19+
<version>8.3.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:8.2.0"
28+
implementation "com.easypost:easypost-api-client:8.3.0"
2929
```
3030

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

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8.2.0
1+
8.3.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>8.2.0</version>
9+
<version>8.3.0</version>
1010
<packaging>jar</packaging>
1111

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

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ public Address create(final Map<String, Object> params) throws EasyPostException
4343
wrappedParams.put("verify_strict", params.remove("verify_strict"));
4444
}
4545

46+
if (params.containsKey("verify_carrier")) {
47+
wrappedParams.put("verify_carrier", params.remove("verify_carrier"));
48+
}
49+
4650
wrappedParams.put("address", params);
4751

4852
String endpoint = "addresses";
@@ -113,6 +117,11 @@ public AddressCollection apply(Map<String, Object> parameters) {
113117
*/
114118
public Address createAndVerify(final Map<String, Object> params) throws EasyPostException {
115119
Map<String, Object> wrappedParams = new HashMap<String, Object>();
120+
121+
if (params.containsKey("verify_carrier")) {
122+
wrappedParams.put("verify_carrier", params.remove("verify_carrier"));
123+
}
124+
116125
wrappedParams.put("address", params);
117126

118127
String endpoint = "addresses/create_and_verify";

src/test/cassettes/address/create_and_verify_carrier.json

Lines changed: 94 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/test/cassettes/address/create_verify_carrier.json

Lines changed: 94 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/test/cassettes/address/error_address_creation.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/test/java/com/easypost/AddressTest.java

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,11 +278,73 @@ public void testVerify() throws EasyPostException {
278278
@Test
279279
public void testInvalidAddressCreation() throws EasyPostException {
280280
vcr.setUpTest("error_address_creation");
281+
Map<String, Object> params = new HashMap<>();
281282
InvalidRequestError exception =
282-
assertThrows(InvalidRequestError.class, () -> vcr.client.address.createAndVerify(null));
283+
assertThrows(InvalidRequestError.class, () -> vcr.client.address.createAndVerify(params));
283284

284285
assertEquals("PARAMETER.REQUIRED", exception.getCode());
285286
assertEquals(422, exception.getStatusCode());
286287
assertEquals("Missing required parameter.", exception.getMessage());
287288
}
289+
290+
/**
291+
* Test creating an address with the verify_carrier param.
292+
* We purposefully pass in slightly incorrect data to get the corrected address
293+
* back once verified.
294+
*
295+
* @throws EasyPostException when the request fails.
296+
*/
297+
@Test
298+
public void testCreateVerifyCarrier() throws EasyPostException {
299+
vcr.setUpTest("create_verify_carrier");
300+
301+
Map<String, Object> addressData = Fixtures.incorrectAddress();
302+
303+
addressData.put("verify", true);
304+
addressData.put("verify_carrier", "UPS");
305+
Address address = vcr.client.address.create(addressData);
306+
307+
assertInstanceOf(Address.class, address);
308+
309+
AddressVerificationFieldError addressVerificationFieldErrorGetDelivery = address.getVerifications()
310+
.getDelivery()
311+
.getErrors()
312+
.get(0);
313+
AddressVerificationFieldError addressVerificationFieldErrorZip4 = address.getVerifications()
314+
.getZip4()
315+
.getErrors()
316+
.get(0);
317+
assertEquals("Address not found", addressVerificationFieldErrorGetDelivery.getMessage());
318+
assertEquals("Address not found", addressVerificationFieldErrorZip4.getMessage());
319+
}
320+
321+
/**
322+
* Test creating and verifying an address with the verify_carrier param.
323+
* We purposefully pass in slightly incorrect data to get the corrected address
324+
* back once verified.
325+
*
326+
* @throws EasyPostException when the request fails.
327+
*/
328+
@Test
329+
public void testCreateAndVerifyCarrier() throws EasyPostException {
330+
vcr.setUpTest("create_and_verify_carrier");
331+
332+
Map<String, Object> addressData = Fixtures.incorrectAddress();
333+
334+
addressData.put("verify_carrier", "UPS");
335+
Address address = vcr.client.address.createAndVerify(addressData);
336+
337+
assertInstanceOf(Address.class, address);
338+
339+
AddressVerificationFieldError addressVerificationFieldErrorGetDelivery = address.getVerifications()
340+
.getDelivery()
341+
.getErrors()
342+
.get(0);
343+
AddressVerificationFieldError addressVerificationFieldErrorZip4 = address.getVerifications()
344+
.getZip4()
345+
.getErrors()
346+
.get(0);
347+
assertEquals("Address not found", addressVerificationFieldErrorGetDelivery.getMessage());
348+
assertEquals("Address not found", addressVerificationFieldErrorZip4.getMessage());
349+
}
288350
}

0 commit comments

Comments
 (0)