private async Task <HttpResponseMessage> GetJsonAsync(string relativePath, OrderStatusRequest request) { EnsureNotDisposed(); request.GuardNull(nameof(request)); request.ApplyDefaults(_Configuration); request.Validate(); await EnsureAuthTokenValidAsync().ConfigureAwait(false); return(await _HttpClient.GetAsync(new Uri(relativePath, UriKind.Relative)).ConfigureAwait(false)); }
/// <summary> /// Requests the current status of the specified order from the Zip API. /// </summary> /// <param name="request">A <see cref="OrderStatusRequest"/> providing details of the order to return the status of.</param> /// <returns>If successful a <see cref="OrderStatusResponse"/> containing details of the specified order's status. Otherwise throws an exception.</returns> /// <exception cref="System.ArgumentNullException">Thrown if <paramref name="request"/> or any required sub-property is null.</exception> /// <exception cref="System.ArgumentException">Thrown if any sub-property of <paramref name="request"/> is determined to be invalid.</exception> /// <exception cref="ZipApiException">Thrown if the Zip API returns an error response.</exception> /// <exception cref="UnauthorizedAccessException">Thrown if the request to Zip is unauthorised, or if insufficient/incorrect client authentication details have been provided via the <see cref="ZipClientConfiguration"/>.</exception> /// <exception cref="System.Net.Http.HttpRequestException">Thrown for some types of network and HTTP failures, usually where the request has not made it to the server for processing.</exception> /// <exception cref="OperationCanceledException">Thrown if a timeout occurs calling the Zip API.</exception> public async Task <OrderStatusResponse> GetOrderStatusAsync(OrderStatusRequest request) { using (var response = await GetJsonAsync($"v2.0/pos/order/{request.OrderId}/status", request).ConfigureAwait(false)) { if (response.StatusCode == System.Net.HttpStatusCode.OK) { return(await JsonResponseToEntityAsync <OrderStatusResponse>(response).ConfigureAwait(false)); } throw await ZipApiExceptionFromResponseAsync(response).ConfigureAwait(false); } }