broker-sync/broker_sync/providers/base.py

33 lines
834 B
Python
Raw Normal View History

from __future__ import annotations
from collections.abc import AsyncIterator
from datetime import datetime
from typing import Protocol
from broker_sync.models import Account, Activity
class Provider(Protocol):
"""Broker connector surface.
Each provider implementation is responsible for fetching raw broker
data, turning it into canonical `Activity` rows (with `account_id`
matching an `Account.id` from `accounts()`), and yielding them.
GBP conversion is performed by the shared normaliser, not here
providers emit native currency and the caller converts.
"""
name: str
def accounts(self) -> list[Account]:
...
def fetch(
self,
*,
since: datetime | None = None,
before: datetime | None = None,
) -> AsyncIterator[Activity]:
...