Skip to content

Commit 69d819b

Browse files
add warning log for debugging #173
1 parent f555381 commit 69d819b

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

pytr/_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class TimelineDetailV2_CustomerSupportChatAction_Payload(TypedDict):
3333

3434
class TimelineDetailV2_CustomerSupportChatAction_ContextParamms(TypedDict):
3535
chat_flow_key: str
36-
timelineEventId: str
36+
timelineEventId: NotRequired[str]
3737
savingsPlanId: NotRequired[str]
3838
primId: NotRequired[str]
3939
groupId: NotRequired[str]

pytr/timeline.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ async def get_next_timeline_transactions(self, response=None):
4040
for event in response["items"]:
4141
if (
4242
self.max_age_timestamp == 0
43-
or datetime.fromisoformat(event["timestamp"][:19]).timestamp() >= self.max_age_timestamp
43+
or datetime.fromisoformat(event["timestamp"]).timestamp() >= self.max_age_timestamp
4444
):
4545
event["source"] = "timelineTransaction"
4646
self.timeline_events[event["id"]] = event
@@ -129,9 +129,14 @@ def process_timelineDetail(self, response, dl):
129129
# Find the ID of the corresponding timeline event. This is burried deep in the last section of the
130130
# response that contains the customer support information.
131131
support_action = get_customer_support_chat_action(response)
132-
if support_action:
133-
timeline_event_id = support_action["payload"]["contextParams"]["timelineEventId"]
132+
if support_action and (timeline_event_id := support_action["payload"]["contextParams"].get("timelineEventId")):
133+
pass
134134
else:
135+
if support_action:
136+
# DEBUG
137+
self.log.warning(
138+
"This event has no timelineEventId in the customerSupportChat action: %s", json.dumps(response)
139+
)
135140
timeline_event_id = response["id"]
136141

137142
event = self.timeline_events.get(timeline_event_id, None)

0 commit comments

Comments
 (0)