feat(psa): implement list_members in ConnectWise provider with cache

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Michael Chihlas
2026-03-14 23:45:14 -04:00
parent eeee94f74b
commit 540208a923

View File

@@ -231,7 +231,33 @@ class ConnectWiseProvider(PSAProvider):
return self._map_ticket(data)
async def list_members(self) -> list[PSAMember]:
raise NotImplementedError("Implemented in Slice 5")
"""List CW system members (cached 15 minutes)."""
cache_key = "members:all"
cached = psa_cache.get(cache_key)
if cached is not None:
return cached
data = await self.client.get_paginated(
"/system/members",
params={
"fields": "id,identifier,firstName,lastName,officeEmail",
"conditions": "inactiveFlag = false",
"pageSize": 1000,
},
)
result = [
PSAMember(
id=str(m["id"]),
identifier=m.get("identifier", ""),
name=f"{m.get('firstName', '')} {m.get('lastName', '')}".strip(),
email=m.get("officeEmail"),
)
for m in data
]
psa_cache.set(cache_key, result, ttl_seconds=900)
return result
# ── Private helpers ───────────────────────────────────────────────