Пример #1
0
        private static void RunSample(string username, string password, string accountId) {
            // Connect to the service
            ContentForShoppingService service = new ContentForShoppingService("Datafeed-Sample", accountId);
            service.setUserCredentials(username, password);

            // Retrieve the list of all existing accounts
            DatafeedFeed feed = service.QueryDatafeeds();

            // Display title and filename for each datafeed
            Console.WriteLine("Listing all datafeeds returned");
            foreach (DatafeedEntry m in feed.Entries) {
                Console.WriteLine("Datafeed: " + m.Title.Text + " (" + m.FeedFileName + ")");
            }

            // Create a new datafeed entry
            DatafeedEntry entry = new DatafeedEntry();
            entry.Title.Text = "ABC Store Electronics products feed";
            entry.AttributeLanguage = "en";
            entry.ContentLanguage = "en";
            entry.FeedFileName = "electronics.txt";
            entry.TargetCountry = "US";

            FileFormat format = new FileFormat();
            format.Format = "dsv";
            format.Delimiter = "pipe";
            format.Encoding = "utf8";
            format.UseQuotedFields = "no";

            entry.FileFormat = format;

            // Add the datafeed
            Console.WriteLine("Inserting datafeed");
            DatafeedEntry inserted = service.InsertDatafeed(entry);

            // Update the datafeed we just inserted
            Console.WriteLine("Updating datafeed");
            inserted.Title.Text = "DEF Store Electronics products feed";
            DatafeedEntry updated = service.UpdateDatafeed(inserted);

            // Retrieve the new list of datafeeds
            feed = service.QueryDatafeeds();

            // Display title and filename for each datafeed
            Console.WriteLine("Listing all datafeed returned");
            foreach (DatafeedEntry m in feed.Entries) {
                Console.WriteLine("Datafeed: " + m.Title.Text + " (" + m.FeedFileName + ")");
            }

            // Delete the datafeed we inserted and updated
            Console.WriteLine("Deleting datafeed");
            service.DeleteDatafeed(updated);
        }
        private static void RunSample(string username, string password, string accountId) {
            // Connect to the service
            ContentForShoppingService service = new ContentForShoppingService("ManagedAccounts-Sample", accountId);
            service.setUserCredentials(username, password);

            // Retrieve the list of all existing accounts
            ManagedAccountsFeed feed = service.QueryManagedAccounts();

            // Display title and id for each managed account
            Console.WriteLine("Listing all managed accounts returned");
            foreach (ManagedAccountsEntry m in feed.Entries) {
                Console.WriteLine("Managed Account: " + m.Title.Text + " (" + m.InternalId + ")");
            }

            // Create a new subaccount entry
            ManagedAccountsEntry entry = new ManagedAccountsEntry();
            entry.Title.Text = "Bob\'s Shirts";
            AtomContent c = new AtomContent();
            c.Content = "Founded in 1980, Bob has been selling shirts that you don\'t want for over 30 years.";
            entry.Content = c;
            entry.AdultContent = "no";
            entry.InternalId = "Subaccount100";
            entry.ReviewsUrl = "http://my.site.com/reviews?mo=user-rating&user=Subaccount100";

            // Add the subaccount entry
            Console.WriteLine("Inserting managed account");
            ManagedAccountsEntry inserted = service.InsertManagedAccount(entry);

            // Update the managed account we just inserted
            c = new AtomContent();
            c.Content = "Founded in 1980, Bob has been selling shirts that you love for over 30 years.";
            inserted.Content = c;
            Console.WriteLine("Updating managed account");
            ManagedAccountsEntry updated = service.UpdateManagedAccount(inserted);

            // Retrieve the new list of managed accounts
            feed = service.QueryManagedAccounts();

            // Display title and id for each managed account
            Console.WriteLine("Listing all managed accounts returned");
            foreach (ManagedAccountsEntry m in feed.Entries) {
                Console.WriteLine("Managed Account: " + m.Title.Text + " (" + m.InternalId + ")");
            }

            // Delete the managed account we inserted and updated
            Console.WriteLine("Deleting product");
            service.DeleteManagedAccount(updated);
        }
        private static void RunSample(string username, string password, string accountId, string subaccount) {
            // Connect to the service
            ContentForShoppingService service = new ContentForShoppingService("DataQuality-Sample", accountId);
            service.setUserCredentials(username, password);

            // Retrieve the list of DQ feeds for first 25 subaccounts
            DataQualityFeed feed = service.QueryDataQualityFeed();

            // Display title for each entry in the feed
            Console.WriteLine("Listing all data quality feeds returned");
            foreach (DataQualityEntry m in feed.Entries) {
                Console.WriteLine("Entry Name: " + m.Title.Text);
            }

            DataQualityEntry entry = service.GetDataQualityEntry(subaccount);
            Console.WriteLine("Entry Name: " + entry.Title.Text);
        }
Пример #4
0
        private static void RunSample(string username, string password, string accountId) {
            // Connect to the service
            ContentForShoppingService service = new ContentForShoppingService("Users-Sample", accountId);
            service.setUserCredentials(username, password);

            // Retrieve the list of all existing users
            UsersFeed feed = service.QueryUsers();

            // Display title and admin for each user
            Console.WriteLine("Listing all users returned");
            foreach (UsersEntry m in feed.Entries) {
                Console.WriteLine("User: "******" (" + m.Admin + ")");
            }

            // Create a new users entry
            UsersEntry entry = new UsersEntry();
            entry.Title.Text = "*****@*****.**";
            entry.Admin = false;
	        entry.Permissions.Add(new Permission("online", "readwrite"));
	        entry.Permissions.Add(new Permission("local", "noaccess"));

            // Add the user
            Console.WriteLine("Inserting user");
            UsersEntry inserted = service.InsertUser(entry);

            // Update the user we just inserted
            Console.WriteLine("Updating user");
            inserted.Permissions.Add(new Permission("online", "readonly"));
	        inserted.Permissions.Add(new Permission("local", "noaccess"));
            UsersEntry updated = service.UpdateUser(inserted);

            // Retrieve the new list of users
            feed = service.QueryUsers();

            // Display title and admin for each user
            Console.WriteLine("Listing all users returned");
            foreach (UsersEntry m in feed.Entries) {
                Console.WriteLine("User: "******" (" + m.Admin + ")");
            }

            // Delete the user we inserted and updated
            Console.WriteLine("Deleting user");
            service.DeleteUser(updated);
        }
Пример #5
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 + ")");
            }
        }
		private static void RunSample(string username, string password, string accountId) {
			// Connect to the service
			ContentForShoppingService service = new ContentForShoppingService("ContentForShopping-Sample");
			service.setUserCredentials(username, password);

			// Retrieve the list of all existing products
			string projection = "schema";
			ProductQuery query = new ProductQuery(projection, accountId);
			ProductFeed feed = service.Query(query);

			// Display title and id for each product
			Console.WriteLine("Listing all products");
			foreach (ProductEntry p in feed.Entries) {
				Console.WriteLine("Product: " + p.Title.Text + " (" + p.ProductId + ")");
			}

			// Create a new product			
			ProductEntry entry = new ProductEntry();
			entry.Title.Text = "Wool sweater";
			AtomContent c = new AtomContent();
			c.Content = "Comfortable and soft, this sweater will keep you warm on those cold winter nights. Red and blue stripes.";
			entry.Content = c;
			entry.ProductId = "123457";
			entry.Language = "it";
			entry.TargetCountry = "US";
			entry.ContentLanguage = "en";
			entry.Brand = "ACME";
			entry.Condition = "new";
			entry.Price = new Price("usd", "25");
			entry.ProductType = "Clothing & Accessories > Clothing > Outerwear > Sweaters";
			entry.Quantity = 3;
			entry.ShippingWeight = new ShippingWeight("lb", "0.1");
            entry.ImageLink = new ImageLink("http://www.example.com/image.jpg");
            entry.Availability = "available for order";
            entry.Channel = "online";
            entry.Gender = "female";
            entry.Material = "wool";
            entry.Pattern = "Red and blue stripes";
            entry.Color = "red";

			AtomLink link = new AtomLink();
			link.HRef = "http://www.example.com";
			link.Rel = "alternate";
			link.Type = "text/html";
			entry.Links.Add(link);

			// Shipping rules
			Shipping s1 = new Shipping();
			s1.Country = "US";
			s1.Region = "MA";
			s1.Service = "Speedy Shipping - Ground";
			s1.Price = new ShippingPrice("usd", "5.95");

			Shipping s2 = new Shipping();
			s2.Country = "US";
			s2.Region = "024*";
			s2.Service = "Speedy Shipping - Air";
			s2.Price = new ShippingPrice("usd", "7.95");

			entry.ShippingRules.Add(s1);
			entry.ShippingRules.Add(s2);

			// Tax rules
			Tax t1 = new Tax();
			t1.Country = "US";
			t1.Region = "CA";
			t1.Rate = "8.25";
			t1.Ship = true;

			Tax t2 = new Tax();
			t2.Country = "US";
			t2.Region = "926*";
			t2.Rate = "8.75";
			t2.Ship = false;

			entry.TaxRules.Add(t1);
			entry.TaxRules.Add(t2);

			// Additional Image Links
            AdditionalImageLink il1 = new AdditionalImageLink("http://www.example.com/1.jpg");
			entry.AdditionalImageLinks.Add(il1);
            AdditionalImageLink il2 = new AdditionalImageLink("http://www.example.com/2.jpg");
            entry.AdditionalImageLinks.Add(il2);

			// Add the product to the server feed
			Console.WriteLine("Inserting product");
			ProductEntry inserted = service.Insert(feed, entry);

			// Update the product we just inserted
			inserted.Title.Text = "2011 Wool sweater";
			Console.WriteLine("Updating product");
			ProductEntry updated = service.Update(inserted);

			// Retrieve the new list of products
			feed = service.Query(query);

			// Display title and id for each product
			Console.WriteLine("Listing all products again");
			foreach (ProductEntry p in feed.Entries) {
				Console.WriteLine("Product: " + p.Title.Text + " (" + p.ProductId + ")");
			}

			// Delete the item we inserted and updated
			Console.WriteLine("Deleting product");
			service.Delete(updated);
		}