Пример #1
0
        /// <summary>
        /// Sends the status.
        /// </summary>
        /// <param name="status">The status.</param>
        /// <returns></returns>
        public async Task <bool> PostStatusAsync(AllfleXML.FlexOrderStatus.OrderStatus status)
        {
            var endpoint   = $"/api/orders/status/{status.WSOrderId}";
            var putMessage = new StringContent(status.Export().ToString(), Encoding.UTF8, "application/xml");

            var response = await _client.PostAsync(endpoint, putMessage);

            if (!response.IsSuccessStatusCode)
            {
                var httpErrorObject = await response.Content.ReadAsStringAsync();

                var uri = new Uri(_client.BaseAddress, endpoint);
                throw new Exception($"Bad response from {uri.ToString()}: {response.StatusCode} - {response.ReasonPhrase}\nThere was an issue with sending the status for the API for order {status.OrderId}, with API id {status.WSOrderId}\n{httpErrorObject}");
            }
            return(response.IsSuccessStatusCode);
        }