예제 #1
0
        private OrdersShipLineItemsRequest ShipAllLineItem(ulong merchantId, string orderId,
                                                           OrderLineItem item)
        {
            Console.WriteLine("=================================================================");
            Console.WriteLine("Shipping {0} of item {1}", item.QuantityPending, item.Id);
            Console.WriteLine("=================================================================");

            var itemShip = new OrderShipmentLineItemShipment();

            itemShip.LineItemId = item.Id;
            itemShip.Quantity   = item.QuantityPending;

            var req = new OrdersShipLineItemsRequest();

            req.Carrier    = item.ShippingDetails.Method.Carrier;
            req.ShipmentId = prng.Next().ToString();
            req.TrackingId = prng.Next().ToString();
            req.LineItems  = new List <OrderShipmentLineItemShipment>();
            req.LineItems.Add(itemShip);
            req.OperationId = NewOperationId();

            var resp = sandboxService.Orders.Shiplineitems(req, merchantId, orderId).Execute();

            Console.WriteLine("Finished with status {0}.", resp.ExecutionStatus);
            Console.WriteLine();

            // We return req here so that we have access to the randomly-generated IDs in the
            // main program.
            return(req);
        }
예제 #2
0
        private void LineItemDelivered(ulong merchantId, string orderId,
                                       OrdersShipLineItemsRequest ship)
        {
            Console.WriteLine("=================================================================");
            Console.WriteLine("Delivered {0} of item {1}", ship.LineItems[0].Quantity,
                              ship.LineItems[0].LineItemId);
            Console.WriteLine("=================================================================");

            var req = new OrdersUpdateShipmentRequest();

            req.Carrier     = ship.Carrier;
            req.TrackingId  = ship.TrackingId;
            req.ShipmentId  = ship.ShipmentId;
            req.Status      = "delivered";
            req.OperationId = NewOperationId();

            var resp = sandboxService.Orders.Updateshipment(req, merchantId, orderId).Execute();

            Console.WriteLine("Finished with status {0}.", resp.ExecutionStatus);
            Console.WriteLine();
        }
예제 #3
0
        /// <summary>
        /// Marks line item(s) as shipped. This method can only be called for non-multi-client accounts.
        /// Documentation https://developers.google.com/shoppingcontent/v2sandbox/reference/orders/shiplineitems
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated ShoppingContent service.</param>
        /// <param name="merchantId">The ID of the managing account.</param>
        /// <param name="orderId">The ID of the order.</param>
        /// <param name="body">A valid ShoppingContent v2sandbox body.</param>
        /// <returns>OrdersShipLineItemsResponseResponse</returns>
        public static OrdersShipLineItemsResponse Shiplineitems(ShoppingContentService service, string merchantId, string orderId, OrdersShipLineItemsRequest body)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (merchantId == null)
                {
                    throw new ArgumentNullException(merchantId);
                }
                if (orderId == null)
                {
                    throw new ArgumentNullException(orderId);
                }

                // Make the request.
                return(service.Orders.Shiplineitems(body, merchantId, orderId).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Orders.Shiplineitems failed.", ex);
            }
        }