from fastapi.routing import APIRouter
from fastapi.requests import Request

from api_validations.validations_request import (
    RegisterServices2Employee,
    RegisterServices2Occupant,
)

from api_services.redis.auth_actions.token import parse_token_object_to_dict


bind_services_route = APIRouter(prefix="/bind/services", tags=["Binds"])
bind_services_route.include_router(bind_services_route, include_in_schema=True)


@bind_services_route.post(path="/occupant", summary="Bind Services to Occupant")
def bind_services_occupant(request: Request, data: RegisterServices2Occupant):
    token_dict = parse_token_object_to_dict(request=request)
    return token_dict.available_event(data=data, token_dict=token_dict)


@bind_services_route.post(path="/employee", summary="Bind Services to Employee")
def bind_services_employee(request: Request, data: RegisterServices2Employee):
    token_dict = parse_token_object_to_dict(request=request)
    return token_dict.available_event(data=data, token_dict=token_dict)
