Tighten provider normalization contract and fallback semantics
This commit is contained in:
@ -1,45 +1,63 @@
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
from apps.providers.contracts import (
|
||||
CompetitionPayload,
|
||||
NormalizedSyncPayload,
|
||||
PlayerCareerPayload,
|
||||
PlayerPayload,
|
||||
PlayerStatsPayload,
|
||||
SeasonPayload,
|
||||
TeamPayload,
|
||||
)
|
||||
|
||||
|
||||
class BaseProviderAdapter(ABC):
|
||||
"""
|
||||
Provider contract for normalized entity payloads consumed by ingestion services.
|
||||
|
||||
Adapters must return provider-agnostic entity dictionaries (see
|
||||
``apps.providers.contracts``) and keep provider-specific response shapes
|
||||
internal to the adapter/client/mapping layer.
|
||||
"""
|
||||
|
||||
namespace: str
|
||||
|
||||
@abstractmethod
|
||||
def search_players(self, *, query: str = "", limit: int = 50, offset: int = 0) -> list[dict]:
|
||||
def search_players(self, *, query: str = "", limit: int = 50, offset: int = 0) -> list[PlayerPayload]:
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
def fetch_player(self, *, external_player_id: str) -> dict | None:
|
||||
def fetch_player(self, *, external_player_id: str) -> PlayerPayload | None:
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
def fetch_players(self) -> list[dict]:
|
||||
def fetch_players(self) -> list[PlayerPayload]:
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
def fetch_competitions(self) -> list[dict]:
|
||||
def fetch_competitions(self) -> list[CompetitionPayload]:
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
def fetch_teams(self) -> list[dict]:
|
||||
def fetch_teams(self) -> list[TeamPayload]:
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
def fetch_seasons(self) -> list[dict]:
|
||||
def fetch_seasons(self) -> list[SeasonPayload]:
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
def fetch_player_stats(self) -> list[dict]:
|
||||
def fetch_player_stats(self) -> list[PlayerStatsPayload]:
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
def fetch_player_careers(self) -> list[dict]:
|
||||
def fetch_player_careers(self) -> list[PlayerCareerPayload]:
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
def sync_all(self) -> dict:
|
||||
def sync_all(self) -> NormalizedSyncPayload:
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
def sync_incremental(self, *, cursor: str | None = None) -> dict:
|
||||
def sync_incremental(self, *, cursor: str | None = None) -> NormalizedSyncPayload:
|
||||
raise NotImplementedError
|
||||
|
||||
Reference in New Issue
Block a user