Skip to content

Commit

Permalink
Add support for detect_provider
Browse files Browse the repository at this point in the history
  • Loading branch information
mrashed-dev committed Mar 5, 2024
1 parent 247a70f commit 08409b3
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion nylas/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,27 @@ def send_authorization(self, code):
self.access_token = results["access_token"]
return results

def detect_provider(self, email):
"""
Detect the provider for a given email address.
Args:
email (str): The email address you want to check
Returns:
dict: The response from the API containing the provider, if found
"""
url = "{api_server}/connect/detect-provider".format(api_server=self.api_server)
data = {
"client_id": self.client_id,
"client_secret": self.client_secret,
"email_address": email,
}

resp = self._request(HttpMethod.POST, url, json=data)
_validate(resp)
return resp.json()

def token_for_code(self, code):
"""
Exchange an authorization code for an access token
Expand Down Expand Up @@ -593,7 +614,7 @@ def _get_resource_raw(
stream=False,
path=None,
stream_timeout=None,
**filters
**filters,
):
"""Get an individual REST resource"""
if path is None:
Expand Down

0 comments on commit 08409b3

Please sign in to comment.