from rest_framework.decorators import api_view
from rest_framework.request import Request
from rest_framework.response import Response


@api_view(['POST'])
def sign_up(request: Request, *args, **kwargs):
    from users.interfaces.signup import as_view

    rslt = as_view(request, *args, **kwargs)
    return Response(rslt.data or rslt.messages, status=rslt.status_code)


@api_view(['POST'])
def refresh_login(request: Request, *args, **kwargs):
    from users.interfaces.refresh_login import as_view

    ret = as_view(request, *args, **kwargs)
    return Response(ret.data or ret.messages, status=ret.status_code)


@api_view(['POST'])
def has_login(request: Request, *args, **kwargs):
    from users.interfaces.has_login import as_view

    ret = as_view(request, *args, **kwargs)
    return Response(ret.data, status=ret.status_code)


@api_view(['POST'])
def login(request: Request, *args, **kwargs):
    from users.interfaces.login import as_view

    ret = as_view(request, *args, **kwargs)
    return Response(ret.data or ret.messages, status=ret.status_code)


@api_view(['POST'])
def send_verification_code(request: Request, *args, **kwargs):
    from users.interfaces.vcode_sender import as_view

    as_view(request, *args, **kwargs)
    return Response(data=None, status=200)


@api_view(['POST'])
def confirmation(request: Request, *args, **kwargs):
    from users.interfaces.confirmation import as_view

    ret = as_view(request, *args, **kwargs)
    return Response(ret.data or ret.messages, status=ret.status_code)


@api_view(['POST'])
def forgot_password(request: Request, *args, **kwargs):
    from users.interfaces.forgot_password import as_view

    ret = as_view(request, *args, **kwargs)
    return Response(ret.data or ret.messages, status=ret.status_code)


@api_view(['GET'])
def get_roles(request: Request, *args, **kwargs):
    from users.interfaces.get_roles import as_view

    ret = as_view(request, *args, **kwargs)
    return Response(ret.data or ret.messages, status=ret.status_code)
