goshippo / shippo-python-sdk

MIT License
11 stars 1 forks source link

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

Open jfriedr opened 6 months ago

jfriedr commented 6 months ago

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 commented 4 days ago

@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 commented 4 days ago

@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