Skip to content

Commit e9ffa69

Browse files
jchen293Justintime50
authored andcommitted
add update params
1 parent 04cfeb9 commit e9ffa69

File tree

5 files changed

+51
-45
lines changed

5 files changed

+51
-45
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- `BetaReferralCustomerService.create_bank_account_client_secret`
99
- `ReferralCustomerService.add_credit_card_from_stripe`
1010
- `ReferralCustomerService.add_bank_account_from_stripe`
11+
- Routes `AmazonShippingAccount` create requests to the new `/register_oauth` endpoint
1112
- Fixes the payload wrapping for updating a webhook
1213
- Removes deprecated `user.all_api_keys` and `user.api_keys`, use `api_key.all` and `api_key.retrieve_api_keys_for_user` respectively
1314
- Bumps all dev dependencies
@@ -16,7 +17,6 @@
1617

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

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

easypost/services/base_service.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ def _update_resource(
8585
"""Update an EasyPost object via the EasyPost API."""
8686
url = self._instance_url(class_name, id)
8787
wrapped_params = {self._snakecase_name(class_name): params}
88+
8889
response = Requestor(self._client).request(method=method, url=url, params=wrapped_params, beta=beta)
8990

9091
return convert_to_easypost_object(response=response)

easypost/services/carrier_account_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def update(self, id: str, **params) -> CarrierAccount:
6161
response = Requestor(self._client).request(
6262
method=RequestMethod.PATCH,
6363
url=f"/carrier_accounts/register_oauth/{id}",
64-
params={},
64+
params={"carrier_account_oauth_registrations": params},
6565
)
6666
return convert_to_easypost_object(response=response)
6767
else:

tests/cassettes/test_carrier_account_update_amazon_shipping.yaml

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

tests/test_carrier_account.py

Lines changed: 8 additions & 6 deletions
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)