private static void Main(string[] args) { var apiClient = new ApiClient("94c1aad642bab54521a7b24b2a4f00fa239793b2", "19c2470b27bf8c4ae615273176aa9faa83110b60", "demo"); var clickStats = apiClient.GetStatisticsClicks(DateTime.Today.AddDays(-30), DateTime.Now); var orderStats = apiClient.GetStatisticsOrders(DateTime.Today.AddDays(-30), DateTime.Now); var revenueStats = apiClient.GetStatisticsRevenue(DateTime.Today.AddDays(-30), DateTime.Now); var merchantOrders = apiClient.GetOrders(new[] {OrderStatus.NEW}); foreach (var order in merchantOrders) { var shipment = new Shipment { Lines = new List<ShipmentLine>(), Method = "postNL", TrackTraceNo = "123456", MerchantShipmentNo = "abc123", OrderId = order.Id.GetValueOrDefault() }; foreach (var orderLine in order.Lines) { var line = new ShipmentLine { OrderLineId = orderLine.Id.GetValueOrDefault(), Quantity = orderLine.Quantity, Status = ShipmentLineStatus.SHIPPED }; if (orderLine == order.Lines.Last()) { line.Status = ShipmentLineStatus.MANCO; } shipment.Lines.Add(line); } apiClient.PostShipment(shipment); } Console.ReadLine(); }
/// <summary> /// Create a shipment /// </summary> /// <param name="shipment"></param> /// <returns></returns> public Shipment PostShipment(Shipment shipment) { var route = BASE_PATH + SHIPMENTS_PATH; var response = _client.PostAsJsonAsync(route, shipment).Result; if (!response.IsSuccessStatusCode) throw new Exception(ErrorToMessage(response)); return response.Content.ReadAsAsync<Shipment>().Result; }