Skip to content

Commit 2e5273c

Browse files
authored
Merge pull request #370 from EasyPost/SHPE-484_verify_carrier
feat: verify_carrier address param
2 parents c01ffd8 + 88dd01d commit 2e5273c

File tree

7 files changed

+225
-5
lines changed

7 files changed

+225
-5
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

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "easypost/easypost-php",
33
"description": "EasyPost Shipping API Client Library for PHP",
4-
"version": "8.2.0",
4+
"version": "8.3.0",
55
"keywords": [
66
"shipping",
77
"api",

lib/EasyPost/Constant/Constants.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ abstract class Constants
1111
const BETA_API_VERSION = 'beta';
1212

1313
// Library constants
14-
const LIBRARY_VERSION = '8.2.0';
14+
const LIBRARY_VERSION = '8.3.0';
1515
const SUPPORT_EMAIL = 'support@easypost.com';
1616

1717
// Validation

lib/EasyPost/Service/AddressService.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ public function create(mixed $params = null): mixed
6666
$wrappedParams['verify_strict'] = $verifyStrict;
6767
}
6868

69+
if (isset($params['verify_carrier'])) {
70+
$verifyCarrier = $params['verify_carrier'];
71+
unset($params['verify_carrier']);
72+
$wrappedParams['verify_carrier'] = $verifyCarrier;
73+
}
74+
6975
$wrappedParams['address'] = $params;
7076

7177
return self::createResource(self::serviceModelClassName(self::class), $wrappedParams);
@@ -79,10 +85,18 @@ public function create(mixed $params = null): mixed
7985
*/
8086
public function createAndVerify(mixed $params = null): mixed
8187
{
82-
$params = InternalUtil::wrapParams($params, 'address');
88+
$wrappedParams = [];
89+
90+
if (isset($params['verify_carrier'])) {
91+
$verifyCarrier = $params['verify_carrier'];
92+
unset($params['verify_carrier']);
93+
$wrappedParams['verify_carrier'] = $verifyCarrier;
94+
}
95+
96+
$wrappedParams['address'] = $params;
8397

8498
$url = self::classUrl(self::serviceModelClassName(self::class));
85-
$response = Requestor::request($this->client, 'post', $url . '/create_and_verify', $params);
99+
$response = Requestor::request($this->client, 'post', $url . '/create_and_verify', $wrappedParams);
86100

87101
return InternalUtil::convertToEasyPostObject($this->client, $response['address']);
88102
}

test/EasyPost/AddressTest.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,4 +233,45 @@ public function testVerifyInvalid(): void
233233
$this->assertEquals('Unable to verify address.', $error->getMessage());
234234
}
235235
}
236+
237+
/**
238+
* Test creating a verified address with verify_carrier.
239+
*
240+
* We purposefully pass in slightly incorrect data to get the corrected address back once verified.
241+
*/
242+
public function testCreateVerifyCarrier(): void
243+
{
244+
TestUtil::setupCassette('addresses/createVerifyCarrier.yml');
245+
246+
$addressData = Fixture::incorrectAddress();
247+
248+
$addressData['verify'] = true;
249+
$addressData['verify_carrier'] = 'UPS';
250+
$address = self::$client->address->create($addressData);
251+
252+
$this->assertInstanceOf(Address::class, $address);
253+
254+
$this->assertEquals('Address not found', $address->verifications->delivery->errors[0]->message);
255+
$this->assertEquals('Address not found', $address->verifications->zip4->errors[0]->message);
256+
}
257+
258+
/**
259+
* Test creating a verified address with verify_carrier.
260+
*
261+
* We purposefully pass in slightly incorrect data to get the corrected address back once verified.
262+
*/
263+
public function testCreateAndVerifyCarrier(): void
264+
{
265+
TestUtil::setupCassette('addresses/createAndVerifyCarrier.yml');
266+
267+
$addressData = Fixture::incorrectAddress();
268+
269+
$addressData['verify_carrier'] = 'UPS';
270+
$address = self::$client->address->createAndVerify($addressData);
271+
272+
$this->assertInstanceOf(Address::class, $address);
273+
274+
$this->assertEquals('Address not found', $address->verifications->delivery->errors[0]->message);
275+
$this->assertEquals('Address not found', $address->verifications->zip4->errors[0]->message);
276+
}
236277
}

test/cassettes/addresses/createAndVerifyCarrier.yml

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

test/cassettes/addresses/createVerifyCarrier.yml

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

0 commit comments

Comments
 (0)