From 64d1c3ec6a161f43d2750a4ae875e9fa16210004 Mon Sep 17 00:00:00 2001 From: cnukaus Date: Fri, 6 Sep 2024 09:24:27 +1000 Subject: [PATCH] added detection of events_received key, fixed the missing colon after else --- facebook_business/adobjects/serverside/event_request.py | 7 ++++++- .../adobjects/serverside/event_request_async.py | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/facebook_business/adobjects/serverside/event_request.py b/facebook_business/adobjects/serverside/event_request.py index b100f973..144c99aa 100644 --- a/facebook_business/adobjects/serverside/event_request.py +++ b/facebook_business/adobjects/serverside/event_request.py @@ -282,9 +282,14 @@ def execute(self): fields=[], params=params, ) - return EventResponse(events_received=response['events_received'], + if response.get('events_received'): + return EventResponse(events_received=response['events_received'], fbtrace_id=response['fbtrace_id'], messages=response['messages']) + else: + return EventResponse(events_received=0, + fbtrace_id=response['fbtrace_id'], + messages=response['messages']) def execute_with_client(self, params): url = '/'.join([ diff --git a/facebook_business/adobjects/serverside/event_request_async.py b/facebook_business/adobjects/serverside/event_request_async.py index 3aac6e16..3189661f 100644 --- a/facebook_business/adobjects/serverside/event_request_async.py +++ b/facebook_business/adobjects/serverside/event_request_async.py @@ -94,7 +94,7 @@ async def execute(self): return EventResponse(events_received=response['events_received'], fbtrace_id=response['fbtrace_id'], messages=response['messages']) - else + else: return EventResponse(events_received=0, fbtrace_id=response['fbtrace_id'], messages=response['messages'])