Pre-optimization commit: Calendar sync implementation with hub design

This commit is contained in:
root
2025-10-23 08:29:46 +00:00
parent 2f9203cac2
commit 1de5bcd369
12 changed files with 506 additions and 954 deletions

View File

@@ -133,7 +133,7 @@ class AdvowareAPI:
try:
self._log(f"Making API call: {method} {url}")
async with session.request(method, url, headers=effective_headers, params=params, json=json_data) as response:
self._log(f"API response status: {response.status}")
response.raise_for_status()
if response.status == 401:
self._log("401 Unauthorized, refreshing token")
token = self.get_access_token(force_refresh=True)
@@ -142,7 +142,19 @@ class AdvowareAPI:
response.raise_for_status()
return await response.json() if response.content_type == 'application/json' else None
response.raise_for_status()
return await response.json() if response.content_type == 'application/json' else None
if response.content_type == 'application/json':
try:
return await response.json()
except Exception as e:
self._log(f"JSON parse error: {e}")
try:
text = await response.text()
self._log(f"Response text: {text}")
except Exception as text_e:
self._log(f"Error getting response text: {text_e}")
raise
else:
return None
except aiohttp.ClientError as e:
self._log(f"API call failed: {e}")
raise