- ExoCrmClient.set_status: live SetStatus needs {Orders: [id], Status} and
replies per order, unlike the documented {ID, Status}
- receipts.crm_status_set_at (migration 0006); set right after creation,
retried by cron, row-locked to avoid a repeat PACKED overwriting a newer status
- CRM errors under capitalized 'Errors' and non-JSON replies are reported
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
18 lines
536 B
Python
18 lines
536 B
Python
"""Protocol клиента CRM — позволяет подменять реализацию в тестах (`StubCrmClient`)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Protocol
|
|
|
|
from app.schemas.orders import OrderOut
|
|
|
|
|
|
class CrmError(Exception):
|
|
"""CRM ответила `status: ERROR` (см. поле `errors` в ответе API)."""
|
|
|
|
|
|
class CrmClient(Protocol):
|
|
async def get_orders(self, *, status: str) -> list[OrderOut]: ...
|
|
|
|
async def set_status(self, *, order_id: str, status: str) -> None: ...
|