changed api client according to specification
bug fixes in VisionDaemon
This commit is contained in:
parent
ce6b06544a
commit
5e46e8068a
6 changed files with 143 additions and 63 deletions
|
@ -1,3 +1,5 @@
|
|||
from typing import Dict, Tuple
|
||||
|
||||
import requests
|
||||
import json
|
||||
import os
|
||||
|
@ -19,37 +21,39 @@ class Seeding:
|
|||
"""
|
||||
|
||||
@staticmethod
|
||||
def get_park() -> int:
|
||||
def get_park() -> Tuple[Dict, int]:
|
||||
"""Get a parkingsapce from the api.
|
||||
|
||||
:return: An int between 0 and 3
|
||||
:rtype: int
|
||||
:return: Json Object and status code as returned by the api.
|
||||
:rtype: Tuple[Dict, int]
|
||||
"""
|
||||
result = json.loads(requests.get(API_URL_GET_PARK).content)["id"]
|
||||
Logging.get_logger().debug(f"Seeding.get_park = {result}")
|
||||
return result
|
||||
res = requests.get(API_URL_GET_PARK)
|
||||
result = json.loads(res.content)
|
||||
Logging.get_logger().debug(f"Seeding.get_park = {result}, status code = {res.status_code}")
|
||||
return result, res.status_code
|
||||
|
||||
@staticmethod
|
||||
def pay_park() -> bool:
|
||||
def pay_park() -> int:
|
||||
"""Pay for parking.
|
||||
|
||||
:return: True if successful, False if not successful
|
||||
:rtype: bool
|
||||
:return: Status code as returned by the api.
|
||||
:rtype: int
|
||||
"""
|
||||
result = requests.get(API_URL_PAY_PARK).status_code == 200
|
||||
result = requests.get(API_URL_PAY_PARK).status_code
|
||||
Logging.get_logger().debug(f"Seeding.pay_park = {result}")
|
||||
return result
|
||||
|
||||
@staticmethod
|
||||
def simon_says() -> int:
|
||||
def simon_says() -> Tuple[Dict, int]:
|
||||
"""Get next simon says zone from the api.
|
||||
|
||||
:return: An int between 0 and 3 or -1 after making this request 5 times.
|
||||
:rtype: int
|
||||
:return: Json Object and status code as returned by the api.
|
||||
:rtype: Tuple[Dict, int]
|
||||
"""
|
||||
result = json.loads(requests.get(API_URL_SIMON_SAYS).content)["id"]
|
||||
Logging.get_logger().debug(f"Seeding.simon_says = {result}")
|
||||
return result
|
||||
res = requests.get(API_URL_SIMON_SAYS)
|
||||
result = json.loads(res.content)
|
||||
Logging.get_logger().debug(f"Seeding.simon_says = {result}, status code = {res.status_code}")
|
||||
return result, res.status_code
|
||||
|
||||
|
||||
class Position:
|
||||
|
|
Reference in a new issue