Skip to content

Commit

Permalink
Added comments and made it accessible on the client
Browse files Browse the repository at this point in the history
  • Loading branch information
Kiran Raju authored and Kiran Raju committed Oct 17, 2023
1 parent 77f08c3 commit 78898fc
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 1 deletion.
11 changes: 11 additions & 0 deletions nylas/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from nylas.resources.applications import Applications
from nylas.resources.auth import Auth
from nylas.resources.calendars import Calendars
from nylas.resources.credentials import Credentials
from nylas.resources.events import Events
from nylas.resources.webhooks import Webhooks

Expand Down Expand Up @@ -52,6 +53,16 @@ def applications(self) -> Applications:
"""
return Applications(self.http_client)

@property
def credentials(self) -> Credentials:
"""
Access the Credentials API.
Returns:
The Credentials API.
"""
return Credentials(self.http_client)

@property
def calendars(self) -> Calendars:
"""
Expand Down
56 changes: 55 additions & 1 deletion nylas/resources/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,78 @@ class Credentials(
DestroyableApiResource,
):
def list(self, provider: Provider, query_params: ListCredentialQueryParams) -> ListResponse[Credential]:
"""
Return all credentials for a particular provider.
Args:
provider: The provider.
query_params: The query parameters to include in the request.
Returns:
The list of credentials.
"""

return super(Credentials, self).list(path=f"/v3/connectors/{provider}/creds", response_type=Credential,
query_params=query_params)

def find(self, provider: Provider, credential_id: str) -> Response[Credential]:
"""
Return a credential.
Args:
provider: The provider of the credential.
credential_id: The ID of the credential to retrieve.
Returns:
The Credential.
"""

return super(Credentials, self).find(
path=f"/v3/connectors/{provider}/creds/{credential_id}", response_type=Credential
)

def create(self, request_body: CredentialRequest) -> Response[Credential]:
"""
Create a credential for a particular provider.
Args:
request_body: The values to create the Credential with.
Returns:
The created Credential.
"""

return super(Credentials, self).create(
path=f"/v3/connectors/microsoft/creds", response_type=Credential, request_body=request_body
path=f"/v3/connectors/{request_body.get('provider')}/creds", response_type=Credential, request_body=request_body
)

def update(self, credential_id: str, request_body: CredentialRequest) -> Response[Credential]:
"""
Update a credential.
Args:
credential_id: The ID of the credential to update.
request_body: The values to update the credential with.
Returns:
The updated credential.
"""

return super(Credentials, self).update(
path=f"/v3/connectors/{request_body.get('provider')}/creds/{credential_id}", response_type=Credential,
request_body=request_body
)

def destroy(self, provider: Provider, credential_id: str) -> DeleteResponse[Credential]:
"""
Delete a credential.
Args:
provider: the provider for the grant
credential_id: The ID of the credential to delete.
Returns:
The deletion response.
"""

return super(Credentials, self).destroy(path=f"/v3/connectors/{provider}/creds/{credential_id}")

0 comments on commit 78898fc

Please sign in to comment.