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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "easypost/easypost-php",
"description": "EasyPost Shipping API Client Library for PHP",
"version": "8.2.0",
"version": "8.3.0",
"keywords": [
"shipping",
"api",
Expand Down
2 changes: 1 addition & 1 deletion lib/EasyPost/Constant/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ abstract class Constants
const BETA_API_VERSION = 'beta';

// Library constants
const LIBRARY_VERSION = '8.2.0';
const LIBRARY_VERSION = '8.3.0';
const SUPPORT_EMAIL = 'support@easypost.com';

// Validation
Expand Down
18 changes: 16 additions & 2 deletions lib/EasyPost/Service/AddressService.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ public function create(mixed $params = null): mixed
$wrappedParams['verify_strict'] = $verifyStrict;
}

if (isset($params['verify_carrier'])) {
$verifyCarrier = $params['verify_carrier'];
unset($params['verify_carrier']);
$wrappedParams['verify_carrier'] = $verifyCarrier;
}

$wrappedParams['address'] = $params;

return self::createResource(self::serviceModelClassName(self::class), $wrappedParams);
Expand All @@ -79,10 +85,18 @@ public function create(mixed $params = null): mixed
*/
public function createAndVerify(mixed $params = null): mixed
{
$params = InternalUtil::wrapParams($params, 'address');
$wrappedParams = [];

if (isset($params['verify_carrier'])) {
$verifyCarrier = $params['verify_carrier'];
unset($params['verify_carrier']);
$wrappedParams['verify_carrier'] = $verifyCarrier;
}

$wrappedParams['address'] = $params;

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

return InternalUtil::convertToEasyPostObject($this->client, $response['address']);
}
Expand Down
41 changes: 41 additions & 0 deletions test/EasyPost/AddressTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,4 +233,45 @@ public function testVerifyInvalid(): void
$this->assertEquals('Unable to verify address.', $error->getMessage());
}
}

/**
* Test creating a verified address with verify_carrier.
*
* We purposefully pass in slightly incorrect data to get the corrected address back once verified.
*/
public function testCreateVerifyCarrier(): void
{
TestUtil::setupCassette('addresses/createVerifyCarrier.yml');

$addressData = Fixture::incorrectAddress();

$addressData['verify'] = true;
$addressData['verify_carrier'] = 'UPS';
$address = self::$client->address->create($addressData);

$this->assertInstanceOf(Address::class, $address);

$this->assertEquals('Address not found', $address->verifications->delivery->errors[0]->message);
$this->assertEquals('Address not found', $address->verifications->zip4->errors[0]->message);
}

/**
* Test creating a verified address with verify_carrier.
*
* We purposefully pass in slightly incorrect data to get the corrected address back once verified.
*/
public function testCreateAndVerifyCarrier(): void
{
TestUtil::setupCassette('addresses/createAndVerifyCarrier.yml');

$addressData = Fixture::incorrectAddress();

$addressData['verify_carrier'] = 'UPS';
$address = self::$client->address->createAndVerify($addressData);

$this->assertInstanceOf(Address::class, $address);

$this->assertEquals('Address not found', $address->verifications->delivery->errors[0]->message);
$this->assertEquals('Address not found', $address->verifications->zip4->errors[0]->message);
}
}
82 changes: 82 additions & 0 deletions test/cassettes/addresses/createAndVerifyCarrier.yml

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

82 changes: 82 additions & 0 deletions test/cassettes/addresses/createVerifyCarrier.yml

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

Loading