diff --git a/src/stapi_fastapi/backends/product_backend.py b/src/stapi_fastapi/backends/product_backend.py index 122382b..f7bc3c0 100644 --- a/src/stapi_fastapi/backends/product_backend.py +++ b/src/stapi_fastapi/backends/product_backend.py @@ -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]]]], ] """ @@ -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. diff --git a/src/stapi_fastapi/backends/root_backend.py b/src/stapi_fastapi/backends/root_backend.py index f072a93..5582f11 100644 --- a/src/stapi_fastapi/backends/root_backend.py +++ b/src/stapi_fastapi/backends/root_backend.py @@ -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. @@ -49,7 +49,7 @@ GetOrderStatuses = Callable[ - [str, Request, str | None, int], + [str, str | None, int, Request], Coroutine[Any, Any, ResultE[tuple[list[T], Maybe[str]]]], ] """ @@ -57,9 +57,9 @@ 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. diff --git a/src/stapi_fastapi/routers/product_router.py b/src/stapi_fastapi/routers/product_router.py index 9f7d0fe..8dbd031 100644 --- a/src/stapi_fastapi/routers/product_router.py +++ b/src/stapi_fastapi/routers/product_router.py @@ -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)) diff --git a/src/stapi_fastapi/routers/root_router.py b/src/stapi_fastapi/routers/root_router.py index e441b21..4aed5da 100644 --- a/src/stapi_fastapi/routers/root_router.py +++ b/src/stapi_fastapi/routers/root_router.py @@ -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)) @@ -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)) diff --git a/tests/backends.py b/tests/backends.py index 0810bf7..7b17d92 100644 --- a/tests/backends.py +++ b/tests/backends.py @@ -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 @@ -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 @@ -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