Skip to content

Commit 26cb437

Browse files
authored
Merge pull request #361 from EasyPost/ups_endpoint
fix: endpoint used for UPS create/update
2 parents e32365b + cd3d914 commit 26cb437

File tree

8 files changed

+59
-136
lines changed

8 files changed

+59
-136
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# CHANGELOG
22

3+
## v10.0.1 (2025-05-27)
4+
5+
- Corrects the endpoint used for creating/updating UPS accounts
6+
37
## v10.0.0 (2025-04-28)
48

59
See our [Upgrade Guide](UPGRADE_GUIDE.md#upgrading-from-9x-to-100) for more details.

easypost/constant.py

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

66
# Client defaults
@@ -38,11 +38,8 @@
3838
]
3939
_CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH = [
4040
"AmazonShippingAccount",
41-
]
42-
_UPS_OAUTH_CARRIER_ACCOUNT_TYPES = [
4341
"UpsAccount",
4442
"UpsMailInnovationsAccount",
4543
"UpsSurepostAccount",
4644
]
4745
_FILTERS_KEY = "filters"
48-
_EXCLUDED_CLASS_NAMES = ["ups_oauth_registrations"]

easypost/services/base_service.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
)
66

77
from easypost.constant import (
8-
_EXCLUDED_CLASS_NAMES,
98
_FILTERS_KEY,
109
NO_MORE_PAGES_ERROR,
1110
)
@@ -30,9 +29,7 @@ def _snakecase_name(self, class_name: str) -> str:
3029
def _class_url(self, class_name: str) -> str:
3130
"""Generate a URL based on class name."""
3231
transformed_class_name = self._snakecase_name(class_name)
33-
if transformed_class_name in _EXCLUDED_CLASS_NAMES:
34-
return f"/{transformed_class_name}"
35-
elif transformed_class_name[-1:] in ("s", "h"):
32+
if transformed_class_name[-1:] in ("s", "h"):
3633
return f"/{transformed_class_name}es"
3734
else:
3835
return f"/{transformed_class_name}s"

easypost/services/carrier_account_service.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from easypost.constant import (
77
_CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH,
88
_CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_WORKFLOWS,
9-
_UPS_OAUTH_CARRIER_ACCOUNT_TYPES,
109
MISSING_PARAMETER_ERROR,
1110
)
1211
from easypost.easypost_object import convert_to_easypost_object
@@ -32,9 +31,7 @@ def create(self, **params) -> CarrierAccount:
3231
raise MissingParameterError(MISSING_PARAMETER_ERROR.format("type"))
3332

3433
url = self._select_carrier_account_creation_endpoint(carrier_account_type=carrier_account_type)
35-
if carrier_account_type in _UPS_OAUTH_CARRIER_ACCOUNT_TYPES:
36-
wrapped_params = {"ups_oauth_registrations": params}
37-
elif carrier_account_type in _CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH:
34+
if carrier_account_type in _CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH:
3835
wrapped_params = {"carrier_account_oauth_registrations": params}
3936
else:
4037
wrapped_params = {self._snakecase_name(self._model_class): params}
@@ -53,14 +50,7 @@ def retrieve(self, id: str) -> CarrierAccount:
5350

5451
def update(self, id: str, **params) -> CarrierAccount:
5552
"""Update a CarrierAccount."""
56-
carrier_account = self.retrieve(id)
57-
58-
if carrier_account.get("type") in _UPS_OAUTH_CARRIER_ACCOUNT_TYPES:
59-
class_name = "UpsOauthRegistrations"
60-
else:
61-
class_name = self._model_class
62-
63-
return self._update_resource(class_name, id, **params)
53+
return self._update_resource(self._model_class, id, **params)
6454

6555
def delete(self, id: str) -> None:
6656
"""Delete a CarrierAccount."""
@@ -76,8 +66,6 @@ def _select_carrier_account_creation_endpoint(self, carrier_account_type: Option
7666
"""Determines which API endpoint to use for the creation call."""
7767
if carrier_account_type in _CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_WORKFLOWS:
7868
return "/carrier_accounts/register"
79-
elif carrier_account_type in _UPS_OAUTH_CARRIER_ACCOUNT_TYPES:
80-
return "/ups_oauth_registrations"
8169
elif carrier_account_type in _CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH:
8270
return "/carrier_accounts/register_oauth"
8371

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.0.0",
30+
version="10.0.1",
3131
description="EasyPost Shipping API Client Library for Python",
3232
author="EasyPost",
3333
author_email="[email protected]",

tests/cassettes/test_carrier_account_create_ups.yaml

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

0 commit comments

Comments
 (0)