-
Notifications
You must be signed in to change notification settings - Fork 155
Open
Description
Expectation:
Calling to_dict() on a model class will produce a dictionary composed of base types that can be correctly serialized to/from json.
Behaviour:
Deeply nested lists appear to be incorrectly handled.
The following code:
import json
from plaid.model.country_code import CountryCode
from plaid.model.depository_account_subtype import DepositoryAccountSubtype
from plaid.model.depository_account_subtypes import DepositoryAccountSubtypes
from plaid.model.depository_filter import DepositoryFilter
from plaid.model.link_token_account_filters import LinkTokenAccountFilters
from plaid.model.link_token_create_request import LinkTokenCreateRequest
from plaid.model.link_token_create_request_auth import LinkTokenCreateRequestAuth
from plaid.model.link_token_create_request_user import LinkTokenCreateRequestUser
from plaid.model.products import Products
request = LinkTokenCreateRequest(
client_name="myClient",
country_codes=[CountryCode("US")],
language="en",
products=[Products("auth"), Products("transactions")],
user=LinkTokenCreateRequestUser(client_user_id="1234"),
account_filters=LinkTokenAccountFilters(
depository=DepositoryFilter(
account_subtypes=DepositoryAccountSubtypes([DepositoryAccountSubtype(value="CHECKING")])
)
),
auth=LinkTokenCreateRequestAuth(
instant_match_enabled=True,
),
)
print(json.dumps(request.to_dict()))
produces the following exception:
Traceback (most recent call last):
File "/Users/sgran/source/wagestream/us-ws-api/scratch/t.py", line 32, in <module>
print(json.dumps(request.to_dict()))
File "/opt/homebrew/Cellar/[email protected]/3.9.18_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/__init__.py", line 231, in dumps
return _default_encoder.encode(obj)
File "/opt/homebrew/Cellar/[email protected]/3.9.18_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/opt/homebrew/Cellar/[email protected]/3.9.18_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "/opt/homebrew/Cellar/[email protected]/3.9.18_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/encoder.py", line 179, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type DepositoryAccountSubtype is not JSON serializable
JefferyOsborne
Metadata
Metadata
Assignees
Labels
No labels