protected override Task <VerificationAttempt> Verify(ThirdPartyCallRequest request, int attempt, CancellationToken cancellationToken) { var response = new ThirdPartCallResponse { StatusCode = 200 }; return(Task.FromResult(VerificationAttempt.Successful(response))); }
protected sealed override async Task <VerificationAttempt> Verify(TRequest request, int attempt, CancellationToken cancellationToken) { var createValidPayloadTask = CreateValidatePayload(request); // Catch scenario where the implement returns null directly and not a null task if (createValidPayloadTask == null) { return(VerificationAttempt.Unsuccessful()); } var payload = await createValidPayloadTask; if (payload == null) { return(VerificationAttempt.Unsuccessful()); } Data.VerifyHttpRequest = new ThirdPartyHttpRequestData { Method = payload.Method.ToString(), Url = payload.RequestUri.ToString(), Headers = payload.Headers.ToDictionary(x => x.Key, v => v.Value.ToArray()), Body = await payload.Content.ReadAsStringAsync() }; var response = await _httpClient.SendAsync(payload, cancellationToken); var responseText = await response.Content.ReadAsStringAsync(); Data.VerifyHttpResponse = new ThirdPartyHttpResponseData { StatusCode = (int)response.StatusCode, Headers = response.Headers.ToDictionary(x => x.Key, v => v.Value.ToArray()), Body = responseText }; var validateVerifyResponse = ValidateVerifyResponse(Data.VerifyHttpResponse); if (validateVerifyResponse == null) { return(VerificationAttempt.Unsuccessful()); } var result = await validateVerifyResponse; return(result); }