""" Account records endpoint configurations. """ from ApiEvents.abstract_class import ( RouteFactoryConfig, EndpointFactoryConfig, endpoint_wrapper, ) from ApiEvents.base_request_model import EndpointBaseRequestModel from Services.PostgresDb.Models.alchemy_response import DictJsonResponse from fastapi import Request, Path, Body @endpoint_wrapper("/address/list") async def address_list(request: "Request", data: EndpointBaseRequestModel): """Handle address list endpoint.""" auth_dict = address_list.auth code_dict = getattr(address_list, "func_code", {"function_code": None}) return {"auth_dict": auth_dict, "code_dict": code_dict, "data": data} @endpoint_wrapper("/address/create") async def address_create(request: "Request", data: EndpointBaseRequestModel): """Handle address creation endpoint.""" return { "data": data, "request": str(request.headers), "request_url": str(request.url), "request_base_url": str(request.base_url), } @endpoint_wrapper("/address/update/{address_uu_id}") async def address_update( request: Request, address_uu_id: str = Path(..., description="UUID of the address to update"), request_data: EndpointBaseRequestModel = Body(..., description="Request body"), ): """ Handle address update endpoint. Args: request: FastAPI request object address_uu_id: UUID of the address to update request_data: Request body containing updated address data Returns: DictJsonResponse: Response containing updated address info """ auth_dict = address_update.auth return DictJsonResponse( data={ "address_uu_id": address_uu_id, "data": request_data.root, "request": str(request.headers), "request_url": str(request.url), "request_base_url": str(request.base_url), } ) prefix = "/address" # Address Router Configuration ADDRESS_CONFIG = RouteFactoryConfig( name="address", prefix=prefix, tags=["Address"], include_in_schema=True, endpoints=[ EndpointFactoryConfig( url_prefix=prefix, url_endpoint="/list", url_of_endpoint=f"{prefix}/list", endpoint="/list", method="POST", summary="List Active/Delete/Confirm Address", description="List Active/Delete/Confirm Address", is_auth_required=True, is_event_required=True, endpoint_function=address_list, ), EndpointFactoryConfig( url_prefix=prefix, url_endpoint="/create", url_of_endpoint=f"{prefix}/create", endpoint="/create", method="POST", summary="Create Address with given auth levels", description="Create Address with given auth levels", is_auth_required=False, is_event_required=False, endpoint_function=address_create, ), EndpointFactoryConfig( url_prefix=prefix, url_endpoint="/{address_uu_id}", url_of_endpoint="{prefix}/" + "{address_uu_id}", endpoint="/{address_uu_id}", method="PUT", summary="Update Address with given auth levels", description="Update Address with given auth levels", is_auth_required=True, is_event_required=True, endpoint_function=address_update, ), ], ).as_dict()