Skip to content

Commit

Permalink
add update params
Browse files Browse the repository at this point in the history
  • Loading branch information
jchen293 committed Dec 16, 2024
1 parent 1825fe4 commit 2b48510
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 45 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# CHANGELOG

## Next Release

- Routes `AmazonShippingAccount` create/update requests to the new `/register_oauth` endpoint

## v9.5.0 (2024-10-24)

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

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

Expand Down
1 change: 1 addition & 0 deletions easypost/services/base_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def _update_resource(
"""Update an EasyPost object via the EasyPost API."""
url = self._instance_url(class_name, id)
wrapped_params = {self._snakecase_name(class_name): params}

response = Requestor(self._client).request(method=method, url=url, params=wrapped_params, beta=beta)

return convert_to_easypost_object(response=response)
Expand Down
2 changes: 1 addition & 1 deletion easypost/services/carrier_account_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def update(self, id: str, **params) -> CarrierAccount:
response = Requestor(self._client).request(
method=RequestMethod.PATCH,
url=f"/carrier_accounts/register_oauth/{id}",
params={},
params={"carrier_account_oauth_registrations": params},
)
return convert_to_easypost_object(response=response)
else:
Expand Down
77 changes: 40 additions & 37 deletions tests/cassettes/test_carrier_account_update_amazon_shipping.yaml

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

14 changes: 8 additions & 6 deletions tests/test_carrier_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,21 +157,23 @@ def test_carrier_account_create_amazon_shipping(prod_client):


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

amazon_shipping_account = prod_client.carrier_account.create(**params)
if not os.path.exists(os.path.join("tests", "cassettes", f"{function_name}.yaml")):
time.sleep(synchronous_sleep_seconds) # Wait enough time for updating the carrier account
updated_amazon_shipping_account = prod_client.carrier_account.update(amazon_shipping_account.id)

# TODO: Re-record this cassettes and add two assertions for description and reference when we made the changes in API level for update endpoint
updated_amazon_shipping_account = prod_client.carrier_account.update(
amazon_shipping_account.id,
description="test description",
reference="test reference",
)

assert isinstance(updated_amazon_shipping_account, CarrierAccount)
assert str.startswith(updated_amazon_shipping_account.id, "ca_")
assert amazon_shipping_account.updated_at != updated_amazon_shipping_account.updated_at

prod_client.carrier_account.delete(
amazon_shipping_account.id
Expand Down

0 comments on commit 2b48510

Please sign in to comment.