Skip to content

messages

Messages

Bases: ListableApiResource, FindableApiResource, UpdatableApiResource, DestroyableApiResource

Source code in nylas/resources/messages.py
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
class Messages(
    ListableApiResource,
    FindableApiResource,
    UpdatableApiResource,
    DestroyableApiResource,
):
    def list(
        self, identifier: str, query_params: ListMessagesQueryParams
    ) -> ListResponse[Message]:
        """
        Return all Messages.

        Args:
            identifier: The identifier of the grant to get messages for.
            query_params: The query parameters to filter messages by.

        Returns:
            A list of Messages.
        """
        return super(Messages, self).list(
            path=f"/v3/grants/{identifier}/messages",
            response_type=Message,
            query_params=query_params,
        )

    def find(
        self,
        identifier: str,
        message_id: str,
        query_params: Optional[FindMessageQueryParams] = None,
    ) -> Response[Message]:
        """
        Return a Message.

        Args:
            identifier: The identifier of the grant to get the message for.
            message_id: The identifier of the message to get.
            query_params: The query parameters to include in the request.

        Returns:
            The requested Message.
        """
        return super(Messages, self).find(
            path=f"/v3/grants/{identifier}/messages/{message_id}",
            response_type=Message,
            query_params=query_params,
        )

    def update(
        self,
        identifier: str,
        message_id: str,
        request_body: UpdateMessageRequest,
        query_params: Dict,
    ) -> Response[Message]:
        """
        Update a Message.

        Args:
            identifier: The identifier of the grant to update the message for.
            message_id: The identifier of the message to update.
            request_body: The request body to update the message with.
            query_params: The query parameters to include in the request.

        Returns:
            The updated Message.
        """
        return super(Messages, self).update(
            path=f"/v3/grants/{identifier}/messages/{message_id}",
            response_type=Message,
            request_body=request_body,
            query_params=query_params,
        )

    def destroy(
        self, identifier: str, message_id: str, query_params: Dict
    ) -> DeleteResponse:
        """
        Delete a Message.

        Args:
            identifier: The identifier of the grant to delete the message for.
            message_id: The identifier of the message to delete.
            query_params: The query parameters to include in the request.

        Returns:
            The deletion response.
        """
        return super(Messages, self).destroy(
            path=f"/v3/grants/{identifier}/messages/{message_id}",
            query_params=query_params,
        )

destroy(identifier, message_id, query_params)

Delete a Message.

Parameters:

Name Type Description Default
identifier str

The identifier of the grant to delete the message for.

required
message_id str

The identifier of the message to delete.

required
query_params Dict

The query parameters to include in the request.

required

Returns:

Type Description
DeleteResponse

The deletion response.

Source code in nylas/resources/messages.py
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
def destroy(
    self, identifier: str, message_id: str, query_params: Dict
) -> DeleteResponse:
    """
    Delete a Message.

    Args:
        identifier: The identifier of the grant to delete the message for.
        message_id: The identifier of the message to delete.
        query_params: The query parameters to include in the request.

    Returns:
        The deletion response.
    """
    return super(Messages, self).destroy(
        path=f"/v3/grants/{identifier}/messages/{message_id}",
        query_params=query_params,
    )

find(identifier, message_id, query_params=None)

Return a Message.

Parameters:

Name Type Description Default
identifier str

The identifier of the grant to get the message for.

required
message_id str

The identifier of the message to get.

required
query_params Optional[FindMessageQueryParams]

The query parameters to include in the request.

None

Returns:

Type Description
Response[Message]

The requested Message.

Source code in nylas/resources/messages.py
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
def find(
    self,
    identifier: str,
    message_id: str,
    query_params: Optional[FindMessageQueryParams] = None,
) -> Response[Message]:
    """
    Return a Message.

    Args:
        identifier: The identifier of the grant to get the message for.
        message_id: The identifier of the message to get.
        query_params: The query parameters to include in the request.

    Returns:
        The requested Message.
    """
    return super(Messages, self).find(
        path=f"/v3/grants/{identifier}/messages/{message_id}",
        response_type=Message,
        query_params=query_params,
    )

list(identifier, query_params)

Return all Messages.

Parameters:

Name Type Description Default
identifier str

The identifier of the grant to get messages for.

required
query_params ListMessagesQueryParams

The query parameters to filter messages by.

required

Returns:

Type Description
ListResponse[Message]

A list of Messages.

Source code in nylas/resources/messages.py
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
def list(
    self, identifier: str, query_params: ListMessagesQueryParams
) -> ListResponse[Message]:
    """
    Return all Messages.

    Args:
        identifier: The identifier of the grant to get messages for.
        query_params: The query parameters to filter messages by.

    Returns:
        A list of Messages.
    """
    return super(Messages, self).list(
        path=f"/v3/grants/{identifier}/messages",
        response_type=Message,
        query_params=query_params,
    )

update(identifier, message_id, request_body, query_params)

Update a Message.

Parameters:

Name Type Description Default
identifier str

The identifier of the grant to update the message for.

required
message_id str

The identifier of the message to update.

required
request_body UpdateMessageRequest

The request body to update the message with.

required
query_params Dict

The query parameters to include in the request.

required

Returns:

Type Description
Response[Message]

The updated Message.

Source code in nylas/resources/messages.py
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
def update(
    self,
    identifier: str,
    message_id: str,
    request_body: UpdateMessageRequest,
    query_params: Dict,
) -> Response[Message]:
    """
    Update a Message.

    Args:
        identifier: The identifier of the grant to update the message for.
        message_id: The identifier of the message to update.
        request_body: The request body to update the message with.
        query_params: The query parameters to include in the request.

    Returns:
        The updated Message.
    """
    return super(Messages, self).update(
        path=f"/v3/grants/{identifier}/messages/{message_id}",
        response_type=Message,
        request_body=request_body,
        query_params=query_params,
    )