Each cash register stores its own encrypted NP API key. Status polling uses register keys and binds an order to the register whose key sees the TTN as its own (PhoneSender present); ETTN receipts are created from that register. Migration 0008 moves the old NOVA_POSHTA_API_KEY into the default register. Closes #3 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
23 lines
707 B
Python
23 lines
707 B
Python
"""Protocol клиента Nova Poshta — позволяет подменять реализацию в тестах.
|
|
|
|
См. `StubNovaPoshtaClient`.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Protocol
|
|
|
|
from app.schemas.tracking import TrackingStatusOut
|
|
|
|
|
|
class NovaPoshtaError(Exception):
|
|
"""NP API ответил `success: false` (см. поле `errors` в ответе)."""
|
|
|
|
|
|
class NovaPoshtaClient(Protocol):
|
|
"""Ключ API передаётся в каждый вызов: у каждой кассы свой кабинет отправителя."""
|
|
|
|
async def get_statuses(
|
|
self, *, api_key: str, waybill_numbers: list[str]
|
|
) -> list[TrackingStatusOut]: ...
|