WIP: config file support

This commit is contained in:
3wc
2024-12-06 21:30:34 -05:00
parent 48905953ca
commit 4fcf972e17
6 changed files with 77 additions and 29 deletions

View File

@ -15,12 +15,10 @@ class KimaiAPI(object):
KIMAI_API_URL = "https://kimai.autonomic.zone/api"
# KIMAI_API_URL = "https://kimaitest.autonomic.zone/api"
KIMAI_USERNAME = "3wordchant"
KIMAI_API_KEY = os.environ["KIMAI_API_KEY"]
auth_headers = {"X-AUTH-USER": KIMAI_USERNAME, "X-AUTH-TOKEN": KIMAI_API_KEY}
def __init__(self):
def __init__(self, username=None, api_key=None):
self.auth_headers = {"X-AUTH-USER": username, "X-AUTH-TOKEN": api_key}
# NOTE: Uncomment the following line to enable requests_cache, which can make development a *lot* faster
# TODO: Add a config option or something for this
# requests_cache.install_cache("kimai", backend="sqlite", expire_after=1800)
self.customers_json = self.get("customers", {"visible": 3})
self.projects_json = self.get("projects", {"visible": 3, "ignoreDates": 1})