public void PostOrderStatusTest() { // TODO: Build status object. var status = new AllfleXML.FlexOrderStatus.OrderStatus(); bool result; using (var c = new Allflex.API.Client(apiKey, apiUrl)) { result = c.PostStatusAsync(status).Result; } Assert.IsTrue(result); }
/// <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); }
/// <summary> /// Sends the status. /// </summary> /// <param name="status">The status.</param> /// <returns></returns> public bool PostStatus(AllfleXML.FlexOrderStatus.OrderStatus status) { return(PostStatusAsync(status).Result); }