public async Task GetFaces()

in packages/ekyc-api/src/ekyc-api/Controllers/DataController.cs [74:110]


        public async Task<GetFacesResponse> GetFaces(S3DataRequest request)
        {
            if (request == null)
                throw new HttpStatusException(HttpStatusCode.BadRequest, "Request cannot be blank.");

            var manager = new DataRequestManager(_config, _amazonS3, _dynamoDb);

            if (request.RequestId == null ||
                !manager.DataRequestExistsAndIsValid(request.RequestId).GetAwaiter().GetResult())
                throw new HttpStatusException(HttpStatusCode.BadRequest,
                    "Request is invalid - did you create a new request first?");

            if (string.IsNullOrEmpty(request.s3Key))
                throw new HttpStatusException(HttpStatusCode.BadRequest, "S3 key must be provided.");

            if (string.IsNullOrEmpty(request.documentType))
                throw new HttpStatusException(HttpStatusCode.BadRequest, "DocumentType cannot be blank.");

            DocumentTypes docType;

            if (!Enum.TryParse(request.documentType, out docType))
                throw new HttpStatusException(HttpStatusCode.BadRequest,
                    $"{request.documentType} is not a valid document type.");

            var documentDefinition = await _factory.GetDocumentDefinition(docType);

            if (!documentDefinition.FaceExtractionSupported)
                throw new HttpStatusException(HttpStatusCode.BadRequest,
                    $"Face extraction is not supported for the document type {request.documentType}.");

            var s3Key = request.RequestId + "/" + request.s3Key;
            var ms = await documentDefinition.GetFace(s3Key);

            var imgBase64 = Convert.ToBase64String(ms.ToArray());

            return new GetFacesResponse { Data = imgBase64 };
        }