Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into devin/1733934681-add-…
Browse files Browse the repository at this point in the history
…metadata-field

# Conflicts:
#	CHANGELOG.md

Co-Authored-By: Aaron de Mello <[email protected]>
  • Loading branch information
devin-ai-integration[bot] and AaronDDM committed Dec 20, 2024
2 parents 4204bb2 + 5922f8c commit 068e67a
Show file tree
Hide file tree
Showing 17 changed files with 1,439 additions and 10 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
nylas-python Changelog
======================

v6.5.0
# Unreleased
----------------
* Add support for Scheduler APIs
* Fixed attachment download response handling
* Add metadata field support for drafts and messages through CreateDraftRequest model

v6.4.0
Expand Down
11 changes: 11 additions & 0 deletions nylas/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from nylas.resources.contacts import Contacts
from nylas.resources.drafts import Drafts
from nylas.resources.grants import Grants
from nylas.resources.scheduler import Scheduler


class Client:
Expand Down Expand Up @@ -169,3 +170,13 @@ def webhooks(self) -> Webhooks:
The Webhooks API.
"""
return Webhooks(self.http_client)

@property
def scheduler(self) -> Scheduler:
"""
Access the Scheduler API.
Returns:
The Scheduler API.
"""
return Scheduler(self.http_client)
18 changes: 18 additions & 0 deletions nylas/handler/api_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,24 @@ def update(
return Response.from_dict(response_json, response_type)


class UpdatablePatchApiResource(Resource):
def patch(
self,
path,
response_type,
headers=None,
query_params=None,
request_body=None,
method="PATCH",
overrides=None,
):
response_json = self._http_client._execute(
method, path, headers, query_params, request_body, overrides=overrides
)

return Response.from_dict(response_json, response_type)


class DestroyableApiResource(Resource):
def destroy(
self,
Expand Down
6 changes: 4 additions & 2 deletions nylas/handler/http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ def _validate_response(response: Response) -> dict:

return json


def _build_query_params(base_url: str, query_params: dict = None) -> str:
query_param_parts = []
for key, value in query_params.items():
Expand Down Expand Up @@ -109,7 +108,7 @@ def _execute_download_request(
query_params=None,
stream=False,
overrides=None,
) -> Union[bytes, Response]:
) -> Union[bytes, Response,dict]:
request = self._build_request("GET", path, headers, query_params, overrides)

timeout = self.timeout
Expand All @@ -124,6 +123,9 @@ def _execute_download_request(
stream=stream,
)

if not response.ok:
return _validate_response(response)

# If we stream an iterator for streaming the content, otherwise return the entire byte array
if stream:
return response
Expand Down
4 changes: 2 additions & 2 deletions nylas/models/availability.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@ class AvailabilityRules(TypedDict):
default_open_hours: A default set of open hours to apply to all participants.
You can overwrite these open hours for individual participants by specifying open_hours on
the participant object.
round_robin_event_id: The ID on events that Nylas considers when calculating the order of
round_robin_group_id: The ID on events that Nylas considers when calculating the order of
round-robin participants.
This is used for both max-fairness and max-availability methods.
"""

availability_method: NotRequired[AvailabilityMethod]
buffer: NotRequired[MeetingBuffer]
default_open_hours: NotRequired[List[OpenHours]]
round_robin_event_id: NotRequired[str]
round_robin_group_id: NotRequired[str]


class AvailabilityParticipant(TypedDict):
Expand Down
2 changes: 0 additions & 2 deletions nylas/models/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ class Message:


class FindMessageQueryParams(TypedDict):

"""
Query parameters for finding a message.
Expand All @@ -144,7 +143,6 @@ class FindMessageQueryParams(TypedDict):


class UpdateMessageRequest(TypedDict):

"""
Request payload for updating a message.
Expand Down
2 changes: 1 addition & 1 deletion nylas/models/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading

0 comments on commit 068e67a

Please sign in to comment.