refactor, add modularity

This commit is contained in:
sha
2026-03-20 14:09:28 +02:00
parent b56cc63c84
commit 3a701a5280
13 changed files with 354 additions and 273 deletions
+26
View File
@@ -0,0 +1,26 @@
import json
import httpx
from .config import REDMINE_URL, REDMINE_API_KEY
def _headers() -> dict:
return {
"X-Redmine-API-Key": REDMINE_API_KEY,
"Content-Type": "application/json",
}
def _get(path: str, params: dict | None = None) -> dict:
url = f"{REDMINE_URL}{path}"
with httpx.Client(timeout=15) as client:
resp = client.get(url, headers=_headers(), params=params or {})
resp.raise_for_status()
return resp.json()
def _put(path: str, body: dict) -> dict:
url = f"{REDMINE_URL}{path}"
with httpx.Client(timeout=15) as client:
resp = client.put(url, headers=_headers(), content=json.dumps(body))
resp.raise_for_status()
return resp.json() if resp.content else {}