Skip to content

Commit 2b48510

Browse files
committed
add update params
1 parent 1825fe4 commit 2b48510

File tree

5 files changed

+54
-45
lines changed

5 files changed

+54
-45
lines changed

CHANGELOG.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
# CHANGELOG
22

3+
## Next Release
4+
5+
- Routes `AmazonShippingAccount` create/update requests to the new `/register_oauth` endpoint
6+
37
## v9.5.0 (2024-10-24)
48

59
- Adds `tracking_codes` as a parameter of the `all` method on the TrackerService
610
- Removes the deprecated `create_list` tracker endpoint function as it is no longer available via API
7-
- Routes `AmazonShippingAccount` create/update requests to the new `/register_oauth` endpoint
811

912
## v9.4.1 (2024-08-09)
1013

easypost/services/base_service.py

+1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ def _update_resource(
7777
"""Update an EasyPost object via the EasyPost API."""
7878
url = self._instance_url(class_name, id)
7979
wrapped_params = {self._snakecase_name(class_name): params}
80+
8081
response = Requestor(self._client).request(method=method, url=url, params=wrapped_params, beta=beta)
8182

8283
return convert_to_easypost_object(response=response)

easypost/services/carrier_account_service.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def update(self, id: str, **params) -> CarrierAccount:
6363
response = Requestor(self._client).request(
6464
method=RequestMethod.PATCH,
6565
url=f"/carrier_accounts/register_oauth/{id}",
66-
params={},
66+
params={"carrier_account_oauth_registrations": params},
6767
)
6868
return convert_to_easypost_object(response=response)
6969
else:

tests/cassettes/test_carrier_account_update_amazon_shipping.yaml

+40-37
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/test_carrier_account.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -157,21 +157,23 @@ def test_carrier_account_create_amazon_shipping(prod_client):
157157

158158

159159
@pytest.mark.vcr()
160-
def test_carrier_account_update_amazon_shipping(prod_client, synchronous_sleep_seconds):
160+
def test_carrier_account_update_amazon_shipping(prod_client):
161161
"""Test updating an Amazon Shipping Carrier Account which uses a different URL and schema."""
162-
function_name = inspect.stack()[0][3]
163162
params = {
164163
"type": "AmazonShippingAccount",
165164
}
166165

167166
amazon_shipping_account = prod_client.carrier_account.create(**params)
168-
if not os.path.exists(os.path.join("tests", "cassettes", f"{function_name}.yaml")):
169-
time.sleep(synchronous_sleep_seconds) # Wait enough time for updating the carrier account
170-
updated_amazon_shipping_account = prod_client.carrier_account.update(amazon_shipping_account.id)
167+
168+
# TODO: Re-record this cassettes and add two assertions for description and reference when we made the changes in API level for update endpoint
169+
updated_amazon_shipping_account = prod_client.carrier_account.update(
170+
amazon_shipping_account.id,
171+
description="test description",
172+
reference="test reference",
173+
)
171174

172175
assert isinstance(updated_amazon_shipping_account, CarrierAccount)
173176
assert str.startswith(updated_amazon_shipping_account.id, "ca_")
174-
assert amazon_shipping_account.updated_at != updated_amazon_shipping_account.updated_at
175177

176178
prod_client.carrier_account.delete(
177179
amazon_shipping_account.id

0 commit comments

Comments
 (0)