From 66c25e93537bbf1a2d65f8274c5a2e68677a3abf Mon Sep 17 00:00:00 2001 From: Filippo Romani Date: Mon, 16 Jan 2023 15:05:50 +0100 Subject: [PATCH 1/2] refactor: remove type union operator I propose this removal to support python versions < 3.10, as (type | None) can't be used in older python versions. --- heyoo/__init__.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/heyoo/__init__.py b/heyoo/__init__.py index b886211..f3861fb 100644 --- a/heyoo/__init__.py +++ b/heyoo/__init__.py @@ -656,7 +656,7 @@ def preprocess(self, data): """ return data["entry"][0]["changes"][0]["value"] - def get_mobile(self, data) -> (str | None): + def get_mobile(self, data): """ Extracts the mobile number of the sender from the data received from the webhook. @@ -674,7 +674,7 @@ def get_mobile(self, data) -> (str | None): if "contacts" in data: return data["contacts"][0]["wa_id"] - def get_name(self, data) -> (str | None): + def get_name(self, data): """ Extracts the name of the sender from the data received from the webhook. @@ -691,7 +691,7 @@ def get_name(self, data) -> (str | None): if contact: return contact["contacts"][0]["profile"]["name"] - def get_message(self, data) -> (str | None): + def get_message(self, data): """ Extracts the text message of the sender from the data received from the webhook. @@ -708,7 +708,7 @@ def get_message(self, data) -> (str | None): if "messages" in data: return data["messages"][0]["text"]["body"] - def get_message_id(self, data) -> (str | None): + def get_message_id(self, data): """ Extracts the message id of the sender from the data received from the webhook. @@ -725,7 +725,7 @@ def get_message_id(self, data) -> (str | None): if "messages" in data: return data["messages"][0]["id"] - def get_message_timestamp(self, data) -> (str | None): + def get_message_timestamp(self, data): """ " Extracts the timestamp of the message from the data received from the webhook. @@ -742,7 +742,7 @@ def get_message_timestamp(self, data) -> (str | None): if "messages" in data: return data["messages"][0]["timestamp"] - def get_interactive_response(self, data) -> (Dict | None): + def get_interactive_response(self, data): """ Extracts the response of the interactive message from the data received from the webhook. @@ -764,7 +764,7 @@ def get_interactive_response(self, data) -> (Dict | None): if "interactive" in data["messages"][0]: return data["messages"][0]["interactive"] - def get_location(self, data) -> (Dict | None): + def get_location(self, data): """ Extracts the location of the sender from the data received from the webhook. @@ -784,7 +784,7 @@ def get_location(self, data) -> (Dict | None): if "location" in data["messages"][0]: return data["messages"][0]["location"] - def get_image(self, data) -> (Dict | None): + def get_image(self, data): """ " Extracts the image of the sender from the data received from the webhook. @@ -803,7 +803,7 @@ def get_image(self, data) -> (Dict | None): if "image" in data["messages"][0]: return data["messages"][0]["image"] - def get_document(self, data) -> (Dict | None): + def get_document(self, data): """ " Extracts the document of the sender from the data received from the webhook. @@ -823,7 +823,7 @@ def get_document(self, data) -> (Dict | None): return data["messages"][0]["document"] - def get_audio(self, data) -> (Dict | None): + def get_audio(self, data): """ Extracts the audio of the sender from the data received from the webhook. @@ -843,7 +843,7 @@ def get_audio(self, data) -> (Dict | None): if "audio" in data["messages"][0]: return data["messages"][0]["audio"] - def get_video(self, data) -> (Dict | None): + def get_video(self, data): """ Extracts the video of the sender from the data received from the webhook. @@ -863,7 +863,7 @@ def get_video(self, data) -> (Dict | None): if "video" in data["messages"][0]: return data["messages"][0]["video"] - def get_message_type(self, data) -> (str | None): + def get_message_type(self, data): """ Gets the type of the message sent by the sender from the data received from the webhook. @@ -883,7 +883,7 @@ def get_message_type(self, data) -> (str | None): if "messages" in data: return data["messages"][0]["type"] - def get_delivery(self, data) -> (Dict | None): + def get_delivery(self, data): """ Extracts the delivery status of the message from the data received from the webhook. Args: From fd9df10e0706854ddb92de691ffcd0cad0c078cf Mon Sep 17 00:00:00 2001 From: Filippo Romani Date: Mon, 16 Jan 2023 15:18:09 +0100 Subject: [PATCH 2/2] refactor: add union --- heyoo/__init__.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/heyoo/__init__.py b/heyoo/__init__.py index f3861fb..2608095 100644 --- a/heyoo/__init__.py +++ b/heyoo/__init__.py @@ -656,7 +656,7 @@ def preprocess(self, data): """ return data["entry"][0]["changes"][0]["value"] - def get_mobile(self, data): + def get_mobile(self, data)-> Union[str, None]: """ Extracts the mobile number of the sender from the data received from the webhook. @@ -674,7 +674,7 @@ def get_mobile(self, data): if "contacts" in data: return data["contacts"][0]["wa_id"] - def get_name(self, data): + def get_name(self, data)-> Union[str, None]: """ Extracts the name of the sender from the data received from the webhook. @@ -691,7 +691,7 @@ def get_name(self, data): if contact: return contact["contacts"][0]["profile"]["name"] - def get_message(self, data): + def get_message(self, data)-> Union[str, None]: """ Extracts the text message of the sender from the data received from the webhook. @@ -708,7 +708,7 @@ def get_message(self, data): if "messages" in data: return data["messages"][0]["text"]["body"] - def get_message_id(self, data): + def get_message_id(self, data)-> Union[str, None]: """ Extracts the message id of the sender from the data received from the webhook. @@ -725,7 +725,7 @@ def get_message_id(self, data): if "messages" in data: return data["messages"][0]["id"] - def get_message_timestamp(self, data): + def get_message_timestamp(self, data)-> Union[str, None]: """ " Extracts the timestamp of the message from the data received from the webhook. @@ -742,7 +742,7 @@ def get_message_timestamp(self, data): if "messages" in data: return data["messages"][0]["timestamp"] - def get_interactive_response(self, data): + def get_interactive_response(self, data)-> Union[Dict, None]: """ Extracts the response of the interactive message from the data received from the webhook. @@ -764,7 +764,7 @@ def get_interactive_response(self, data): if "interactive" in data["messages"][0]: return data["messages"][0]["interactive"] - def get_location(self, data): + def get_location(self, data)-> Union[Dict, None]: """ Extracts the location of the sender from the data received from the webhook. @@ -784,7 +784,7 @@ def get_location(self, data): if "location" in data["messages"][0]: return data["messages"][0]["location"] - def get_image(self, data): + def get_image(self, data)-> Union[Dict, None]: """ " Extracts the image of the sender from the data received from the webhook. @@ -803,7 +803,7 @@ def get_image(self, data): if "image" in data["messages"][0]: return data["messages"][0]["image"] - def get_document(self, data): + def get_document(self, data)-> Union[Dict, None]: """ " Extracts the document of the sender from the data received from the webhook. @@ -823,7 +823,7 @@ def get_document(self, data): return data["messages"][0]["document"] - def get_audio(self, data): + def get_audio(self, data)-> Union[Dict, None]: """ Extracts the audio of the sender from the data received from the webhook. @@ -843,7 +843,7 @@ def get_audio(self, data): if "audio" in data["messages"][0]: return data["messages"][0]["audio"] - def get_video(self, data): + def get_video(self, data)-> Union[Dict, None]: """ Extracts the video of the sender from the data received from the webhook. @@ -863,7 +863,7 @@ def get_video(self, data): if "video" in data["messages"][0]: return data["messages"][0]["video"] - def get_message_type(self, data): + def get_message_type(self, data)-> Union[str, None]: """ Gets the type of the message sent by the sender from the data received from the webhook. @@ -883,7 +883,7 @@ def get_message_type(self, data): if "messages" in data: return data["messages"][0]["type"] - def get_delivery(self, data): + def get_delivery(self, data)-> Union[Dict, None]: """ Extracts the delivery status of the message from the data received from the webhook. Args: