public void Setup() { _command = _fixture.Create <DebitPledgeCommand>(); var apiResponse = new ApiResponse <DebitPledgeRequest>(new DebitPledgeRequest(_command.PledgeId, new DebitPledgeRequest.DebitPledgeRequestData()), HttpStatusCode.OK, string.Empty); _levyTransferMatchingService = new Mock <ILevyTransferMatchingService>(); _levyTransferMatchingService.Setup(x => x.DebitPledge(It.IsAny <DebitPledgeRequest>())) .Callback <DebitPledgeRequest>(r => _request = r) .ReturnsAsync(apiResponse); _handler = new DebitPledgeCommandHandler(_levyTransferMatchingService.Object, Mock.Of <ILogger <DebitPledgeCommandHandler> >()); }
public async Task <DebitPledgeCommandResult> Handle(DebitPledgeCommand request, CancellationToken cancellationToken) { _logger.LogInformation($"Debiting pledge {request.PledgeId}"); var data = new DebitPledgeRequest.DebitPledgeRequestData { Amount = request.Amount, ApplicationId = request.ApplicationId }; var debitRequest = new DebitPledgeRequest(request.PledgeId, data); var response = await _levyTransferMatchingService.DebitPledge(debitRequest); return(new DebitPledgeCommandResult { ErrorContent = response.ErrorContent, StatusCode = response.StatusCode }); }
public async Task <ApiResponse <DebitPledgeRequest> > DebitPledge(DebitPledgeRequest request) { return(await _levyTransferMatchingApiClient.PostWithResponseCode <DebitPledgeRequest>(request)); }