Skip to content

Commit

Permalink
refactor: change docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
R1D3R175 committed Nov 21, 2023
1 parent b10600e commit 759e998
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions module/otp.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,6 @@ class OTPSender:
Attributes:
authenticated (bool): True if the user is authenticated, False otherwise.
Methods:
login() -> None:
Logs in to the SMTP server. Modifies the authenticated attribute.
send(to: str) -> str | None:
Sends a randomly generated OTP to the specified email address.
Returns the OTP sent to the specified email address.
"""
def __init__(self):
try:
Expand All @@ -53,10 +46,11 @@ def __init__(self):

def login(self) -> None:
"""
Logs in to the SMTP server.
Logs in to the SMTP server. Check the `authenticated` to see if it
was successful or not.
Returns:
None: check self.authenticated for login status.
Raises:
OTPLoginFailed: Something went wrong while trying to contact on the SMTP server.
"""
if self.authenticated:
return
Expand All @@ -72,10 +66,14 @@ def send(self, to: str) -> str:
Sends a randomly generated OTP to the specified email address.
Args:
to (str): The email address of the recipient.
to: The email address of the recipient.
Returns:
str: The OTP sent to the specified email address.
The OTP sent to the specified email address.
Raises:
OTPNotAuthenticated: You have to be logged in order to send mails.
OTPCodeNotSent: Something went wrong while trying to send the mail.
"""
if not self.authenticated:
raise OTPNotAuthenticated('Not authenticated.')
Expand Down

0 comments on commit 759e998

Please sign in to comment.