Skip to content

Commit

Permalink
added docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
vwh committed Jun 14, 2024
1 parent 6fec886 commit 2dd70bf
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]

name = "rbrapi"
version = "0.1"
version = "0.2"

authors = [
{ name="VWH", email="[email protected]" },
Expand Down
58 changes: 56 additions & 2 deletions rbrapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@
class RocketBotRoyale:
def __init__(self, email: str = None, password: str = None) -> None:
"""
Initialize RocketBotRoyale instance with email and password.
Args:
email (str): the account email
password (str): the account password
email (str): The account email.
password (str): The account password.
"""

self.email = email
Expand All @@ -32,6 +34,18 @@ def __init__(self, email: str = None, password: str = None) -> None:
self.authenticate()

def authenticate(self, timeout: int = None) -> "AuthenticateResponse":
"""
Authenticate the user with the RocketBotRoyale API
Args:
timeout (int, optional): Timeout for the request in seconds.
Returns:
AuthenticateResponse: Response object containing authentication details.
Raises:
AuthenticationError: If authentication fails.
"""
data = {
"email": self.email,
"password": self.password,
Expand All @@ -58,6 +72,18 @@ def check(response):
return response_data

def account(self, timeout: int = None) -> "AccountResponse":
"""
Retrieve account details for the authenticated user.
Args:
timeout (int, optional): Timeout for the request in seconds.
Returns:
AccountResponse: Response object containing account details.
Raises:
AuthenticationError: If authentication token is missing or invalid.
"""
if not self.token:
raise AuthenticationError("Token not found or user is unauthenticated")

Expand All @@ -71,6 +97,19 @@ def account(self, timeout: int = None) -> "AccountResponse":
return AccountResponse.from_dict(response)

def collect_timed_bonus(self, timeout: int = None) -> bool:
"""
Collect timed bonus
Args:
timeout (int, optional): Timeout for the request in seconds.
Returns:
bool: True if timed bonus collection was successful.
Raises:
AuthenticationError: If authentication token is missing or invalid.
CollectTimedBonus: If collecting timed bonus fails.
"""
if not self.token:
raise AuthenticationError("Token not found or user is unauthenticated")

Expand All @@ -96,6 +135,21 @@ def check(response):

@staticmethod
def signup(email: str, password: str, username: str, timeout=None) -> bool:
"""
Sign up a new user with the RocketBotRoyale API.
Args:
email (str): New account email.
password (str): New account password.
username (str): Display name for the new account.
timeout (int, optional): Timeout for the request in seconds.
Returns:
bool: True if signup was successful.
Raises:
SignUpError: If signup fails.
"""
data = (
'"{\\"display_name\\":\\"'
+ username
Expand Down
Binary file removed rbrapi/__pycache__/__init__.cpython-312.pyc
Binary file not shown.
Binary file removed rbrapi/__pycache__/errors.cpython-312.pyc
Binary file not shown.
Binary file removed rbrapi/__pycache__/session.cpython-312.pyc
Binary file not shown.
Binary file removed rbrapi/__pycache__/types.cpython-312.pyc
Binary file not shown.
Binary file removed rbrapi/__pycache__/utils.cpython-312.pyc
Binary file not shown.
3 changes: 1 addition & 2 deletions rbrapi/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ def make_request(
fn=None,
data=None,
) -> dict:
"""Make a GET request using the session."""

"""Make a request using the session."""
session = get_session()

if method == "POST":
Expand Down

0 comments on commit 2dd70bf

Please sign in to comment.