async def get_settings(request: Request, build: int,
                       platform: Platform) -> HTTPResponse:
    """
    Provide the app settings given the build number and platform.

    :return: 200 and JSON-formatted dictionary, 400 on SchemaValidationException.
    """
    settings = Setting.with_build_and_platform(build=build, platform=platform)
    return json_response(settings)
 async def handle_bare_exception(request: Request,
                                 exception: Exception) -> HTTPResponse:
     _LOGGER.exception(exception)
     return json_response(
         body={
             "error_code": ApiException.error_code,
             "message": ApiException.error_message
         },
         status=ApiException.status_code,
     )
 async def handle_unknown_exception(
         request: Request, exception: SanicException) -> HTTPResponse:
     _LOGGER.exception(exception)
     return json_response(
         body={
             "error_code": ApiException.error_code,
             "message": ApiException.error_message
         },
         status=HTTPStatus(exception.status_code),
     )
Exemple #4
0
async def authorize_otp(request: Request, otp: str,
                        symptoms_started_on: date) -> HTTPResponse:
    """
    Authorize the upload of the Mobile Client’s TEKs.

    :param request: the HTTP request object.
    :param otp: the OTP code to authorize.
    :param symptoms_started_on: the date of the first symptoms.
    :return: 204 on OTP successfully authorized, 400 on BadRequest, 409 on OTP already authorized.
    """
    await store(otp=otp,
                otp_data=OtpData(symptoms_started_on=symptoms_started_on))
    return json_response(body=None, status=HTTPStatus.NO_CONTENT)
 async def validated(request: Request, **kwargs: Dict[str,
                                                      Any]) -> HTTPResponse:
     return json_response({})