Skip to content

response

DeleteResponse dataclass

Delete response object returned from the Nylas API.

Attributes:

Name Type Description
request_id str

The request ID returned from the API.

Source code in nylas/models/response.py
106
107
108
109
110
111
112
113
114
115
116
@dataclass_json
@dataclass
class DeleteResponse:
    """
    Delete response object returned from the Nylas API.

    Attributes:
        request_id: The request ID returned from the API.
    """

    request_id: str

ListResponse

Bases: tuple, Generic[T]

List response object returned from the Nylas API.

Attributes:

Name Type Description
data List[T]

The list of requested data objects.

request_id str

The request ID.

next_cursor Optional[str]

The cursor to use to get the next page of data.

Source code in nylas/models/response.py
 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
class ListResponse(tuple, Generic[T]):
    """
    List response object returned from the Nylas API.

    Attributes:
        data: The list of requested data objects.
        request_id: The request ID.
        next_cursor: The cursor to use to get the next page of data.
    """

    data: List[T]
    request_id: str
    next_cursor: Optional[str] = None

    def __new__(cls, data: List[T], request_id: str, next_cursor: Optional[str] = None):
        """
        Initialize the response object.

        Args:
            data: The list of requested data objects.
            request_id: The request ID.
            next_cursor: The cursor to use to get the next page of data.
        """
        # Initialize the tuple for destructuring support
        instance = super().__new__(cls, (data, request_id, next_cursor))

        instance.data = data
        instance.request_id = request_id
        instance.next_cursor = next_cursor

        return instance

    @classmethod
    def from_dict(cls, resp: dict, generic_type):
        """
        Convert a dictionary to a response object.

        Args:
            resp: The dictionary to convert.
            generic_type: The type to deserialize the data objects into.
        """

        converted_data = []
        for item in resp["data"]:
            converted_data.append(generic_type.from_dict(item))

        return cls(
            data=converted_data,
            request_id=resp["request_id"],
            next_cursor=resp.get("next_cursor", None),
        )

__new__(data, request_id, next_cursor=None)

Initialize the response object.

Parameters:

Name Type Description Default
data List[T]

The list of requested data objects.

required
request_id str

The request ID.

required
next_cursor Optional[str]

The cursor to use to get the next page of data.

None
Source code in nylas/models/response.py
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
def __new__(cls, data: List[T], request_id: str, next_cursor: Optional[str] = None):
    """
    Initialize the response object.

    Args:
        data: The list of requested data objects.
        request_id: The request ID.
        next_cursor: The cursor to use to get the next page of data.
    """
    # Initialize the tuple for destructuring support
    instance = super().__new__(cls, (data, request_id, next_cursor))

    instance.data = data
    instance.request_id = request_id
    instance.next_cursor = next_cursor

    return instance

from_dict(resp, generic_type) classmethod

Convert a dictionary to a response object.

Parameters:

Name Type Description Default
resp dict

The dictionary to convert.

required
generic_type

The type to deserialize the data objects into.

required
Source code in nylas/models/response.py
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
@classmethod
def from_dict(cls, resp: dict, generic_type):
    """
    Convert a dictionary to a response object.

    Args:
        resp: The dictionary to convert.
        generic_type: The type to deserialize the data objects into.
    """

    converted_data = []
    for item in resp["data"]:
        converted_data.append(generic_type.from_dict(item))

    return cls(
        data=converted_data,
        request_id=resp["request_id"],
        next_cursor=resp.get("next_cursor", None),
    )

RequestIdOnlyResponse dataclass

Response object returned from the Nylas API that only contains a request ID.

Attributes:

Name Type Description
request_id str

The request ID returned from the API.

Source code in nylas/models/response.py
119
120
121
122
123
124
125
126
127
128
129
@dataclass_json
@dataclass
class RequestIdOnlyResponse:
    """
    Response object returned from the Nylas API that only contains a request ID.

    Attributes:
        request_id: The request ID returned from the API.
    """

    request_id: str

Response

Bases: tuple, Generic[T]

Response object returned from the Nylas API.

Attributes:

Name Type Description
data T

The requested data object.

request_id str

The request ID.

Source code in nylas/models/response.py
 9
10
11
12
13
14
15
16
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
class Response(tuple, Generic[T]):
    """
    Response object returned from the Nylas API.

    Attributes:
        data: The requested data object.
        request_id: The request ID.
    """

    data: T
    request_id: str

    def __new__(cls, data: T, request_id: str):
        """
        Initialize the response object.

        Args:
            data: The requested data object.
            request_id: The request ID.
        """
        # Initialize the tuple for destructuring support
        instance = super().__new__(cls, (data, request_id))

        instance.data = data
        instance.request_id = request_id

        return instance

    @classmethod
    def from_dict(cls, resp: dict, generic_type):
        """
        Convert a dictionary to a response object.

        Args:
            resp: The dictionary to convert.
            generic_type: The type to deserialize the data object into.
        """

        return cls(
            data=generic_type.from_dict(resp["data"]),
            request_id=resp["request_id"],
        )

__new__(data, request_id)

Initialize the response object.

Parameters:

Name Type Description Default
data T

The requested data object.

required
request_id str

The request ID.

required
Source code in nylas/models/response.py
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
def __new__(cls, data: T, request_id: str):
    """
    Initialize the response object.

    Args:
        data: The requested data object.
        request_id: The request ID.
    """
    # Initialize the tuple for destructuring support
    instance = super().__new__(cls, (data, request_id))

    instance.data = data
    instance.request_id = request_id

    return instance

from_dict(resp, generic_type) classmethod

Convert a dictionary to a response object.

Parameters:

Name Type Description Default
resp dict

The dictionary to convert.

required
generic_type

The type to deserialize the data object into.

required
Source code in nylas/models/response.py
37
38
39
40
41
42
43
44
45
46
47
48
49
50
@classmethod
def from_dict(cls, resp: dict, generic_type):
    """
    Convert a dictionary to a response object.

    Args:
        resp: The dictionary to convert.
        generic_type: The type to deserialize the data object into.
    """

    return cls(
        data=generic_type.from_dict(resp["data"]),
        request_id=resp["request_id"],
    )