Skip to content

Commit

Permalink
refactoringh
Browse files Browse the repository at this point in the history
  • Loading branch information
bisgaard-itis committed Dec 18, 2024
1 parent 80c1223 commit c82f397
Showing 1 changed file with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from fastapi import FastAPI
from fastapi_pagination import Page, create_page
from models_library.api_schemas_webserver.licensed_items import LicensedItemGetPage
from servicelib.rabbitmq._client_rpc import RabbitMQRPCClient
from servicelib.rabbitmq.rpc_interfaces.webserver.licenses.licensed_items import (
get_licensed_items as _get_licensed_items,
Expand All @@ -20,16 +21,9 @@
class WbApiRpcClient:
_client: RabbitMQRPCClient

@_exception_mapper(rpc_exception_map={})
async def get_licensed_items(
self, product_name: str, page_params: PaginationParams
def _create_licensed_items_get_page(
self, *, licensed_items_page: LicensedItemGetPage, page_params: PaginationParams
) -> Page[LicensedItemGet]:
licensed_items_page = await _get_licensed_items(
rabbitmq_rpc_client=self._client,
product_name=product_name,
offset=page_params.offset,
limit=page_params.limit,
)
page = create_page(
[
LicensedItemGet(
Expand All @@ -48,6 +42,20 @@ async def get_licensed_items(
)
return cast(Page[LicensedItemGet], page)

@_exception_mapper(rpc_exception_map={})
async def get_licensed_items(
self, product_name: str, page_params: PaginationParams
) -> Page[LicensedItemGet]:
licensed_items_page = await _get_licensed_items(
rabbitmq_rpc_client=self._client,
product_name=product_name,
offset=page_params.offset,
limit=page_params.limit,
)
return self._create_licensed_items_get_page(
licensed_items_page=licensed_items_page, page_params=page_params
)


def setup(app: FastAPI, rabbitmq_rmp_client: RabbitMQRPCClient):
app.state.wb_api_rpc_client = WbApiRpcClient(_client=rabbitmq_rmp_client)

0 comments on commit c82f397

Please sign in to comment.