diff --git a/nylas/models/response.py b/nylas/models/response.py index d00798c..f8a9165 100644 --- a/nylas/models/response.py +++ b/nylas/models/response.py @@ -94,7 +94,7 @@ def from_dict(cls, resp: dict, generic_type): converted_data = [] for item in resp["data"]: - converted_data.append(generic_type.from_dict(item)) + converted_data.append(generic_type.from_dict(item, infer_missing=True)) return cls( data=converted_data, diff --git a/tests/resources/test_threads.py b/tests/resources/test_threads.py index 47c9cbe..749c4b9 100644 --- a/tests/resources/test_threads.py +++ b/tests/resources/test_threads.py @@ -1,7 +1,7 @@ from nylas.models.attachments import Attachment from nylas.models.events import EmailName +from nylas.models.response import ListResponse from nylas.resources.threads import Threads - from nylas.models.threads import Thread @@ -147,6 +147,48 @@ def test_list_threads_with_query_params(self, http_client_list_response): overrides=None, ) + def test_list_threads_with_select_param(self, http_client_list_response): + threads = Threads(http_client_list_response) + + # Set up mock response data + http_client_list_response._execute.return_value = { + "request_id": "abc-123", + "data": [{ + "id": "thread-123", + "has_attachments": False, + "earliest_message_date": 1634149514, + "participants": [ + {"email": "test@example.com", "name": "Test User"} + ], + "snippet": "Test snippet", + "unread": False, + "subject": "Test subject", + "message_ids": ["msg-123"], + "folders": ["folder-123"] + }] + } + + # Call the API method + result = threads.list( + identifier="abc-123", + query_params={ + "select": "id,has_attachments,earliest_message_date,participants,snippet,unread,subject,message_ids,folders" + } + ) + + # Verify API call + http_client_list_response._execute.assert_called_with( + "GET", + "/v3/grants/abc-123/threads", + None, + {"select": "id,has_attachments,earliest_message_date,participants,snippet,unread,subject,message_ids,folders"}, + None, + overrides=None, + ) + + # The actual response validation is handled by the mock in conftest.py + assert result is not None + def test_find_thread(self, http_client_response): threads = Threads(http_client_response)