feat: use taskgettasklists endpoint for get_lists (v0.2.4)
This commit is contained in:
@@ -1 +1 @@
|
||||
__version__ = "0.2.3"
|
||||
__version__ = "0.2.4"
|
||||
|
||||
@@ -166,6 +166,8 @@ def get_circles() -> str:
|
||||
def get_lists(scope: str | None = None) -> str:
|
||||
"""Return all task lists, optionally filtered by circle name.
|
||||
|
||||
Uses the taskgettasklists endpoint directly.
|
||||
|
||||
Args:
|
||||
scope: Optional circle name to filter by. When None, all lists from
|
||||
all circles are returned.
|
||||
@@ -175,30 +177,49 @@ def get_lists(scope: str | None = None) -> str:
|
||||
id, name, type, open, total.
|
||||
"""
|
||||
try:
|
||||
data = _accgetallfamily()
|
||||
email, password = get_credentials()
|
||||
except RuntimeError as exc:
|
||||
return f"Error: {exc}"
|
||||
|
||||
raw_lists = _extract_lists(data)
|
||||
if not raw_lists:
|
||||
# Return raw response for debugging if no lists found at expected path
|
||||
try:
|
||||
with FamilyWallClient() as client:
|
||||
client.login(email, password)
|
||||
data = client.call("taskgettasklists", {})
|
||||
client.logout()
|
||||
except FamilyWallError as exc:
|
||||
return f"Error: {exc}"
|
||||
except Exception as exc:
|
||||
return f"Connection error: {exc}"
|
||||
|
||||
# Try known response patterns; fall back to raw JSON for verification.
|
||||
raw_lists: list[dict[str, Any]] | None = None
|
||||
try:
|
||||
candidate = data["a00"]["r"]["r"]
|
||||
if isinstance(candidate, list):
|
||||
raw_lists = candidate
|
||||
elif isinstance(candidate, dict) and isinstance(candidate.get("updatedCreated"), list):
|
||||
raw_lists = candidate["updatedCreated"]
|
||||
except (KeyError, TypeError):
|
||||
pass
|
||||
|
||||
if raw_lists is None:
|
||||
# Response structure not yet verified — return raw JSON for inspection.
|
||||
return json.dumps(
|
||||
{"warning": "No lists found at expected path", "raw": data},
|
||||
{"warning": "Unexpected taskgettasklists response structure", "raw": data},
|
||||
ensure_ascii=False,
|
||||
indent=2,
|
||||
)
|
||||
|
||||
result = []
|
||||
for item in raw_lists:
|
||||
# _extract_lists already normalises to {id, name, type, open, total}.
|
||||
# TODO: apply scope filtering once the circle field is identified.
|
||||
result.append(
|
||||
{
|
||||
"id": item.get("id"),
|
||||
"id": item.get("metaId"),
|
||||
"name": translate_name(item.get("name", "")),
|
||||
"type": item.get("type"),
|
||||
"open": item.get("open"),
|
||||
"total": item.get("total"),
|
||||
"type": item.get("taskListType"),
|
||||
"open": item.get("remainingTaskNumber"),
|
||||
"total": item.get("totalTaskNumber"),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user