Files
resolutionflow/backend/app/services/psa/connectwise/provider.py
Michael Chihlas 2086ecb5ea feat(psa): add ConnectWiseProvider with test_connection + provider registry
ConnectWiseProvider implements PSAProvider with test_connection() that
calls GET /system/info to verify credentials and connectivity. All other
methods raise NotImplementedError with slice references for future work.

Provider registry (get_provider_for_account) looks up the account's
PsaConnection, decrypts stored credentials, and instantiates the
correct provider. Currently supports connectwise only.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-14 21:52:23 -04:00

77 lines
2.5 KiB
Python

"""ConnectWise implementation of PSAProvider."""
from __future__ import annotations
from app.services.psa.base import PSAProvider
from app.services.psa.types import (
ConnectionTestResult,
PSATicket,
PSANote,
PSAStatus,
PSACompany,
PSAMember,
PSAConfiguration,
)
from .client import ConnectWiseClient
class ConnectWiseProvider(PSAProvider):
"""ConnectWise PSA provider implementation."""
def __init__(self, client: ConnectWiseClient):
self.client = client
async def test_connection(self) -> ConnectionTestResult:
"""Test the CW connection by fetching system info."""
try:
info = await self.client.get("/system/info")
return ConnectionTestResult(
success=True,
message="Connected successfully.",
server_version=info.get("version", None),
)
except Exception as e:
return ConnectionTestResult(
success=False,
message=str(e),
server_version=None,
)
# ── Stubs for Phase A slices 2-5 ─────────────────────────────────
async def get_ticket(self, ticket_id: str) -> PSATicket:
raise NotImplementedError("Implemented in Slice 2")
async def search_tickets(self, query: str, **filters) -> list[PSATicket]:
raise NotImplementedError("Implemented in Slice 3")
async def post_note(
self,
ticket_id: str,
text: str,
note_type: str,
member_id: str | None = None,
) -> PSANote:
raise NotImplementedError("Implemented in Slice 4")
async def update_ticket_status(
self, ticket_id: str, status_id: int
) -> PSATicket:
raise NotImplementedError("Implemented in Slice 4")
async def get_ticket_statuses(self, board_id: int) -> list[PSAStatus]:
raise NotImplementedError("Implemented in Slice 3")
async def list_companies(self, **filters) -> list[PSACompany]:
raise NotImplementedError("Implemented in Slice 3")
async def get_company(self, company_id: str) -> PSACompany:
raise NotImplementedError("Implemented in Slice 3")
async def list_members(self) -> list[PSAMember]:
raise NotImplementedError("Implemented in Slice 5")
async def get_ticket_configurations(
self, ticket_id: str
) -> list[PSAConfiguration]:
raise NotImplementedError("Implemented in Slice 3")