-
Couldn't load subscription status.
- Fork 59
Closed
Labels
triageIssue is being researchedIssue is being researched
Description
Software Version
7.13.0
Language Version
3.10.8
Operating System
Ubuntu 22.04.2
What happened?
- I'm trying to retrieve payloads for an event as described in the api docs:
import easypost
easypost.api_key = config("EASYPOST_API_KEY_TEST")
def test_list_payloads():
# api documentation: https://www.easypost.com/docs/api/python#retrieve-a-list-of-payloads
payloads = easypost.Event.retrieve_all_payloads(
"evt_a93cbcd2fbef11ed9b16693a7541b68d"
)
- The test fails with this error (line 84 from easypost_objects.py
cls = getattr(easypost, class_name, EasyPostObject)
`> obj = cls.construct_from(values=response, api_key=api_key, parent=parent, name=name)
E AttributeError: type object 'Payload' has no attribute 'construct_from'`
What was expected?
The call did not return a list of payloads as expected.
Sample Code
No response
Relevant logs
Pytest output:
shipaware_django/shipments/utils/tests/test_easypost.py:47 (test_list_payloads)
def test_list_payloads():
# api documentation: https://www.easypost.com/docs/api/python#retrieve-a-list-of-payloads
> payloads = easypost.Event.retrieve_all_payloads(
"evt_a93cbcd2fbef11ed9b16693a7541b68d"
)
test_easypost.py:50:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/home/nate/.venv/shipaware/lib/python3.10/site-packages/easypost/event.py:30: in retrieve_all_payloads
return convert_to_easypost_object(response=response, api_key=api_key)
/home/nate/.venv/shipaware/lib/python3.10/site-packages/easypost/easypost_object.py:75: in convert_to_easypost_object
obj = cls.construct_from(values=response, api_key=api_key, parent=parent, name=name)
/home/nate/.venv/shipaware/lib/python3.10/site-packages/easypost/easypost_object.py:163: in construct_from
instance.refresh_from(values=values, api_key=api_key)
/home/nate/.venv/shipaware/lib/python3.10/site-packages/easypost/easypost_object.py:175: in refresh_from
self.__dict__[k] = convert_to_easypost_object(response=v, api_key=api_key, parent=self, name=k)
/home/nate/.venv/shipaware/lib/python3.10/site-packages/easypost/easypost_object.py:62: in convert_to_easypost_object
return [convert_to_easypost_object(response=item, api_key=api_key, parent=parent) for item in response]
/home/nate/.venv/shipaware/lib/python3.10/site-packages/easypost/easypost_object.py:62: in <listcomp>
return [convert_to_easypost_object(response=item, api_key=api_key, parent=parent) for item in response]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
response = {'created_at': '2023-05-26T18:04:18Z', 'id': 'payload_bb6a216afbef11edafff179518355bf1', 'object': 'Payload', 'request...s_return":false,"public_url":"https://track.easypost.com/djE6dHJrXzAyMzhkYjkyZmU5MjQyZTViMTc3MGRlMWU3ZWFlMzk3"}}', ...}
api_key = [REMOVED]
parent = <EasyPostObject at 0x7f8038106fb0> JSON: {}, name = None
def convert_to_easypost_object(
response: Dict[str, Any],
api_key: Optional[str] = None,
parent: object = None,
name: Optional[str] = None,
):
"""Convert a response to an EasyPost object."""
if isinstance(response, list):
return [convert_to_easypost_object(response=item, api_key=api_key, parent=parent) for item in response]
elif isinstance(response, dict):
response = response.copy()
object_type_str = response.get("object", "EasyPostObject")
class_name = OBJECT_CLASS_NAME_OVERRIDES.get(object_type_str, object_type_str)
object_id = response.get("id", None)
if object_id is not None:
# If an object ID is present, use it to find the class type instead.
object_id_prefix = object_id.split("_")[0]
class_name = EASYPOST_OBJECT_ID_PREFIX_TO_CLASS_NAME_MAP.get(object_id_prefix, "EasyPostObject")
cls = getattr(easypost, class_name, EasyPostObject)
> obj = cls.construct_from(values=response, api_key=api_key, parent=parent, name=name)
E AttributeError: type object 'Payload' has no attribute 'construct_from'
/home/nate/.venv/shipaware/lib/python3.10/site-packages/easypost/easypost_object.py:75: AttributeError
Process finished with exit code 1Metadata
Metadata
Assignees
Labels
triageIssue is being researchedIssue is being researched