Fix api documentation

This commit is contained in:
Konstantin Lampalzer 2021-01-17 15:07:11 +01:00
parent 7de2d921d8
commit 210d377e9b
No known key found for this signature in database
GPG key ID: 9A60A522835A2AD9
2 changed files with 16 additions and 1 deletions

View file

@ -19,21 +19,27 @@ class Seeding:
@staticmethod @staticmethod
def get_park() -> int: def get_park() -> int:
"""Get a parkingsapce from the api. """Get a parkingsapce from the api.
:return: An int between 0 and 3 :return: An int between 0 and 3
:rtype: int
""" """
return json.loads(requests.get(API_URL_GET_PARK).content)["id"] return json.loads(requests.get(API_URL_GET_PARK).content)["id"]
@staticmethod @staticmethod
def pay_park() -> bool: def pay_park() -> bool:
"""Pay for parking. """Pay for parking.
:return: True if successful, False if not successful :return: True if successful, False if not successful
:rtype: bool
""" """
return requests.get(API_URL_PAY_PARK).status_code == 200 return requests.get(API_URL_PAY_PARK).status_code == 200
@staticmethod @staticmethod
def simon_says() -> int: def simon_says() -> int:
"""Get next simon says zone from the api. """Get next simon says zone from the api.
:return: An int between 0 and 3 or -1 after making this request 5 times. :return: An int between 0 and 3 or -1 after making this request 5 times.
:rtype: int
""" """
return json.loads(requests.get(API_URL_SIMON_SAYS).content)["id"] return json.loads(requests.get(API_URL_SIMON_SAYS).content)["id"]
@ -53,7 +59,9 @@ class DoubleElim:
@staticmethod @staticmethod
def get_position() -> Position: def get_position() -> Position:
"""Get position of the robot """Get position of the robot
:return: A Position object with robot position :return: A Position object with robot position
:rtype: Position
""" """
response = json.loads(requests.get(API_URL_GET_POS).content) response = json.loads(requests.get(API_URL_GET_POS).content)
return Position(response["x"], response["y"], response["degrees"]) return Position(response["x"], response["y"], response["degrees"])
@ -61,7 +69,9 @@ class DoubleElim:
@staticmethod @staticmethod
def get_opponent() -> Position: def get_opponent() -> Position:
"""Get position of the opponents robot """Get position of the opponents robot
:return: A Position object with opponents robot position :return: A Position object with opponents robot position
:rtype: Position
""" """
response = json.loads(requests.get(API_URL_GET_OP).content) response = json.loads(requests.get(API_URL_GET_OP).content)
return Position(response["x"], response["y"], response["degrees"]) return Position(response["x"], response["y"], response["degrees"])
@ -69,7 +79,9 @@ class DoubleElim:
@staticmethod @staticmethod
def get_goal() -> Position: def get_goal() -> Position:
"""Get position of the goal """Get position of the goal
:return: A Position object with x and y coordinates of the goal, rotation is always -1 :return: A Position object with x and y coordinates of the goal, rotation is always -1
:rtype: Position
""" """
response = json.loads(requests.get(API_URL_GET_GOAL).content) response = json.loads(requests.get(API_URL_GET_GOAL).content)
return Position(response["x"], response["y"], -1) return Position(response["x"], response["y"], -1)
@ -77,6 +89,8 @@ class DoubleElim:
@staticmethod @staticmethod
def get_items() -> list: def get_items() -> list:
"""Get a list with all current items """Get a list with all current items
:return: A list will all items currently on the game field. Items are dictionaries that look like: {"id": 0} :return: A list will all items currently on the game field. Items are dictionaries that look like: {"id": 0}
:rtype: list
""" """
return json.loads(requests.get(API_URL_GET_ITEMS).content) return json.loads(requests.get(API_URL_GET_ITEMS).content)

1
docs/.gitignore vendored
View file

@ -1 +1,2 @@
build build
logs.db