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

added return types for getter methods #35

Merged
merged 1 commit into from
Oct 10, 2022
Merged
Changes from all commits
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
24 changes: 12 additions & 12 deletions heyoo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ def preprocess(self, data):
"""
return data["entry"][0]["changes"][0]["value"]

def get_mobile(self, data):
def get_mobile(self, data) -> (str | None):
"""
Extracts the mobile number of the sender from the data received from the webhook.

Expand All @@ -655,7 +655,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) -> (str | None):
"""
Extracts the name of the sender from the data received from the webhook.

Expand All @@ -672,7 +672,7 @@ def get_name(self, data):
if contact:
return contact["contacts"][0]["profile"]["name"]

def get_message(self, data):
def get_message(self, data) -> (str | None):
"""
Extracts the text message of the sender from the data received from the webhook.

Expand All @@ -689,7 +689,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) -> (str | None):
"""
Extracts the message id of the sender from the data received from the webhook.

Expand All @@ -706,7 +706,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) -> (str | None):
""" "
Extracts the timestamp of the message from the data received from the webhook.

Expand All @@ -723,7 +723,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) -> (Dict | None):
"""
Extracts the response of the interactive message from the data received from the webhook.

Expand All @@ -745,7 +745,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) -> (Dict | None):
"""
Extracts the location of the sender from the data received from the webhook.

Expand All @@ -765,7 +765,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) -> (Dict | None):
""" "
Extracts the image of the sender from the data received from the webhook.

Expand All @@ -784,7 +784,7 @@ def get_image(self, data):
if "image" in data["messages"][0]:
return data["messages"][0]["image"]

def get_audio(self, data):
def get_audio(self, data) -> (Dict | None):
"""
Extracts the audio of the sender from the data received from the webhook.

Expand All @@ -804,7 +804,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) -> (Dict | None):
"""
Extracts the video of the sender from the data received from the webhook.

Expand All @@ -824,7 +824,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) -> (str | None):
"""
Gets the type of the message sent by the sender from the data received from the webhook.

Expand All @@ -844,7 +844,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) -> (Dict | None):
"""
Extracts the delivery status of the message from the data received from the webhook.
Args:
Expand Down