示例#1
0
        internal static void Main(string[] args)
        {
            Console.WriteLine("Content API for Shopping Command Line Sample");
            Console.WriteLine("============================================");

            ManufacturerConfig config = ManufacturerConfig.Load();

            var initializer = Authenticator.authenticate(config, ManufacturerCenterService.Scope.Manufacturercenter);

            if (initializer == null)
            {
                Console.WriteLine("Failed to authenticate, so exiting.");
                return;
            }

            // Create the service.
            var service = new ManufacturerCenterService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = initializer,
                ApplicationName       = config.ApplicationName,
            });

            ProductsSample productsSample = new ProductsSample(service, MaxListPageSize);

            string manufacturerId = "accounts/" + config.ManufacturerId.ToString();

            productsSample.RunCalls(manufacturerId);
        }
https:  //support.google.com/manufacturers/answer/6124116#id.</param>
        /// <returns>ProductResponse</returns>
        public static Product Get(ManufacturerCenterService service, string parent, string name)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (parent == null)
                {
                    throw new ArgumentNullException(parent);
                }
                if (name == null)
                {
                    throw new ArgumentNullException(name);
                }

                // Make the request.
                return(service.Products.Get(parent, name).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Products.Get failed.", ex);
            }
        }
        /// <param name="optional">Optional paramaters.</param>        /// <returns>ListProductsResponseResponse</returns>
        public static ListProductsResponse List(ManufacturerCenterService service, string parent, ProductsListOptionalParms optional = null)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (parent == null)
                {
                    throw new ArgumentNullException(parent);
                }

                // Building the initial request.
                var request = service.Products.List(parent);

                // Applying optional parameters to the request.
                request = (ProductsResource.ListRequest)SampleHelpers.ApplyOptionalParms(request, optional);

                // Requesting data.
                return(request.Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Products.List failed.", ex);
            }
        }
示例#4
0
        public void RepeatedEnumQueryParameter()
        {
            var service = new ManufacturerCenterService();
            var request = service.Accounts.Products.Get("accounts/abc", "def");

            request.IncludeList = new[] { IncludeEnum.ATTRIBUTES, IncludeEnum.ISSUES };
            var uri = request.CreateRequest().RequestUri;

            Assert.Equal("https://manufacturers.googleapis.com/v1/accounts/abc/products/def?include=ATTRIBUTES&include=ISSUES", uri.ToString());
        }
 internal override void initializeService(BaseClientService.Initializer init, Uri u)
 {
     service = new ManufacturerCenterServiceWithBaseUri(init, u);
 }
 internal override void initializeService(BaseClientService.Initializer init)
 {
     service = new ManufacturerCenterService(init);
 }
 /// <summary>Initializes a new instance of the <see cref="ProductsSample"/> class.</summary>
 /// <param name="service">Content service object on which to run the requests.</param>
 /// <param name="maxListPageSize">The maximum page size to retrieve.</param>
 public ProductsSample(ManufacturerCenterService service, int maxListPageSize)
 {
     this.service         = service;
     this.maxListPageSize = maxListPageSize;
 }