コード例 #1
0
        public async Task <FeedAcknowledgement> UpdateBulkInventory(List <Inventory> inventoryItems)
        {
            InventoryFeed inventoryFeed = new InventoryFeed
            {
                InventoryHeader = new InventoryHeader
                {
                    FeedDate = DateTime.UtcNow,
                    Version  = InventoryHeaderVersion.Item14,
                },
                Items = inventoryItems,
            };

            return(await feedApi.UploadFeed(inventoryFeed, V3.Payload.FeedType.inventory));
        }
コード例 #2
0
        private static void RunSample(string username, string password, string accountId,
                                      string language, string country, string productId,
                                      string storeCode)
        {
            // Connect to the service
            ContentForShoppingService service = new ContentForShoppingService("Inventory-Sample", accountId);

            service.setUserCredentials(username, password);

            // Create a new inventory entry
            InventoryEntry entry = new InventoryEntry();

            entry.Availability           = "in stock";
            entry.Price                  = new Price("usd", "250.00");
            entry.Quantity               = 1000;
            entry.SalePrice              = new SalePrice("usd", "199.90");
            entry.SalePriceEffectiveDate = "2012-01-09 2012-01-13";

            // Add necessary EditUri
            bool setEditUri = true;

            entry = service.AddLocalId(entry, language, country, productId, storeCode, setEditUri);

            // Update the product we just constructed
            Console.WriteLine("Updating local product");
            InventoryEntry updated = service.UpdateInventoryEntry(entry);

            // Attempt a similar update via batch
            updated.Quantity = 900;
            updated.Price    = new Price("usd", "240.00");

            updated = service.AddLocalId(updated, language, country, productId, storeCode);
            InventoryFeed feed = service.UpdateInventoryFeed(new List <InventoryEntry> {
                updated
            });

            // Display title and id for each local product
            Console.WriteLine("Listing all inventory returned");
            foreach (InventoryEntry m in feed.Entries)
            {
                Console.WriteLine("Locsl Product: " + m.Title.Text + " (" + m.EditUri + ")");
            }
        }