/// <summary> /// Retrieves the tax settings of the account. This method can only be called for accounts to which the managing account has access: either the managing account itself or sub-accounts if the managing account is a multi-client account. /// Documentation https://developers.google.com/shoppingcontent/v2/reference/accounttax/get /// 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="accountId">The ID of the account for which to get/update account tax settings.</param> /// <returns>AccountTaxResponse</returns> public static AccountTax Get(ShoppingContentService service, string merchantId, string accountId) { try { // Initial validation. if (service == null) { throw new ArgumentNullException("service"); } if (merchantId == null) { throw new ArgumentNullException(merchantId); } if (accountId == null) { throw new ArgumentNullException(accountId); } // Make the request. return(service.Accounttax.Get(merchantId, accountId).Execute()); } catch (Exception ex) { throw new Exception("Request Accounttax.Get failed.", ex); } }
public ShoppingContentService GetShoppingContentService() { if (_contentService == null) { string appPath = System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath; var key = string.Format(@"{0}{1}{2}", appPath, Path.DirectorySeparatorChar, keyPath); var certificate = new X509Certificate2(key, "notasecret", X509KeyStorageFlags.Exportable); var credential = new ServiceAccountCredential( new ServiceAccountCredential.Initializer(serviceAccountEmail) { Scopes = new[] { ShoppingContentService.Scope.Content } }.FromCertificate(certificate)); // Create the service. _contentService = new ShoppingContentService(new BaseClientService.Initializer() { HttpClientInitializer = credential, ApplicationName = "VirtoCommerce shopping integration" }); } return(_contentService); }
/// <summary> /// Retrieves, inserts, and deletes multiple products in a single request. This method can only be called for non-multi-client accounts. /// Documentation https://developers.google.com/shoppingcontent/v2/reference/products/custombatch /// 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="body">A valid ShoppingContent v2 body.</param> /// <param name="optional">Optional paramaters.</param> /// <returns>ProductsCustomBatchResponseResponse</returns> public static ProductsCustomBatchResponse Custombatch(ShoppingContentService service, ProductsCustomBatchRequest body, ProductsCustombatchOptionalParms optional = null) { try { // Initial validation. if (service == null) { throw new ArgumentNullException("service"); } if (body == null) { throw new ArgumentNullException("body"); } // Building the initial request. var request = service.Products.Custombatch(body); // Applying optional parameters to the request. request = (ProductsResource.CustombatchRequest)SampleHelpers.ApplyOptionalParms(request, optional); // Requesting data. return(request.Execute()); } catch (Exception ex) { throw new Exception("Request Products.Custombatch failed.", ex); } }
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); } }
/// <summary> /// Retrieves an order using merchant order id. This method can only be called for non-multi-client accounts. /// Documentation https://developers.google.com/shoppingcontent/v2sandbox/reference/orders/getbymerchantorderid /// 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="merchantOrderId">The merchant order id to be looked for.</param> /// <returns>OrdersGetByMerchantOrderIdResponseResponse</returns> public static OrdersGetByMerchantOrderIdResponse Getbymerchantorderid(ShoppingContentService service, string merchantId, string merchantOrderId) { try { // Initial validation. if (service == null) { throw new ArgumentNullException("service"); } if (merchantId == null) { throw new ArgumentNullException(merchantId); } if (merchantOrderId == null) { throw new ArgumentNullException(merchantOrderId); } // Make the request. return(service.Orders.Getbymerchantorderid(merchantId, merchantOrderId).Execute()); } catch (Exception ex) { throw new Exception("Request Orders.Getbymerchantorderid failed.", ex); } }
internal bool retrieveMCAStatus(ShoppingContentService service, MerchantConfig config) { Console.WriteLine("Retrieving MCA status for configured account."); // The resource returned by Accounts.get() does not have the MCA status, but if // the authenticated user is directly listed as a user of the Merchant Center account // in question, we can see whether it is an MCA or not by calling Accounts.authinfo(). var authinfo = service.Accounts.Authinfo().Execute(); foreach (var accountId in authinfo.AccountIdentifiers) { if (config.MerchantId == accountId.AggregatorId) { return(true); } if (config.MerchantId == accountId.MerchantId) { return(false); } } // If the configured account wasn't listed in the authinfo response, then either // it is a sub-account of an MCA that was listed, or the authenticated user does // not have access. Check this by trying to call Accounts.get(). try { service.Accounts.Get(config.MerchantId, config.MerchantId).Execute(); } catch (Google.GoogleApiException) { throw new ArgumentException(String.Format( "Authenticated user does not have access to account {0}.", config.MerchantId)); } // Sub-accounts cannot be MCAs. return(false); }
/// <summary> /// Updates a shipment's status, carrier, and/or tracking ID. This method can only be called for non-multi-client accounts. /// Documentation https://developers.google.com/shoppingcontent/v2sandbox/reference/orders/updateshipment /// 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>OrdersUpdateShipmentResponseResponse</returns> public static OrdersUpdateShipmentResponse Updateshipment(ShoppingContentService service, string merchantId, string orderId, OrdersUpdateShipmentRequest 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.Updateshipment(body, merchantId, orderId).Execute()); } catch (Exception ex) { throw new Exception("Request Orders.Updateshipment failed.", ex); } }
/// <summary> /// Sandbox only. Retrieves an order template that can be used to quickly create a new order in sandbox. This method can only be called for non-multi-client accounts. /// Documentation https://developers.google.com/shoppingcontent/v2sandbox/reference/orders/gettestordertemplate /// 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="templateName">The name of the template to retrieve.</param> /// <returns>OrdersGetTestOrderTemplateResponseResponse</returns> public static OrdersGetTestOrderTemplateResponse Gettestordertemplate(ShoppingContentService service, string merchantId, string templateName) { try { // Initial validation. if (service == null) { throw new ArgumentNullException("service"); } if (merchantId == null) { throw new ArgumentNullException(merchantId); } if (templateName == null) { throw new ArgumentNullException(templateName); } // Make the request. return(service.Orders.Gettestordertemplate(merchantId, templateName).Execute()); } catch (Exception ex) { throw new Exception("Request Orders.Gettestordertemplate failed.", ex); } }
/// <summary> /// Lists the statuses of the datafeeds in your Merchant Center account. This method can only be called for non-multi-client accounts. /// Documentation https://developers.google.com/shoppingcontent/v2/reference/datafeedstatuses/list /// 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="optional">Optional paramaters.</param> /// <returns>DatafeedstatusesListResponseResponse</returns> public static DatafeedstatusesListResponse List(ShoppingContentService service, string merchantId, DatafeedstatusesListOptionalParms optional = null) { try { // Initial validation. if (service == null) { throw new ArgumentNullException("service"); } if (merchantId == null) { throw new ArgumentNullException(merchantId); } // Building the initial request. var request = service.Datafeedstatuses.List(merchantId); // Applying optional parameters to the request. request = (DatafeedstatusesResource.ListRequest)SampleHelpers.ApplyOptionalParms(request, optional); // Requesting data. return(request.Execute()); } catch (Exception ex) { throw new Exception("Request Datafeedstatuses.List failed.", ex); } }
/// <summary> /// Sandbox only. Moves a test order from state "inProgress" to state "pendingShipment". This method can only be called for non-multi-client accounts. /// Documentation https://developers.google.com/shoppingcontent/v2sandbox/reference/orders/advancetestorder /// 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 test order to modify.</param> /// <returns>OrdersAdvanceTestOrderResponseResponse</returns> public static OrdersAdvanceTestOrderResponse Advancetestorder(ShoppingContentService service, string merchantId, string orderId) { try { // Initial validation. if (service == null) { throw new ArgumentNullException("service"); } if (merchantId == null) { throw new ArgumentNullException(merchantId); } if (orderId == null) { throw new ArgumentNullException(orderId); } // Make the request. return(service.Orders.Advancetestorder(merchantId, orderId).Execute()); } catch (Exception ex) { throw new Exception("Request Orders.Advancetestorder failed.", ex); } }
/// <summary> /// Retrieves the status of a datafeed from your Merchant Center account. This method can only be called for non-multi-client accounts. /// Documentation https://developers.google.com/shoppingcontent/v2/reference/datafeedstatuses/get /// 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">NA</param> /// <param name="datafeedId">NA</param> /// <returns>DatafeedStatusResponse</returns> public static DatafeedStatus Get(ShoppingContentService service, string merchantId, string datafeedId) { try { // Initial validation. if (service == null) { throw new ArgumentNullException("service"); } if (merchantId == null) { throw new ArgumentNullException(merchantId); } if (datafeedId == null) { throw new ArgumentNullException(datafeedId); } // Make the request. return(service.Datafeedstatuses.Get(merchantId, datafeedId).Execute()); } catch (Exception ex) { throw new Exception("Request Datafeedstatuses.Get failed.", ex); } }
public ShoppingContentService GetShoppingContentService() { if (_contentService == null) { string appPath = System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath; var key = string.Format(@"{0}{1}{2}", appPath, Path.DirectorySeparatorChar, keyPath); var certificate = new X509Certificate2(key, "notasecret", X509KeyStorageFlags.Exportable); var credential = new ServiceAccountCredential( new ServiceAccountCredential.Initializer(serviceAccountEmail) { Scopes = new[] { ShoppingContentService.Scope.Content } }.FromCertificate(certificate)); // Create the service. _contentService = new ShoppingContentService(new BaseClientService.Initializer() { HttpClientInitializer = credential, ApplicationName = "VirtoCommerce shopping integration" }); } return _contentService; }
internal override void initializeService(BaseClientService.Initializer init) { service = new ShoppingContentService(init); // Retrieve whether the configured MC account is an MCA via the API. // The sandbox service only has access to Orders methods, so can't // use it for this. config.IsMCA = retrieveMCAStatus(service, config); createSandbox(init, new Uri(service.BaseUri)); }
/// <summary> /// Initializes a new instance of the <see cref="GoogleProductService"/> class. /// </summary> /// <param name="options"></param> /// <param name="contentService"></param> /// <param name="logger"></param> public GoogleProductService( IOptions <GoogleShoppingOptions> options, ShoppingContentService contentService, ILogger <GoogleProductService> logger) { _options = options.Value; _contentService = contentService ?? throw new System.ArgumentNullException(nameof(contentService)); _logger = logger ?? throw new System.ArgumentNullException(nameof(logger)); }
public GoogleShoppingController( IShoppingSettings settingsManager, IGoogleProductProvider productProvider, IPushNotificationManager pushNotificationManager, IDateTimeProvider dateTimeProvider, IGoogleContentServiceProvider googleContentServiceProvider) { _settingsManager = settingsManager; _productProvider = productProvider; _pushNotificationManager = pushNotificationManager; _dateTimeProvider = dateTimeProvider; _contentService = googleContentServiceProvider.GetShoppingContentService(); }
public GoogleShoppingController( IShopping settingsManager, IGoogleProductProvider productProvider, INotifier notifier, IDateTimeProvider dateTimeProvider, IGoogleContentServiceProvider googleContentServiceProvider) { _settingsManager = settingsManager; _productProvider = productProvider; _notifier = notifier; _dateTimeProvider = dateTimeProvider; _contentService = googleContentServiceProvider.GetShoppingContentService(); }
public GoogleShoppingController( IShoppingSettings settingsManager, IGoogleProductProvider productProvider, INotifier notifier, IDateTimeProvider dateTimeProvider, IGoogleContentServiceProvider googleContentServiceProvider) { _settingsManager = settingsManager; _productProvider = productProvider; _notifier = notifier; _dateTimeProvider = dateTimeProvider; _contentService = googleContentServiceProvider.GetShoppingContentService(); }
public ShoppingContentService GetShoppingContentService() { if (_contentService == null) { var credential = _credentialsProvider.GetCredential(); // Create the service. _contentService = new ShoppingContentService(new BaseClientService.Initializer() { HttpClientInitializer = credential, ApplicationName = "VirtoCommerce shopping integration" }); } return(_contentService); }
/// <summary> /// Returns information about the authenticated user. /// Documentation https://developers.google.com/shoppingcontent/v2/reference/accounts/authinfo /// 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> /// <returns>AccountsAuthInfoResponseResponse</returns> public static AccountsAuthInfoResponse Authinfo(ShoppingContentService service) { try { // Initial validation. if (service == null) { throw new ArgumentNullException("service"); } // Make the request. return(service.Accounts.Authinfo().Execute()); } catch (Exception ex) { throw new Exception("Request Accounts.Authinfo failed.", ex); } }
private void createSandbox(BaseClientService.Initializer init, Uri u) { var pathParts = service.BasePath .Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries); var basename = pathParts.Last(); if (basename == "v2") { var newPath = "/" + String.Join("/", pathParts.Take(pathParts.Count() - 1)) + "/v2sandbox/"; sandboxService = new ShoppingContentServiceWithBaseUri(init, new Uri(u, newPath)); } else { Console.WriteLine("Using same API endpoint for sandbox methods."); sandboxService = service; } }
internal static void Main(string[] args) { Console.WriteLine("Content API for Shopping Command Line Sample"); Console.WriteLine("============================================"); GoogleWebAuthorizationBroker.Folder = "ShoppingContent.Sample"; var credential = GoogleWebAuthorizationBroker.AuthorizeAsync( new ClientSecrets { ClientId = CLIENT_ID, ClientSecret = CLIENT_SECRET }, new string[] { ShoppingContentService.Scope.Content}, "user", CancellationToken.None).Result; // Create the service. var service = new ShoppingContentService(new BaseClientService.Initializer() { HttpClientInitializer = credential, ApplicationName = "Shopping Content Sample", }); // Execute the calls. ShoppingContentApiConsumer shoppingContentApiConsumer = new ShoppingContentApiConsumer(service, MaxListPageSize); if (MCA_MERCHANT_ID == 0) { // Non-MCA calls shoppingContentApiConsumer.RunCalls(MERCHANT_ID, EMAIL_ADDRESS, ADWORDS_ACCOUNT_ID); } else { // MCA calls shoppingContentApiConsumer.RunMultiClientAccountCalls(MCA_MERCHANT_ID); } Console.WriteLine("Press any key to continue..."); Console.ReadKey(); }
internal static void Main(string[] args) { Console.WriteLine("Content API for Shopping Command Line Sample"); Console.WriteLine("============================================"); GoogleWebAuthorizationBroker.Folder = "ShoppingContent.Sample"; var credential = GoogleWebAuthorizationBroker.AuthorizeAsync( new ClientSecrets { ClientId = CLIENT_ID, ClientSecret = CLIENT_SECRET }, new string[] { ShoppingContentService.Scope.Content }, "user", CancellationToken.None).Result; // Create the service. var service = new ShoppingContentService(new BaseClientService.Initializer() { HttpClientInitializer = credential, ApplicationName = "Shopping Content Sample", }); // Execute the calls. ShoppingContentApiConsumer shoppingContentApiConsumer = new ShoppingContentApiConsumer(service, MaxListPageSize); if (MCA_MERCHANT_ID == 0) { // Non-MCA calls shoppingContentApiConsumer.RunCalls(MERCHANT_ID, EMAIL_ADDRESS, ADWORDS_ACCOUNT_ID); } else { // MCA calls shoppingContentApiConsumer.RunMultiClientAccountCalls(MCA_MERCHANT_ID); } Console.WriteLine("Press any key to continue..."); Console.ReadKey(); }
/// <summary> /// Updates price and availability of a product in your Merchant Center account. This operation does not update the expiration date of the product. This method can only be called for non-multi-client accounts. /// Documentation https://developers.google.com/shoppingcontent/v2/reference/inventory/set /// 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="storeCode">The code of the store for which to update price and availability. Use online to update price and availability of an online product.</param> /// <param name="productId">The ID of the product for which to update price and availability.</param> /// <param name="body">A valid ShoppingContent v2 body.</param> /// <param name="optional">Optional paramaters.</param> /// <returns>InventorySetResponseResponse</returns> public static InventorySetResponse Set(ShoppingContentService service, string merchantId, string storeCode, string productId, InventorySetRequest body, InventorySetOptionalParms optional = null) { 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 (storeCode == null) { throw new ArgumentNullException(storeCode); } if (productId == null) { throw new ArgumentNullException(productId); } // Building the initial request. var request = service.Inventory.Set(body, merchantId, storeCode, productId); // Applying optional parameters to the request. request = (InventoryResource.SetRequest)SampleHelpers.ApplyOptionalParms(request, optional); // Requesting data. return(request.Execute()); } catch (Exception ex) { throw new Exception("Request Inventory.Set failed.", ex); } }
/// <summary> /// NA /// Documentation https://developers.google.com/shoppingcontent/v2/reference/datafeedstatuses/custombatch /// 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="body">A valid ShoppingContent v2 body.</param> /// <returns>DatafeedstatusesCustomBatchResponseResponse</returns> public static DatafeedstatusesCustomBatchResponse Custombatch(ShoppingContentService service, DatafeedstatusesCustomBatchRequest body) { try { // Initial validation. if (service == null) { throw new ArgumentNullException("service"); } if (body == null) { throw new ArgumentNullException("body"); } // Make the request. return(service.Datafeedstatuses.Custombatch(body).Execute()); } catch (Exception ex) { throw new Exception("Request Datafeedstatuses.Custombatch failed.", ex); } }
/// <summary> /// Updates the tax settings of the account. This method can only be called for accounts to which the managing account has access: either the managing account itself or sub-accounts if the managing account is a multi-client account. /// Documentation https://developers.google.com/shoppingcontent/v2/reference/accounttax/update /// 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="accountId">The ID of the account for which to get/update account tax settings.</param> /// <param name="body">A valid ShoppingContent v2 body.</param> /// <param name="optional">Optional paramaters.</param> /// <returns>AccountTaxResponse</returns> public static AccountTax Update(ShoppingContentService service, string merchantId, string accountId, AccountTax body, AccounttaxUpdateOptionalParms optional = null) { 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 (accountId == null) { throw new ArgumentNullException(accountId); } // Building the initial request. var request = service.Accounttax.Update(body, merchantId, accountId); // Applying optional parameters to the request. request = (AccounttaxResource.UpdateRequest)SampleHelpers.ApplyOptionalParms(request, optional); // Requesting data. return(request.Execute()); } catch (Exception ex) { throw new Exception("Request Accounttax.Update failed.", ex); } }
/// <summary> /// Updates the shipping settings of the account. This method can only be called for accounts to which the managing account has access: either the managing account itself or sub-accounts if the managing account is a multi-client account. This method supports patch semantics. /// Documentation https://developers.google.com/shoppingcontent/v2/reference/shippingsettings/patch /// 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="accountId">The ID of the account for which to get/update shipping settings.</param> /// <param name="body">A valid ShoppingContent v2 body.</param> /// <param name="optional">Optional paramaters.</param> /// <returns>ShippingSettingsResponse</returns> public static ShippingSettings Patch(ShoppingContentService service, string merchantId, string accountId, ShippingSettings body, ShippingsettingsPatchOptionalParms optional = null) { 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 (accountId == null) { throw new ArgumentNullException(accountId); } // Building the initial request. var request = service.Shippingsettings.Patch(body, merchantId, accountId); // Applying optional parameters to the request. request = (ShippingsettingsResource.PatchRequest)SampleHelpers.ApplyOptionalParms(request, optional); // Requesting data. return(request.Execute()); } catch (Exception ex) { throw new Exception("Request Shippingsettings.Patch failed.", ex); } }
/// <summary>Initializes a new instance of the <see cref="ShoppingcontentApiConsumer"/> 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 ShoppingContentApiConsumer(ShoppingContentService service, int maxListPageSize) { this.service = service; this.maxListPageSize = maxListPageSize; }
/// <summary>Initializes a new instance of the <see cref="DatafeedsSample"/> class.</summary> /// <param name="service">Content service object on which to run the requests.</param> public DatafeedsSample(ShoppingContentService service) { this.service = service; }
internal override void initializeService(BaseClientService.Initializer init, Uri u) { service = new ShoppingContentServiceWithBaseUri(init, u); retrieveConfiguration(service, config); createSandbox(init, u); }
// Retrieve the following configuration fields using the Content API: // - IsMCA // - WebsiteUrl // Also use the first Merchant Center account to which the authenticated user has access // if no Merchant Center ID was provided. internal void retrieveConfiguration(ShoppingContentService service, MerchantConfig config) { Console.WriteLine("Retrieving information for authenticated user."); var authinfo = service.Accounts.Authinfo().Execute(); if (authinfo.AccountIdentifiers.Count == 0) { throw new ArgumentException( "Authenticated user has no access to any Merchant Center accounts."); } if (config.MerchantId == null) { var firstAccount = authinfo.AccountIdentifiers[0]; if (firstAccount.MerchantId == null) { config.MerchantId = firstAccount.AggregatorId; } else { config.MerchantId = firstAccount.MerchantId; } Console.WriteLine( "Using Merchant Center {0} for running samples.", config.MerchantId.Value); } ulong merchantId = config.MerchantId.Value; // We detect whether the requested Merchant Center ID is an MCA by checking // Accounts.authinfo(). If it is an MCA, then the authenticated user must be // a user of that account, which means it'll be listed here, and it must // appear in the AggregatorId field of one of the AccountIdentifier entries. config.IsMCA = false; foreach (var accountId in authinfo.AccountIdentifiers) { if (merchantId == accountId.AggregatorId) { config.IsMCA = true; break; } if (merchantId == accountId.MerchantId) { break; } } Console.WriteLine("Merchant Center {0} is{1} an MCA.", merchantId, config.IsMCA ? "" : " not"); var account = service.Accounts.Get(merchantId, merchantId).Execute(); if (!String.IsNullOrEmpty(account.WebsiteUrl)) { config.WebsiteURL = account.WebsiteUrl; Console.WriteLine( "Website for Merchant Center {0}: {1}", merchantId, config.WebsiteURL); } else { Console.WriteLine("Merchant Center {0} has no configured website.", merchantId); } }
public OrdersSample(ShoppingContentService service) { this.service = service; this.prng = new Random(); }
public ProductstatusesSample(ShoppingContentService service, int maxListPageSize) { this.service = service; this.maxListPageSize = maxListPageSize; }
/// <summary>Initializes a new instance of the <see cref="ShippingsettingsSample"/> class.</summary> /// <param name="service">Content service object on which to run the requests.</param> public ShippingsettingsSample(ShoppingContentService service) { this.service = service; }
internal override void initializeService(BaseClientService.Initializer init, Uri u) { service = new ShoppingContentServiceWithBaseUri(init, u); config.IsMCA = retrieveMCAStatus(service, config); createSandbox(init, u); }
/// <summary>Initializes a new instance of the <see cref="AccountsSample"/> class.</summary> /// <param name="service">Content service object on which to run the requests.</param> public AccountsSample(ShoppingContentService service) { this.service = service; }