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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## v10.0.1 (2025-05-27)

- Corrects the endpoint used for creating/updating UPS accounts

## v10.0.0 (2025-04-28)

See our [Upgrade Guide](UPGRADE_GUIDE.md#upgrading-from-9x-to-100) for more details.
Expand Down
5 changes: 1 addition & 4 deletions easypost/constant.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# flake8: noqa
# Library version
VERSION = "10.0.0"
VERSION = "10.0.1"
VERSION_INFO = [str(number) for number in VERSION.split(".")]

# Client defaults
Expand Down Expand Up @@ -38,11 +38,8 @@
]
_CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH = [
"AmazonShippingAccount",
]
_UPS_OAUTH_CARRIER_ACCOUNT_TYPES = [
"UpsAccount",
"UpsMailInnovationsAccount",
"UpsSurepostAccount",
]
_FILTERS_KEY = "filters"
_EXCLUDED_CLASS_NAMES = ["ups_oauth_registrations"]
5 changes: 1 addition & 4 deletions easypost/services/base_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
)

from easypost.constant import (
_EXCLUDED_CLASS_NAMES,
_FILTERS_KEY,
NO_MORE_PAGES_ERROR,
)
Expand All @@ -30,9 +29,7 @@ def _snakecase_name(self, class_name: str) -> str:
def _class_url(self, class_name: str) -> str:
"""Generate a URL based on class name."""
transformed_class_name = self._snakecase_name(class_name)
if transformed_class_name in _EXCLUDED_CLASS_NAMES:
return f"/{transformed_class_name}"
elif transformed_class_name[-1:] in ("s", "h"):
if transformed_class_name[-1:] in ("s", "h"):
return f"/{transformed_class_name}es"
else:
return f"/{transformed_class_name}s"
Expand Down
16 changes: 2 additions & 14 deletions easypost/services/carrier_account_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from easypost.constant import (
_CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH,
_CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_WORKFLOWS,
_UPS_OAUTH_CARRIER_ACCOUNT_TYPES,
MISSING_PARAMETER_ERROR,
)
from easypost.easypost_object import convert_to_easypost_object
Expand All @@ -32,9 +31,7 @@ def create(self, **params) -> CarrierAccount:
raise MissingParameterError(MISSING_PARAMETER_ERROR.format("type"))

url = self._select_carrier_account_creation_endpoint(carrier_account_type=carrier_account_type)
if carrier_account_type in _UPS_OAUTH_CARRIER_ACCOUNT_TYPES:
wrapped_params = {"ups_oauth_registrations": params}
elif carrier_account_type in _CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH:
if carrier_account_type in _CARRIER_ACCOUNT_TYPES_WITH_CUSTOM_OAUTH:
wrapped_params = {"carrier_account_oauth_registrations": params}
else:
wrapped_params = {self._snakecase_name(self._model_class): params}
Expand All @@ -53,14 +50,7 @@ def retrieve(self, id: str) -> CarrierAccount:

def update(self, id: str, **params) -> CarrierAccount:
"""Update a CarrierAccount."""
carrier_account = self.retrieve(id)

if carrier_account.get("type") in _UPS_OAUTH_CARRIER_ACCOUNT_TYPES:
class_name = "UpsOauthRegistrations"
else:
class_name = self._model_class

return self._update_resource(class_name, id, **params)
return self._update_resource(self._model_class, id, **params)

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

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

setup(
name="easypost",
version="10.0.0",
version="10.0.1",
description="EasyPost Shipping API Client Library for Python",
author="EasyPost",
author_email="support@easypost.com",
Expand Down
37 changes: 19 additions & 18 deletions tests/cassettes/test_carrier_account_create_ups.yaml

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

Loading