|
| 1 | +from abc import abstractmethod |
1 | 2 | from collections.abc import Callable, Coroutine |
2 | 3 | from typing import Any, Generic, Protocol |
3 | 4 |
|
|
8 | 9 |
|
9 | 10 |
|
10 | 11 | class GetOrders(Protocol, Generic[OrderStatusBound]): |
11 | | - """Callable class wrapping an async method that returns a list of Orders. |
| 12 | + """Interface for getting a list of orders or a single order.""" |
12 | 13 |
|
13 | | - Args: |
14 | | - next (str | None): A pagination token. |
15 | | - limit (int): The maximum number of orders to return in a page. |
16 | | - request (Request): FastAPI's Request object. |
17 | | -
|
18 | | - Returns: |
19 | | - A tuple containing a list of orders and a pagination token. |
20 | | -
|
21 | | - - Should return returns.result.Success[tuple[list[Order], returns.maybe.Some[str]]] |
22 | | - if including a pagination token |
23 | | - - Should return returns.result.Success[tuple[list[Order], returns.maybe.Nothing]] |
24 | | - if not including a pagination token |
25 | | - - Returning returns.result.Failure[Exception] will result in a 500. |
26 | | - """ |
27 | | - |
28 | | - async def __call__( |
| 14 | + @abstractmethod |
| 15 | + async def get_orders( |
29 | 16 | self, |
30 | 17 | next: str | None, |
31 | 18 | limit: int, |
32 | 19 | request: Request, |
33 | | - ) -> ResultE[tuple[list[Order[OrderStatusBound]], Maybe[str], Maybe[int]]]: ... |
| 20 | + ) -> ResultE[tuple[list[Order[OrderStatusBound]], Maybe[str], Maybe[int]]]: |
| 21 | + """Get a list of Order objects. |
34 | 22 |
|
| 23 | + Args: |
| 24 | + next (str | None): A pagination token. |
| 25 | + limit (int): The maximum number of orders to return in a page. |
| 26 | + request (Request): FastAPI's Request object. |
35 | 27 |
|
36 | | -class GetOrder(Protocol, Generic[OrderStatusBound]): |
37 | | - """Callable class wrapping an async method that gets details for the order with `order_id`. |
| 28 | + Returns: |
| 29 | + A tuple containing a list of orders and a pagination token. |
38 | 30 |
|
39 | | - Args: |
40 | | - order_id (str): The order ID. |
41 | | - request (Request): FastAPI's Request object. |
| 31 | + - Should return returns.result.Success[tuple[list[Order], returns.maybe.Some[str]]] |
| 32 | + if including a pagination token |
| 33 | + - Should return returns.result.Success[tuple[list[Order], returns.maybe.Nothing]] |
| 34 | + if not including a pagination token |
| 35 | + - Returning returns.result.Failure[Exception] will result in a 500. |
| 36 | + """ |
42 | 37 |
|
43 | | - Returns: |
44 | | - - Should return returns.result.Success[returns.maybe.Some[Order]] if order is found. |
45 | | - - Should return returns.result.Success[returns.maybe.Nothing] if the order is not found or if access is denied. |
46 | | - - Returning returns.result.Failure[Exception] will result in a 500. |
47 | | - """ |
| 38 | + @abstractmethod |
| 39 | + async def get_order(self, order_id: str, request: Request) -> ResultE[Maybe[Order[OrderStatusBound]]]: |
| 40 | + """Get details for the order with `order_id`. |
48 | 41 |
|
49 | | - async def __call__(self, order_id: str, request: Request) -> ResultE[Maybe[Order[OrderStatusBound]]]: ... |
| 42 | + Args: |
| 43 | + order_id (str): The order ID. |
| 44 | + request (Request): FastAPI's Request object. |
| 45 | +
|
| 46 | + Returns: |
| 47 | + - Should return returns.result.Success[returns.maybe.Some[Order]] if order is found. |
| 48 | + - Should return returns.result.Success[returns.maybe.Nothing] if the order is not found or if access is |
| 49 | + denied. |
| 50 | + - Returning returns.result.Failure[Exception] will result in a 500. |
| 51 | + """ |
50 | 52 |
|
51 | 53 |
|
52 | 54 | class GetOrderStatuses(Protocol, Generic[OrderStatusBound]): |
53 | | - """Callable class wrapping an async method that gets statuses for the order with `order_id`. |
54 | | -
|
55 | | - Args: |
56 | | - order_id (str): The order ID. |
57 | | - next (str | None): A pagination token. |
58 | | - limit (int): The maximum number of statuses to return in a page. |
59 | | - request (Request): FastAPI's Request object. |
60 | | -
|
61 | | - Returns: |
62 | | - A tuple containing a list of order statuses and a pagination token. |
63 | | -
|
64 | | - - Should return returns.result.Success[returns.maybe.Some[tuple[list[OrderStatus], returns.maybe.Some[str]]] |
65 | | - if order is found and including a pagination token. |
66 | | - - Should return returns.result.Success[returns.maybe.Some[tuple[list[OrderStatus], returns.maybe.Nothing]]] |
67 | | - if order is found and not including a pagination token. |
68 | | - - Should return returns.result.Success[returns.maybe.Nothing] if the order is not found or if access is denied. |
69 | | - - Returning returns.result.Failure[Exception] will result in a 500. |
70 | | - """ |
71 | | - |
72 | | - async def __call__( |
| 55 | + """Callable class wrapping an async method that gets statuses for the order with `order_id`.""" |
| 56 | + |
| 57 | + @abstractmethod |
| 58 | + async def get_order_statuses( |
73 | 59 | self, order_id: str, _next: str | None, limit: int, request: Request |
74 | | - ) -> ResultE[Maybe[tuple[list[OrderStatusBound], Maybe[str]]]]: ... |
| 60 | + ) -> ResultE[Maybe[tuple[list[OrderStatusBound], Maybe[str]]]]: |
| 61 | + """Method that gets statuses for the order with `order_id`. |
| 62 | +
|
| 63 | + Args: |
| 64 | + order_id (str): The order ID. |
| 65 | + next (str | None): A pagination token. |
| 66 | + limit (int): The maximum number of statuses to return in a page. |
| 67 | + request (Request): FastAPI's Request object. |
| 68 | +
|
| 69 | + Returns: |
| 70 | + A tuple containing a list of order statuses and a pagination token. |
| 71 | +
|
| 72 | + - Should return returns.result.Success[returns.maybe.Some[tuple[list[OrderStatus], returns.maybe.Some[str]]] |
| 73 | + if order is found and including a pagination token. |
| 74 | + - Should return returns.result.Success[returns.maybe.Some[tuple[list[OrderStatus], returns.maybe.Nothing]]] |
| 75 | + if order is found and not including a pagination token. |
| 76 | + - Should return returns.result.Success[returns.maybe.Nothing] if the order is not found or if access is |
| 77 | + denied. |
| 78 | + - Returning returns.result.Failure[Exception] will result in a 500. |
| 79 | + """ |
75 | 80 |
|
76 | 81 |
|
77 | 82 | GetOpportunitySearchRecords = Callable[ |
|
0 commit comments