static void Main(string[] args) { var client = new Client("https://www.mystore.com/mm5/json.mvc", "MY_API_TOKEN", "MY_SIGNING_KEY"); client.DefaultStoreCode = "STORE_CODE"; /// Create a OrderListLoadQuery request instance, passing client to the constructor var request = new OrderListLoadQueryRequest(client); /// include additional order information by including ondemandcolumns request.SetOnDemandColumns(new String[] { "ship_method", // include the shipping method "cust_login", // include the customers login "cust_pw_email", // include the customers email address "business_title", // include the customers business account title "payment_module", // include the payment module information "customer", // include the customer information "items", // include the orders items "charges", // include the orders charges "coupons", // include the orders coupons "discounts", // include the orders discounts "payments" // include the orders payments }); request.AddOnDemandColumn("notes"); // include the orders notes /// Include all custom fields request.AddOnDemandColumn("CustomField_Values:*"); /// Set the list sorting request.SetSort("id", OrderListLoadQueryRequest.SortDirection.ASC); /// If you wish to decrypt payment data, you must provide the passphrase used by your encryption key request.SetPassphrase("MY_ENCRYPTION_KEYS_PASSPHRASE"); // Send the request OrderListLoadQueryResponse response = request.Send(); if (!response.IsSuccess()) { Console.WriteLine("Error: {0}: {1}", response.GetErrorCode(), response.GetErrorMessage()); } else { foreach (Order order in response.GetOrders()) { Console.WriteLine("Order ID {0} With {1} Items, {2} Charges Total {3}", order.GetId(), order.GetItems().Count, order.GetCharges().Count, order.GetFormattedTotal()); } } }
static void Main(string[] args) { var client = new Client("https://www.mystore.com/mm5/json.mvc", "MY_API_TOKEN", "MY_SIGNING_KEY"); client.DefaultStoreCode = "STORE_CODE"; var ordersRequest = new OrderListLoadQueryRequest(client); ordersRequest.Filter.Equal("id", System.Convert.ToUInt32(args[1])); var ordersResponse = ordersRequest.Send(); if (!ordersResponse.IsSuccess()) { Console.WriteLine("Error: {0}: {1}", ordersResponse.GetErrorCode(), ordersResponse.GetErrorMessage()); return; } else if (ordersResponse.GetOrders().Count == 0) { Console.WriteLine("Error: Order Not Found"); return; } foreach (Order order in ordersResponse.GetOrders()) { if (order.GetItems().Count == 0) { Console.WriteLine("Order Has No Items"); continue; } // Create a shipment for all items in the order var createShipmentRequest = new OrderItemListCreateShipmentRequest(client); foreach (OrderItem item in order.GetItems()) { if (item.GetShipmentId() > 0) { // item already has a shipment, skip it continue; } // add it the the shipment we are creating createShipmentRequest.AddOrderItem(item); } var orderShipmentResponse = createShipmentRequest.Send(); if (!orderShipmentResponse.IsSuccess()) { Console.WriteLine("Error: {0}: {1}", orderShipmentResponse.GetErrorCode(), orderShipmentResponse.GetErrorMessage()); return; } var shipment = orderShipmentResponse.GetOrderShipment(); // Now that we have created a shipment for the items in the order we can // assign a tracking number and mark it shipped var shipmentUpdateRequest = new OrderShipmentListUpdateRequest(client); var shipmentUpdate = new OrderShipmentUpdate(); var trackingNumber = String.Format("Z{0}", DateTimeOffset.UtcNow.ToUnixTimeSeconds()); shipmentUpdate.SetCost(1.00) .SetMarkShipped(true) .SetShipmentId(shipment.GetId()) .SetTrackingNumber(trackingNumber) .SetTrackingType("UPS"); shipmentUpdateRequest.AddShipmentUpdate(shipmentUpdate); var shipmentUpdateResponse = shipmentUpdateRequest.Send(); if (!shipmentUpdateResponse.IsSuccess()) { Console.WriteLine("Error: {0}: {1}", shipmentUpdateResponse.GetErrorCode(), shipmentUpdateResponse.GetErrorMessage()); return; } else { Console.WriteLine("Order {0} Shipment {1} Created With Tracking {2}", order.GetId(), shipment.GetId(), trackingNumber); } } }