Skip to content

Commit 21965d9

Browse files
authored
Merge pull request #373 from EasyPost/SHPE-484_verify_carrier
feat: adds verify_carrier address param
2 parents 0e6782f + 92a279a commit 21965d9

File tree

7 files changed

+201
-5
lines changed

7 files changed

+201
-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+
## v10.2.0 (2025-11-10)
44

55
- Adds `UspsShipAccount` support to the create carrier method
66
- Adds `tracker.retrieve_batch` function
7+
- Adds `verify_carrier` address param
78

89
## v10.1.0 (2025-06-18)
910

easypost/constant.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# flake8: noqa
22
# Library version
3-
VERSION = "10.1.0"
3+
VERSION = "10.2.0"
44
VERSION_INFO = [str(number) for number in VERSION.split(".")]
55

66
# Client defaults

easypost/services/address_service.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def create(
2121
self,
2222
verify: Optional[bool] = None,
2323
verify_strict: Optional[bool] = None,
24+
verify_carrier: Optional[str] = None,
2425
**params,
2526
) -> Address:
2627
"""Create an Address."""
@@ -31,6 +32,8 @@ def create(
3132
wrapped_params["verify"] = verify
3233
if verify_strict:
3334
wrapped_params["verify_strict"] = verify_strict
35+
if verify_carrier:
36+
wrapped_params["verify_carrier"] = verify_carrier
3437

3538
response = Requestor(self._client).request(method=RequestMethod.POST, url=url, params=wrapped_params)
3639

@@ -48,10 +51,13 @@ def retrieve(self, id) -> Address:
4851
"""Retrieve an Address."""
4952
return self._retrieve_resource(self._model_class, id)
5053

51-
def create_and_verify(self, **params) -> Address:
54+
def create_and_verify(self, verify_carrier: Optional[str] = None, **params) -> Address:
5255
"""Create and verify an Address in one call."""
5356
url = f"{self._class_url('address')}/create_and_verify"
54-
wrapped_params = {self._snakecase_name(self._model_class): params}
57+
wrapped_params = {self._snakecase_name(self._model_class): params} # type: dict[str, Any]
58+
59+
if verify_carrier:
60+
wrapped_params["verify_carrier"] = verify_carrier
5561

5662
response = Requestor(self._client).request(method=RequestMethod.POST, url=url, params=wrapped_params)
5763

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
setup(
2929
name="easypost",
30-
version="10.1.0",
30+
version="10.2.0",
3131
description="EasyPost Shipping API Client Library for Python",
3232
author="EasyPost",
3333
author_email="[email protected]",

tests/cassettes/test_address_create_and_verify_carrier.yaml

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

tests/cassettes/test_address_create_verify_carrier.yaml

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

tests/test_address.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,3 +155,28 @@ def test_address_verify_invalid_address(test_client):
155155
test_client.address.verify(address.id)
156156

157157
assert str(error.value) == "Unable to verify address."
158+
159+
160+
@pytest.mark.vcr()
161+
def test_address_create_verify_carrier(incorrect_address, test_client):
162+
"""Test creating an address with the `verify_carrier` param."""
163+
incorrect_address["verify"] = True
164+
incorrect_address["verify_carrier"] = "UPS"
165+
address = test_client.address.create(**incorrect_address)
166+
167+
assert isinstance(address, Address)
168+
169+
assert address.verifications.delivery.errors[0].message == "Address not found"
170+
assert address.verifications.zip4.errors[0].message == "Address not found"
171+
172+
173+
@pytest.mark.vcr()
174+
def test_address_create_and_verify_carrier(incorrect_address, test_client):
175+
"""Test creating and verifying an address with the `verify_carrier` param."""
176+
incorrect_address["verify_carrier"] = "UPS"
177+
address = test_client.address.create_and_verify(**incorrect_address)
178+
179+
assert isinstance(address, Address)
180+
181+
assert address.verifications.delivery.errors[0].message == "Address not found"
182+
assert address.verifications.zip4.errors[0].message == "Address not found"

0 commit comments

Comments
 (0)