from typing import List from fastapi import APIRouter, HTTPException, Query from loguru import logger from app.controllers.location.ble.space import get_space_location from app.models.domain.location import PositionSpaceResponse from app.schemas.bluetooth import IBeaconBase router = APIRouter() @router.post('/space/users/{user_id}/projects/{project_id}', response_model=PositionSpaceResponse) async def update_in_space(user_id: str, project_id: str, ibeacon_list: List[IBeaconBase]): space_id = await get_space_location(project_id, ibeacon_list) logger.debug(f'{user_id} is in {space_id}') response = { 'userId': user_id, 'projectId': project_id } if space_id: response.update({ 'result': 'success', 'spaceId': space_id }) else: response.update({'result': 'failure'}) return response