fix: add tasklistsync, fix get_circles response, update SPEC (v0.2.1)

This commit is contained in:
2026-04-15 13:29:01 +02:00
parent 119a0b577e
commit 8262c8440c
4 changed files with 62 additions and 45 deletions
+30 -21
View File
@@ -37,7 +37,11 @@ def _accgetallfamily() -> dict[str, Any]:
client.login(email, password)
data = client.call(
"accgetallfamily",
{"a01call": "taskcategorysync", "a02call": "tasksync"},
{
"a01call": "taskcategorysync",
"a02call": "tasksync",
"a03call": "tasklistsync",
},
)
client.logout()
return data
@@ -48,25 +52,23 @@ def _accgetallfamily() -> dict[str, Any]:
def _extract_lists(data: dict[str, Any]) -> list[dict[str, Any]]:
"""Extract the list of task categories from an accgetallfamily response.
"""Extract task lists from an accgetallfamily response.
SPEC says a00.r.r[], but a02.r.r[] has also been observed.
Both paths are tried defensively; the first non-empty result wins.
Lists live under a03.r.r.updatedCreated[] (tasklistsync).
Args:
data: Raw response body from accgetallfamily.
Returns:
List of raw list-category dicts (may be empty).
List of raw task-list dicts (may be empty).
"""
for key in ("a00", "a02"):
try:
items = data[key]["r"]["r"]
if isinstance(items, list) and items:
logger.debug("Lists found under %s.r.r (%d items)", key, len(items))
return items # type: ignore[return-value]
except (KeyError, TypeError):
continue
try:
items = data["a03"]["r"]["r"]["updatedCreated"]
if isinstance(items, list):
logger.debug("Lists found under a03.r.r.updatedCreated (%d items)", len(items))
return items # type: ignore[return-value]
except (KeyError, TypeError):
pass
return []
@@ -100,13 +102,10 @@ def get_circles() -> str:
"""Return all Family Wall circles (Kreise) the account belongs to.
Each circle has an id and a name.
Because the response structure of the famlistfamily endpoint has not yet
been verified against a live API call, the raw response is returned as
JSON for the first verification pass.
Response structure verified: a00.r.r[] with metaId and name fields.
Returns:
JSON string — either a list of {id, name} objects once the structure
is confirmed, or the raw API response for verification.
JSON string — list of {id, name} objects.
"""
try:
email, password = get_credentials()
@@ -123,9 +122,19 @@ def get_circles() -> str:
except Exception as exc:
return f"Connection error: {exc}"
# Response structure not yet verified — return raw JSON for inspection.
# TODO: once confirmed, extract and return [{id, name}, ...] list.
return json.dumps(data, ensure_ascii=False, indent=2)
try:
raw_circles = data["a00"]["r"]["r"]
if not isinstance(raw_circles, list):
raise TypeError("a00.r.r is not a list")
except (KeyError, TypeError):
return json.dumps(
{"warning": "Unexpected famlistfamily response structure", "raw": data},
ensure_ascii=False,
indent=2,
)
result = [{"id": c.get("metaId"), "name": c.get("name")} for c in raw_circles]
return json.dumps(result, ensure_ascii=False, indent=2)
# ---------------------------------------------------------------------------