Example #1
0
        public async Task <InitiateKycResponseModel> InitiateKycAsync(InitiateKycRequestModel requestModel)
        {
            var kycEntity = await _kycRepository.AddAsync(new KycEntity(requestModel.UserId, KycStatus.Initiated));

            var mrzSubmitRequest  = _mapper.Map <MrzSubmitRequest>(requestModel);
            var mrzSubmitResponse = _mrzProcessor.ProcessMrzFile(mrzSubmitRequest);

            kycEntity.Status = KycStatus.Queued;
            await _kycRepository.UpdateAsync(kycEntity);

            var responseModel = _mapper.Map <InitiateKycResponseModel>(requestModel);

            responseModel.KycId     = kycEntity.Id;
            responseModel.MrzTaskId = mrzSubmitResponse.TaskId;

            // Send Kafka Message
            var kafkaMessage = new KafkaMessage <string, InitiateKycResponseModel>
            {
                Key         = Guid.NewGuid().ToString(),
                Value       = responseModel,
                MessageType = nameof(InitiateKycResponseModel)
            };

            await _initiateKycProducer.ProduceAsync(kafkaMessage);

            return(responseModel);
        }