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

            var options = new Options();

            CommandLine.Parser.Default.ParseArgumentsStrict(args, options);

            if (options.ConfigPath == null)
            {
                options.ConfigPath = defaultPath;
            }

            MerchantConfig config = MerchantConfig.Load(options.ConfigPath);

            var initializer = Authenticator.authenticate(config, ShoppingContentService.Scope.Content);

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

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

            AccountsSample        accountsSample        = new AccountsSample(service);
            AccountstatusesSample accountstatusesSample =
                new AccountstatusesSample(service, MaxListPageSize);
            AccounttaxSample      accounttaxSample      = new AccounttaxSample(service);
            DatafeedsSample       datafeedsSample       = new DatafeedsSample(service);
            ProductsSample        productsSample        = new ProductsSample(service, MaxListPageSize);
            ProductstatusesSample productstatusesSample =
                new ProductstatusesSample(service, MaxListPageSize);
            ShippingsettingsSample   shippingsettingsSample   = new ShippingsettingsSample(service);
            MultiClientAccountSample multiClientAccountSample = new MultiClientAccountSample(service);

            if (!config.IsMCA)
            {
                // Non-MCA calls
                productsSample.RunCalls(config.MerchantId, config.WebsiteURL);
                productstatusesSample.RunCalls(config.MerchantId);
                datafeedsSample.RunCalls(config.MerchantId);
                accountstatusesSample.RunCalls(config.MerchantId);
                accountsSample.RunCalls(config.MerchantId, config.AccountSampleUser, config.AccountSampleAdWordsCID);
                accounttaxSample.RunCalls(config.MerchantId);
                shippingsettingsSample.RunCalls(config.MerchantId);
            }
            else
            {
                // MCA calls
                accountstatusesSample.RunMultiCalls(config.MerchantId);
                multiClientAccountSample.RunCalls(config.MerchantId);
            }
        }
        internal override void RunCalls()
        {
            AccountsSample        accountsSample        = new AccountsSample(service);
            AccountstatusesSample accountstatusesSample =
                new AccountstatusesSample(service, MaxListPageSize);
            AccounttaxSample      accounttaxSample      = new AccounttaxSample(service);
            DatafeedsSample       datafeedsSample       = new DatafeedsSample(service);
            ProductsSample        productsSample        = new ProductsSample(service, MaxListPageSize);
            ProductstatusesSample productstatusesSample =
                new ProductstatusesSample(service, MaxListPageSize);
            ShippingsettingsSample   shippingsettingsSample   = new ShippingsettingsSample(service);
            MultiClientAccountSample multiClientAccountSample =
                new MultiClientAccountSample(service);

            ulong merchantId = config.MerchantId.Value;

            if (!config.IsMCA)
            {
                // Non-MCA calls
                productsSample.RunCalls(merchantId, config.WebsiteURL);
                //productstatusesSample.RunCalls(merchantId);
                datafeedsSample.RunCalls(merchantId);
                accountstatusesSample.RunCalls(merchantId);
                accountsSample.RunCalls(
                    merchantId, config.AccountSampleUser, config.AccountSampleAdWordsCID);
                accounttaxSample.RunCalls(merchantId);
                shippingsettingsSample.RunCalls(merchantId);
            }
            else
            {
                // MCA calls
                accountstatusesSample.RunMultiCalls(merchantId);
                multiClientAccountSample.RunCalls(merchantId);
            }
        }