/// <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); }
public void ImportFlexOrderStatus2Bad() { AllfleXML.FlexOrderStatus.OrderStatus order = null; Exception err = null; try { order = AllfleXML.FlexOrderStatus.Parser.Import(@"TestData\FlexOrderStatus\sample2bad.xml"); } catch (Exception ex) { err = ex; } Assert.IsNull(order); Assert.IsNotNull(err); }
/// <summary> /// Sends the status. /// </summary> /// <param name="status">The status.</param> /// <returns></returns> public bool PostStatus(AllfleXML.FlexOrderStatus.OrderStatus status) { return(PostStatusAsync(status).Result); }
public void ExportFlexOrderStatus() { var order = new AllfleXML.FlexOrderStatus.OrderStatus { WSOrderId = "8432fe3a-ef38-45bf-af81-f73a5ae7eb8c", PO = "3432564", MasterId = 123456, OrderId = "CC123456", CustomerNumber = "12345", Status = "Confirmed", Progress = 67, Shipment = new List <Shipment>() { new Shipment() { ShipMethod = "UPS", ShippingAccountNumber = "98765432", FreightAmount = 14.56, TrackingNumber = "Z3242FFSD324326SA", ShippingDate = DateTime.Now, Address = new Address() { Name = "John H. Smith", Address1 = "123 Main Street", Address2 = "", Address3 = "", City = "Everytown", State = "TX", PostalCode = "12345", Country = "USA" }, OrderLines = new List <OrderLine>() { new OrderLine() { LineNumber = 123456, ItemNumber = "Test", Quanitity = 3, Progress = 0, Status = "Confirmed", TagManifest = new TagManifest() { Containers = new List <Container>() { new Container() { ChildContainers = null, ID = "", Tags = null, Type = "Bag" } } }, Template = "" } } } }, Messages = new AllfleXML.FlexOrderStatus.Messages() { Message = new List <string> { "This is 1 test message", "This is 2 test message" } } }; var doc = AllfleXML.FlexOrderStatus.Parser.Export(order); Assert.IsNotNull(doc); var result = AllfleXML.FlexOrderStatus.Parser.Validate(doc); Assert.IsTrue(result.Item1); }
public static void Save(this OrderStatus order, string xmlFilePath) { var doc = Export(order); doc.Save(xmlFilePath); }