Skip to content

Commit

Permalink
Adding Folder query param support and setting background image to none (
Browse files Browse the repository at this point in the history
#371)

* Setting background image to none

* Adding query param support for Folders

* fixing tests and formatting
  • Loading branch information
kraju3 authored May 31, 2024
1 parent 0857efb commit edb8b06
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
6 changes: 3 additions & 3 deletions nylas/models/application_details.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from dataclasses import dataclass
from dataclasses import dataclass, field
from typing import Literal, Optional, List

from dataclasses_json import dataclass_json
Expand Down Expand Up @@ -48,7 +48,7 @@ class HostedAuthentication:
spacing: CSS spacing attribute in px.
"""

background_image_url: str
background_image_url: Optional[str] = None
alignment: Optional[str] = None
color_primary: Optional[str] = None
color_secondary: Optional[str] = None
Expand Down Expand Up @@ -80,4 +80,4 @@ class ApplicationDetails:
environment: Environment
branding: Branding
hosted_authentication: Optional[HostedAuthentication] = None
callback_uris: List[RedirectUri] = None
callback_uris: List[RedirectUri] = field(default_factory=list)
13 changes: 13 additions & 0 deletions nylas/models/folders.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from dataclasses_json import dataclass_json
from typing_extensions import TypedDict, NotRequired

from nylas.models.list_query_params import ListQueryParams


@dataclass_json
@dataclass
Expand Down Expand Up @@ -75,3 +77,14 @@ class UpdateFolderRequest(TypedDict):
parent_id: NotRequired[str]
background_color: NotRequired[str]
text_color: NotRequired[str]


class ListFolderQueryParams(ListQueryParams):
"""
Interface representing the query parameters for listing folders.
Attributes:
parent_id: (Microsoft and EWS only.) Use the ID of a folder to find all child folders it contains.
"""

parent_id: NotRequired[str]
6 changes: 6 additions & 0 deletions nylas/resources/folders.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Optional

from nylas.config import RequestOverrides
from nylas.handler.api_resources import (
ListableApiResource,
Expand All @@ -10,6 +12,7 @@
Folder,
CreateFolderRequest,
UpdateFolderRequest,
ListFolderQueryParams,
)
from nylas.models.response import Response, ListResponse, DeleteResponse

Expand All @@ -30,13 +33,15 @@ class Folders(
def list(
self,
identifier: str,
query_params: Optional[ListFolderQueryParams] = None,
overrides: RequestOverrides = None,
) -> ListResponse[Folder]:
"""
Return all Folders.
Args:
identifier: The identifier of the Grant to act upon.
query_params: The query parameters to include in the request.
overrides: The request overrides to use.
Returns:
Expand All @@ -46,6 +51,7 @@ def list(
return super().list(
path=f"/v3/grants/{identifier}/folders",
response_type=Folder,
query_params=query_params,
overrides=overrides,
)

Expand Down
2 changes: 1 addition & 1 deletion tests/resources/test_folders.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_folder_deserialization(self):
def test_list_folders(self, http_client_list_response):
folders = Folders(http_client_list_response)

folders.list(identifier="abc-123")
folders.list(identifier="abc-123",query_params=None)

http_client_list_response._execute.assert_called_once_with(
"GET", "/v3/grants/abc-123/folders", None, None, None, overrides=None
Expand Down

0 comments on commit edb8b06

Please sign in to comment.