public SendTrackNotificationResult SendTrackNotification(OrderTrackingInformation orderTrackingInformation) { OrderTrackingInfoAdapter adaptee = new OrderTrackingInfoAdapter(); using (var client = new HttpClient()) { /* * Autenticacao pode ser feita aqui */ var url = ServiceConfiguration.GetConfigurations() .Configuration .GetConfiguration() .ApiUrl; HttpResponseMessage response = null; try { response = client.PostAsync(url, new JsonContent(adaptee.Adapt(orderTrackingInformation))).Result; } catch (Exception ex) { return(new SendTrackNotificationResult(response)); } return(new SendTrackNotificationResult(response)); } }
public void TrackingInfoIsConvertingRightToSalePlatformInfo() { DateTime date = DateTime.Now; OrderTrackingInformation info = new OrderTrackingInformation() { Order_id = 123, Event = new OrderTrackingEvent() { Date = date, Status_id = 1, } }; SalePlatformTrackInfo expected = new SalePlatformTrackInfo() { Date = date, OrderId = 123, Status = "in_transit" }; OrderTrackingInfoAdapter adapter = new OrderTrackingInfoAdapter(); var dest = adapter.Adapt(info); Assert.Equal(expected.Date, dest.Date); Assert.Equal(expected.OrderId, dest.OrderId); Assert.Equal(expected.Status, dest.Status); }