-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
70 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from api.turn import pyTurn | ||
|
||
start = "2024-01-01T00:00:00+00:00" | ||
end = "2024-01-01T05:00:00+00:00" | ||
|
||
contacts = pyTurn.contacts.get_contacts(start=start, end=end) | ||
|
||
print(contacts.head(5)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from api.turn import pyTurn | ||
|
||
content = pyTurn.content.get_content() | ||
|
||
print(content.head(5)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
from datetime import datetime, timedelta | ||
|
||
from api.turn import pyTurn | ||
|
||
end = datetime.now().isoformat() | ||
start = (datetime.now() - timedelta(2)).isoformat() | ||
start = "2024-01-01T00:00:00+00:00" | ||
end = "2024-01-01T05:00:00+00:00" | ||
|
||
messages = pyTurn.messages.get_messages(start=start, end=end) | ||
|
||
messages.keys() | ||
print(messages.keys()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,31 @@ | ||
from pandas import json_normalize | ||
from attrs import define | ||
from httpx import Client | ||
from pandas import DataFrame, json_normalize | ||
|
||
|
||
def deep_get(obj, path): | ||
if not path or not obj: | ||
return obj | ||
return deep_get(obj.get(path[0]), path[1:]) | ||
@define | ||
class Content: | ||
"""Dedicated to the content export endpoint of the Turn Data Export API.""" | ||
|
||
client: Client | ||
|
||
class Content: | ||
def __init__(self, session) -> None: | ||
self._session = session | ||
def get_content(self, **kwargs: str | int) -> DataFrame: | ||
"""Get a pandas DataFrame of content. | ||
No time-based query parameters are supported by this endpoint. | ||
def get_content(self, start, end): | ||
pyTurn.content.get_content() | ||
See examples/turn/content.py | ||
""" | ||
url = "export" | ||
|
||
response = self._session.request("GET", url) | ||
response.raise_for_status() | ||
params = {**kwargs} | ||
|
||
content_response = self.client.get(url=url, params=params) | ||
content_response.raise_for_status() | ||
|
||
content = json_normalize(response.json()["data"]) | ||
content = json_normalize(content_response.json()["data"]) | ||
|
||
return content |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,8 @@ def get_messages( | |
end=end | ||
) | ||
See examples/turn/messages.py. | ||
""" | ||
|
||
url = "data/messages/cursor" | ||
|