Skip to content

Commit 39710f8

Browse files
authored
Add new fields; provider for code exchange and custom_headers for drafts/messages (#360)
This PR adds two new fields: - `provider` to `CodeExchangeResponse` - `custom_headers` to `CreateDraftRequest`, `UpdateDraftRequest`, and `SendMessageRequest`
1 parent 763e911 commit 39710f8

File tree

5 files changed

+25
-1
lines changed

5 files changed

+25
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ nylas-python Changelog
33

44
Unreleased
55
----------------
6-
* Add clean messages support
6+
* Added support for adding custom headers to outgoing requests
7+
* Added support for `provider` field in code exchange response
8+
* Added clean messages support
9+
* Added additional webhook triggers
10+
* Made event visibility optional to support iCloud events
711

812
v6.1.1
913
----------------

nylas/models/auth.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ class CodeExchangeResponse:
114114
refresh_token: Returned only if the code is requested using "access_type=offline".
115115
id_token: A JWT that contains identity information about the user. Digitally signed by Nylas.
116116
token_type: Always "Bearer".
117+
provider: The provider that the code was exchanged with.
117118
"""
118119

119120
access_token: str
@@ -124,6 +125,7 @@ class CodeExchangeResponse:
124125
refresh_token: Optional[str] = None
125126
id_token: Optional[str] = None
126127
token_type: Optional[str] = None
128+
provider: Optional[Provider] = None
127129

128130

129131
@dataclass_json

nylas/models/drafts.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,19 @@ class TrackingOptions(TypedDict):
5757
thread_replies: NotRequired[bool]
5858

5959

60+
class CustomHeader(TypedDict):
61+
"""
62+
A key-value pair representing a header that can be added to drafts and outgoing messages.
63+
64+
Attributes:
65+
name: The name of the custom header.
66+
value: The value of the custom header.
67+
"""
68+
69+
name: str
70+
value: str
71+
72+
6073
class CreateDraftRequest(TypedDict):
6174
"""
6275
A request to create a draft.
@@ -73,6 +86,7 @@ class CreateDraftRequest(TypedDict):
7386
send_at: Unix timestamp to send the message at.
7487
reply_to_message_id: The ID of the message that you are replying to.
7588
tracking_options: Options for tracking opens, links, and thread replies.
89+
custom_headers: Custom headers to add to the message.
7690
"""
7791

7892
body: NotRequired[str]
@@ -86,6 +100,7 @@ class CreateDraftRequest(TypedDict):
86100
send_at: NotRequired[int]
87101
reply_to_message_id: NotRequired[str]
88102
tracking_options: NotRequired[TrackingOptions]
103+
custom_headers: NotRequired[List[CustomHeader]]
89104

90105

91106
UpdateDraftRequest = CreateDraftRequest
@@ -148,6 +163,7 @@ class SendMessageRequest(CreateDraftRequest):
148163
send_at (NotRequired[int]): Unix timestamp to send the message at.
149164
reply_to_message_id (NotRequired[str]): The ID of the message that you are replying to.
150165
tracking_options (NotRequired[TrackingOptions]): Options for tracking opens, links, and thread replies.
166+
custom_headers(NotRequired[List[CustomHeader]]): Custom headers to add to the message.
151167
use_draft: Whether or not to use draft support. This is primarily used when dealing with large attachments.
152168
"""
153169

tests/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ def http_client_token_exchange():
113113
"scope": "https://www.googleapis.com/auth/gmail.readonly profile",
114114
"token_type": "Bearer",
115115
"grant_id": "grant_123",
116+
"provider": "google",
116117
}
117118
return mock_http_client
118119

tests/resources/test_auth.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ def test_get_token(self, http_client_token_exchange):
9999
assert res.scope == "https://www.googleapis.com/auth/gmail.readonly profile"
100100
assert res.token_type == "Bearer"
101101
assert res.grant_id == "grant_123"
102+
assert res.provider == "google"
102103

103104
def test_get_token_info(self, http_client_token_info):
104105
auth = Auth(http_client_token_info)

0 commit comments

Comments
 (0)