Skip to content
This repository was archived by the owner on Apr 2, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/stapi_fastapi/backends/product_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from stapi_fastapi.routers.product_router import ProductRouter

SearchOpportunities = Callable[
[ProductRouter, OpportunityRequest, Request, str | None, int],
[ProductRouter, OpportunityRequest, str | None, int, Request],
Coroutine[Any, Any, ResultE[tuple[list[Opportunity], Maybe[str]]]],
]
"""
Expand All @@ -21,9 +21,9 @@
Args:
product_router (ProductRouter): The product router.
search (OpportunityRequest): The search parameters.
request (Request): FastAPI's Request object.
next (str | None): A pagination token.
limit (int): The maximum number of opportunities to return in a page.
request (Request): FastAPI's Request object.

Returns:
A tuple containing a list of opportunities and a pagination token.
Expand Down
8 changes: 4 additions & 4 deletions src/stapi_fastapi/backends/root_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@
)

GetOrders = Callable[
[Request, str | None, int],
[str | None, int, Request],
Coroutine[Any, Any, ResultE[tuple[list[Order], Maybe[str]]]],
]
"""
Type alias for an async function that returns a list of existing Orders.

Args:
request (Request): FastAPI's Request object.
next (str | None): A pagination token.
limit (int): The maximum number of orders to return in a page.
request (Request): FastAPI's Request object.

Returns:
A tuple containing a list of orders and a pagination token.
Expand Down Expand Up @@ -49,17 +49,17 @@


GetOrderStatuses = Callable[
[str, Request, str | None, int],
[str, str | None, int, Request],
Coroutine[Any, Any, ResultE[tuple[list[T], Maybe[str]]]],
]
"""
Type alias for an async function that gets statuses for the order with `order_id`.

Args:
order_id (str): The order ID.
request (Request): FastAPI's Request object.
next (str | None): A pagination token.
limit (int): The maximum number of statuses to return in a page.
request (Request): FastAPI's Request object.

Returns:
A tuple containing a list of order statuses and a pagination token.
Expand Down
6 changes: 5 additions & 1 deletion src/stapi_fastapi/routers/product_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,11 @@ async def search_opportunities(
"""
links: list[Link] = []
match await self.product._search_opportunities(
self, search, request, next, limit
self,
search,
next,
limit,
request,
):
case Success((features, Some(pagination_token))):
links.append(self.order_link(request))
Expand Down
4 changes: 2 additions & 2 deletions src/stapi_fastapi/routers/root_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ async def get_orders(
self, request: Request, next: str | None = None, limit: int = 10
) -> OrderCollection:
links: list[Link] = []
match await self._get_orders(request, next, limit):
match await self._get_orders(next, limit, request):
case Success((orders, Some(pagination_token))):
for order in orders:
order.links.append(self.order_link(request, order))
Expand Down Expand Up @@ -235,7 +235,7 @@ async def get_order_statuses(
limit: int = 10,
) -> OrderStatuses:
links: list[Link] = []
match await self._get_order_statuses(order_id, request, next, limit):
match await self._get_order_statuses(order_id, next, limit, request):
case Success((statuses, Some(pagination_token))):
links.append(self.order_statuses_link(request, order_id))
links.append(self.pagination_link(request, pagination_token))
Expand Down
6 changes: 3 additions & 3 deletions tests/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@


async def mock_get_orders(
request: Request, next: str | None, limit: int
next: str | None, limit: int, request: Request
) -> ResultE[tuple[list[Order], Maybe[str]]]:
"""
Return orders from backend. Handle pagination/limit if applicable
Expand Down Expand Up @@ -55,7 +55,7 @@ async def mock_get_order(order_id: str, request: Request) -> ResultE[Maybe[Order


async def mock_get_order_statuses(
order_id: str, request: Request, next: str | None, limit: int
order_id: str, next: str | None, limit: int, request: Request
) -> ResultE[tuple[list[OrderStatus], Maybe[str]]]:
try:
start = 0
Expand All @@ -77,9 +77,9 @@ async def mock_get_order_statuses(
async def mock_search_opportunities(
product_router: ProductRouter,
search: OpportunityRequest,
request: Request,
next: str | None,
limit: int,
request: Request,
) -> ResultE[tuple[list[Opportunity], Maybe[str]]]:
try:
start = 0
Expand Down