Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

source-intercom-native: add tickets stream and reduce logging #2281

Merged
merged 5 commits into from
Jan 22, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
source-intercom-native: misc renaming & fixing typos
Alex-Bair committed Jan 17, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 17120d199831d0ab6bd6cc119fd1d2221b1a0a82
20 changes: 10 additions & 10 deletions source-intercom-native/source_intercom_native/api.py
Original file line number Diff line number Diff line change
@@ -60,7 +60,7 @@ async def snapshot_resources(
yield resource


def _generate_contacts_search_request_body(
def _generate_contacts_search_body(
lower_bound: int,
upper_bound: int,
next_page_cursor: str | None = None
@@ -128,7 +128,7 @@ def _generate_contacts_search_request_body(
}


def _generate_conversations_or_tickets_search_request_body(
def _generate_conversations_or_tickets_search_body(
lower_bound: int,
upper_bound: int,
next_page_cursor: str | None = None
@@ -185,7 +185,7 @@ async def fetch_contacts(
last_seen_ts = start

url = f"{API}/contacts/search"
body = _generate_contacts_search_request_body(start, end)
body = _generate_contacts_search_body(start, end)

pagination_ended_early = False
while True:
@@ -224,7 +224,7 @@ async def fetch_contacts(
if pagination_ended_early or response.pages.next is None:
break

body = _generate_contacts_search_request_body(start, end, response.pages.next.starting_after)
body = _generate_contacts_search_body(start, end, response.pages.next.starting_after)

# Results are returned in descending order, so we can't yield a cursor until pagination is complete.
if end == max_end:
@@ -246,7 +246,7 @@ async def fetch_tickets(
last_seen_ts = start

url = f"{API}/tickets/search"
body = _generate_conversations_or_tickets_search_request_body(start, end)
body = _generate_conversations_or_tickets_search_body(start, end)

while True:
response = TicketsSearchResponse.model_validate_json(
@@ -280,7 +280,7 @@ async def fetch_tickets(
yield _s_to_dt(last_seen_ts)
break

body = _generate_conversations_or_tickets_search_request_body(start, end, response.pages.next.starting_after)
body = _generate_conversations_or_tickets_search_body(start, end, response.pages.next.starting_after)


async def fetch_conversations(
@@ -296,7 +296,7 @@ async def fetch_conversations(
last_seen_ts = start

url = f"{API}/conversations/search"
body = _generate_conversations_or_tickets_search_request_body(start, end)
body = _generate_conversations_or_tickets_search_body(start, end)

while True:
response = ConversationsSearchResponse.model_validate_json(
@@ -330,7 +330,7 @@ async def fetch_conversations(
yield _s_to_dt(last_seen_ts)
break

body = _generate_conversations_or_tickets_search_request_body(start, end, response.pages.next.starting_after)
body = _generate_conversations_or_tickets_search_body(start, end, response.pages.next.starting_after)


async def fetch_conversations_parts(
@@ -348,7 +348,7 @@ async def fetch_conversations_parts(
last_seen_ts = start

url = f"{API}/conversations/search"
body = _generate_conversations_or_tickets_search_request_body(start, end)
body = _generate_conversations_or_tickets_search_body(start, end)

while True:
response = ConversationsSearchResponse.model_validate_json(
@@ -379,7 +379,7 @@ async def fetch_conversations_parts(
if response.pages.next is None:
break

body = _generate_conversations_or_tickets_search_request_body(start, end, response.pages.next.starting_after)
body = _generate_conversations_or_tickets_search_body(start, end, response.pages.next.starting_after)

# Since a conversation part's updated_at could be after the window_start but before the parent
# conversation's updated_at, we can't yield a new cursor until after checking the entire date window.
4 changes: 2 additions & 2 deletions source-intercom-native/source_intercom_native/resources.py
Original file line number Diff line number Diff line change
@@ -43,14 +43,14 @@


# Incremental resources that use date windows.
# Each tuple contains the resource's name and it's fetch function.
# Each tuple contains the resource's name and its fetch function.
INCREMENTAL_DATE_WINDOW_RESOURCES: list[tuple[str, IncrementalDateWindowResourceFetchChangesFn]] = [
('contacts', fetch_contacts),
('conversation_parts', fetch_conversations_parts),
]

# Incremental resources that don't use date windows.
# Each tuple contains the resource's name and it's fetch function.
# Each tuple contains the resource's name and its fetch function.
INCREMENTAL_RESOURCES: list[tuple[str, IncrementalResourceFetchChangesFn]] = [
('tickets', fetch_tickets),
('conversations', fetch_conversations),