Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[carrier_accounts] Creation and listing Warning operations.ListCarrierAccountsRequest #61

Closed
jfriedr opened this issue May 17, 2024 · 3 comments

Comments

@jfriedr
Copy link

jfriedr commented May 17, 2024

Warning is being thrown when creating or listing an account using something like the following:

import shippo
from shippo.models import components, operations

from shippo.debug import DebugSession
#debug_session = DebugSession()

shippo_api_key = '<SHIPPO_API_KEY>'

s = shippo.Shippo(api_key_header=shippo_api_key)

req = components.ConnectExistingOwnAccountRequest(
    account_id='<account_number>',
    carrier='dhl_ecommerce',
    parameters={"api_version": 4, "username": "<client_id>", "password": "<client_password>", "pickup_no": "<dhl_pickup_no>", "facility_code": "<facility_code>"},
    metadata='DHLEcomTestAccount',
    active=False,
    test=False,
)

car_req = operations.ListCarrierAccountsRequest(carrier='dhl_ecommerce')

try:
    car = s.carrier_accounts.list(car_req)
    for x in car.results:
        print(f'carrier_account number: {x.account_id}\nobject_id: {x.object_id}')
except shippo.models.errors.sdkerror.SDKError:
    print(f'There was an exception' )

The warning presented is:

/Users/xxxx/hippo/pip_examples/sdk_venv/lib/python3.11/site-packages/dataclasses_json/core.py:336: UserWarning: Failed to decode {'access_token': '******', 'valid_until': '******', 'expires_in': '******', 'username': 'xxxxxx', 'password': '******', 'pickup_no': 'xxxxxx', 'facility_code': 'xxxxxxx'} Union dataclasses.Expected Union to include a matching dataclass and it didn't.
  warnings.warn(
/Users/xxxx/hippo/pip_examples/sdk_venv/lib/python3.11/site-packages/dataclasses_json/core.py:336: UserWarning: Failed to decode {'access_token': '******', 'valid_until': '******', 'expires_in': '******', 'username': 'xxxxxxxx', 'password': '******', 'pickup_no': 'xxxxxxx', 'facility_code': 'xxxxxxxx'} Union dataclasses.Expected Union to include a matching dataclass and it didn't.
  warnings.warn(
@rkeur7
Copy link
Contributor

rkeur7 commented Nov 25, 2024

@jfriedr
For this line:
car_req = operations.ListCarrierAccountsRequest(carrier='dhl_ecommerce')
Why aren't we using the Enum like this?
car_req = ListCarrierAccountsRequest(carrier=CarriersEnum.DHL_ECOMMERCE)

@rkeur7
Copy link
Contributor

rkeur7 commented Nov 25, 2024

@jfriedr Can you share what data types are being passed in for all the parameter values?
Most likely there is an error serializing the parameters into the default Union[Dict[str|any]] type here

I created a test for it but need closer to the real data to potentially cause it to fail. See here

@rkeur7
Copy link
Contributor

rkeur7 commented Dec 2, 2024

Is this still an issue or can we close it? @jfriedr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants