Coverage for atlas_ecommerce/purchases/__init__.py: 100%

23 statements  

« prev     ^ index     » next       coverage.py v7.16.0, created at 2026-09-25 16:36 +0000

1from dataclasses import dataclass 

2from datetime import datetime 

3from typing import Any, Protocol 

4 

5from atlas_ecommerce.attribution import OrderAttribution 

6 

7 

8@dataclass(frozen=True) 

9class PurchaseEvent: 

10 """A paid order as the conversion destinations see it, whatever checkout produced it.""" 

11 

12 provider: str 

13 order_id: str 

14 happened_at: datetime 

15 attribution: OrderAttribution 

16 value: str | None = None 

17 currency: str | None = None 

18 quantity: int = 1 

19 variant_id: int | None = None 

20 order_number: int | None = None 

21 paid: bool = True 

22 problem: str | None = None 

23 source_ref: Any = None 

24 

25 

26class PurchaseSource(Protocol): 

27 provider: str 

28 

29 async def unplanned(self, limit: int) -> list[PurchaseEvent]: ... 

30 

31 async def mark_planned(self, purchase: PurchaseEvent) -> None: ... 

32 

33 async def load(self, order_id: str) -> PurchaseEvent | None: ...