Skip to content
Snippets Groups Projects
Verified Commit b21cce83 authored by Chris Pastl's avatar Chris Pastl Committed by Ole Binder
Browse files

chore: fetch virtual timeslots, add optional get params

parent a25206c9
Branches
Tags
1 merge request!46Steering playout schema and virtual timeslot integration
......@@ -204,7 +204,9 @@ class SimpleRestApi:
return json_data
@exception_handler
def get(self, url: str, headers: dict = None, timeout: int = 5) -> requests.Response:
def get(
self, url: str, headers: dict = None, params: dict = None, timeout: int = 5
) -> requests.Response:
"""
GET from an URL.
......@@ -222,7 +224,7 @@ class SimpleRestApi:
json_data = None
if not headers:
headers = SimpleRestApi.default_headers
response = requests.get(url, headers=headers, timeout=timeout)
response = requests.get(url, headers=headers, params=params, timeout=timeout)
if headers.get("content-type") == SimpleRestApi.CONTENT_JSON:
json_data = self.deserialize_json(response)
return DotDict({"response": response, "json": json_data})
......@@ -305,7 +307,7 @@ class SimpleCachedRestApi:
self.cache_location = cache_location
self.logger = logging.getLogger(logger_name)
def get(self, url: str, headers: dict = None) -> requests.Response:
def get(self, url: str, headers: dict = None, params: dict = None) -> requests.Response:
"""
GET from an URL while also storing the result in the local cache.
......@@ -322,7 +324,7 @@ class SimpleCachedRestApi:
"""
filename = self.build_filename(url)
cache_filepath = self.cache_location + filename
result = self.simple_api.get(url, headers)
result = self.simple_api.get(url, headers, params)
if result and result.json and result.response.status_code == 200:
with open(cache_filepath, "w") as file:
......
......@@ -160,7 +160,7 @@ class ApiFetcher(threading.Thread):
api_timeslots = None
url = self.url_api_timeslots
self.logger.debug("Fetch timeslots from Steering API...")
result = self.api.get(url)
result = self.api.get(url, params={"includeVirtual": "true"})
api_timeslots = result.json
if not api_timeslots:
return
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment