From 950f296f7a0caf5ccfc5b45983105fd19dc9b1b1 Mon Sep 17 00:00:00 2001 From: cnukaus Date: Mon, 9 Sep 2024 19:17:44 -0700 Subject: [PATCH] added detection of events_received key, fixed the missing colon after else (#682) Summary: Pull Request resolved: https://github.com/facebook/facebook-python-business-sdk/pull/682 Reviewed By: yoongyj Differential Revision: D62390864 Pulled By: stcheng fbshipit-source-id: 7b37f103687b281104e9125ca52eb242a655b3e0 --- 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'])