public async Task <OfferingResultWriteResponse> WriteAsync(OfferingResult offeringResult, IVendorCredentials credentials) { if (offeringResult == null) { throw new ArgumentNullException(nameof(offeringResult)); } var writeResponse = new OfferingResultWriteResponse(); var client = _httpClientCreator.Create(credentials); var webRequest = new HttpRequestMessage(HttpMethod.Post, _configuration.ServiceUrl) { Content = new StringContent(_serializer.Serialize(offeringResult), Encoding.UTF8, "application/json") }; webRequest.Headers.Add(AuthTokenHeaderKey, _authTokenGenerator.Generate(credentials.Id, credentials.SharedSecret)); var response = await client.SendAsync(webRequest).ConfigureAwait(false);; if (response.IsSuccessStatusCode) { writeResponse.Success = true; } else { writeResponse = ProcessUnsuccessfulRequest(response); } return(writeResponse); }
public async Task <OfferingSaleCancellationResponse> CancelAsync(Guid offeringId, IVendorCredentials credentials) { if (offeringId == Guid.Empty) { throw new ArgumentNullException(nameof(offeringId)); } if (credentials == null) { throw new ArgumentNullException(nameof(credentials)); } var client = _httpClientCreator.Create(credentials); var request = new HttpRequestMessage(HttpMethod.Post, _configuration.ServiceUrl) { Content = new StringContent(_serializer.Serialize(new OfferingSaleCancellationRequest { OfferingId = offeringId }), Encoding.UTF8, "application/json") }; request.Headers.Add(AuthTokenHeaderKey, _authTokenGenerator.Generate(credentials.Id, credentials.SharedSecret)); var response = await client.SendAsync(request).ConfigureAwait(false);; OfferingSaleCancellationResponse cancellationResponse; if (!response.IsSuccessStatusCode) { cancellationResponse = ProcessUnsuccessfulRequest(response); } else { cancellationResponse = new OfferingSaleCancellationResponse { Success = true }; } return(cancellationResponse); }