/// <summary>Snippet for GetProductBiddingCategoryConstant</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void GetProductBiddingCategoryConstantResourceNames() { // Create client ProductBiddingCategoryConstantServiceClient productBiddingCategoryConstantServiceClient = ProductBiddingCategoryConstantServiceClient.Create(); // Initialize request argument(s) ProductBiddingCategoryConstantName resourceName = ProductBiddingCategoryConstantName.FromCountryCodeLevelId("[COUNTRY_CODE]", "[LEVEL]", "[ID]"); // Make the request ProductBiddingCategoryConstant response = productBiddingCategoryConstantServiceClient.GetProductBiddingCategoryConstant(resourceName); }
/// <summary>Snippet for GetProductBiddingCategoryConstant</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void GetProductBiddingCategoryConstant() { // Create client ProductBiddingCategoryConstantServiceClient productBiddingCategoryConstantServiceClient = ProductBiddingCategoryConstantServiceClient.Create(); // Initialize request argument(s) string resourceName = "productBiddingCategoryConstants/[COUNTRY_CODE]~[LEVEL]~[ID]"; // Make the request ProductBiddingCategoryConstant response = productBiddingCategoryConstantServiceClient.GetProductBiddingCategoryConstant(resourceName); }
/// <summary>Snippet for GetProductBiddingCategoryConstant</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void GetProductBiddingCategoryConstantResourceNames() { // Create client ProductBiddingCategoryConstantServiceClient productBiddingCategoryConstantServiceClient = ProductBiddingCategoryConstantServiceClient.Create(); // Initialize request argument(s) ProductBiddingCategoryConstantName resourceName = ProductBiddingCategoryConstantName.FromProductBiddingCategoryConstant("[PRODUCT_BIDDING_CATEGORY_CONSTANT]"); // Make the request ProductBiddingCategoryConstant response = productBiddingCategoryConstantServiceClient.GetProductBiddingCategoryConstant(resourceName); }
/// <summary>Snippet for GetProductBiddingCategoryConstantAsync</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public async Task GetProductBiddingCategoryConstantAsync() { // Create client ProductBiddingCategoryConstantServiceClient productBiddingCategoryConstantServiceClient = await ProductBiddingCategoryConstantServiceClient.CreateAsync(); // Initialize request argument(s) string resourceName = "productBiddingCategoryConstants/[PRODUCT_BIDDING_CATEGORY_CONSTANT]"; // Make the request ProductBiddingCategoryConstant response = await productBiddingCategoryConstantServiceClient.GetProductBiddingCategoryConstantAsync(resourceName); }
/// <summary>Snippet for GetProductBiddingCategoryConstant</summary> public void GetProductBiddingCategoryConstant() { // Snippet: GetProductBiddingCategoryConstant(string, CallSettings) // Create client ProductBiddingCategoryConstantServiceClient productBiddingCategoryConstantServiceClient = ProductBiddingCategoryConstantServiceClient.Create(); // Initialize request argument(s) string resourceName = "productBiddingCategoryConstants/[PRODUCT_BIDDING_CATEGORY_CONSTANT]"; // Make the request ProductBiddingCategoryConstant response = productBiddingCategoryConstantServiceClient.GetProductBiddingCategoryConstant(resourceName); // End snippet }
/// <summary>Snippet for GetProductBiddingCategoryConstantAsync</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public async Task GetProductBiddingCategoryConstantRequestObjectAsync() { // Create client ProductBiddingCategoryConstantServiceClient productBiddingCategoryConstantServiceClient = await ProductBiddingCategoryConstantServiceClient.CreateAsync(); // Initialize request argument(s) GetProductBiddingCategoryConstantRequest request = new GetProductBiddingCategoryConstantRequest { ResourceNameAsProductBiddingCategoryConstantName = ProductBiddingCategoryConstantName.FromCountryCodeLevelId("[COUNTRY_CODE]", "[LEVEL]", "[ID]"), }; // Make the request ProductBiddingCategoryConstant response = await productBiddingCategoryConstantServiceClient.GetProductBiddingCategoryConstantAsync(request); }
/// <summary>Snippet for GetProductBiddingCategoryConstantAsync</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public async Task GetProductBiddingCategoryConstantRequestObjectAsync() { // Create client ProductBiddingCategoryConstantServiceClient productBiddingCategoryConstantServiceClient = await ProductBiddingCategoryConstantServiceClient.CreateAsync(); // Initialize request argument(s) GetProductBiddingCategoryConstantRequest request = new GetProductBiddingCategoryConstantRequest { ResourceNameAsProductBiddingCategoryConstantName = ProductBiddingCategoryConstantName.FromProductBiddingCategoryConstant("[PRODUCT_BIDDING_CATEGORY_CONSTANT]"), }; // Make the request ProductBiddingCategoryConstant response = await productBiddingCategoryConstantServiceClient.GetProductBiddingCategoryConstantAsync(request); }
/// <summary>Snippet for GetProductBiddingCategoryConstantAsync</summary> public async Task GetProductBiddingCategoryConstantAsync() { // Snippet: GetProductBiddingCategoryConstantAsync(string, CallSettings) // Additional: GetProductBiddingCategoryConstantAsync(string, CancellationToken) // Create client ProductBiddingCategoryConstantServiceClient productBiddingCategoryConstantServiceClient = await ProductBiddingCategoryConstantServiceClient.CreateAsync(); // Initialize request argument(s) string resourceName = "productBiddingCategoryConstants/[PRODUCT_BIDDING_CATEGORY_CONSTANT]"; // Make the request ProductBiddingCategoryConstant response = await productBiddingCategoryConstantServiceClient.GetProductBiddingCategoryConstantAsync(resourceName); // End snippet }
/// <summary>Snippet for GetProductBiddingCategoryConstant</summary> public void GetProductBiddingCategoryConstantRequestObject() { // Snippet: GetProductBiddingCategoryConstant(GetProductBiddingCategoryConstantRequest, CallSettings) // Create client ProductBiddingCategoryConstantServiceClient productBiddingCategoryConstantServiceClient = ProductBiddingCategoryConstantServiceClient.Create(); // Initialize request argument(s) GetProductBiddingCategoryConstantRequest request = new GetProductBiddingCategoryConstantRequest { ResourceNameAsProductBiddingCategoryConstantName = ProductBiddingCategoryConstantName.FromProductBiddingCategoryConstant("[PRODUCT_BIDDING_CATEGORY_CONSTANT]"), }; // Make the request ProductBiddingCategoryConstant response = productBiddingCategoryConstantServiceClient.GetProductBiddingCategoryConstant(request); // End snippet }
/// <summary>Snippet for GetProductBiddingCategoryConstant</summary> public void GetProductBiddingCategoryConstantRequestObject() { // Snippet: GetProductBiddingCategoryConstant(GetProductBiddingCategoryConstantRequest, CallSettings) // Create client ProductBiddingCategoryConstantServiceClient productBiddingCategoryConstantServiceClient = ProductBiddingCategoryConstantServiceClient.Create(); // Initialize request argument(s) GetProductBiddingCategoryConstantRequest request = new GetProductBiddingCategoryConstantRequest { ResourceNameAsProductBiddingCategoryConstantName = ProductBiddingCategoryConstantName.FromCountryCodeLevelId("[COUNTRY_CODE]", "[LEVEL]", "[ID]"), }; // Make the request ProductBiddingCategoryConstant response = productBiddingCategoryConstantServiceClient.GetProductBiddingCategoryConstant(request); // End snippet }
/// <summary>Snippet for GetProductBiddingCategoryConstantAsync</summary> public async Task GetProductBiddingCategoryConstantResourceNamesAsync() { // Snippet: GetProductBiddingCategoryConstantAsync(ProductBiddingCategoryConstantName, CallSettings) // Additional: GetProductBiddingCategoryConstantAsync(ProductBiddingCategoryConstantName, CancellationToken) // Create client ProductBiddingCategoryConstantServiceClient productBiddingCategoryConstantServiceClient = await ProductBiddingCategoryConstantServiceClient.CreateAsync(); // Initialize request argument(s) ProductBiddingCategoryConstantName resourceName = ProductBiddingCategoryConstantName.FromCountryCodeLevelId("[COUNTRY_CODE]", "[LEVEL]", "[ID]"); // Make the request ProductBiddingCategoryConstant response = await productBiddingCategoryConstantServiceClient.GetProductBiddingCategoryConstantAsync(resourceName); // End snippet }
/// <summary>Snippet for GetProductBiddingCategoryConstantAsync</summary> public async Task GetProductBiddingCategoryConstantRequestObjectAsync() { // Snippet: GetProductBiddingCategoryConstantAsync(GetProductBiddingCategoryConstantRequest, CallSettings) // Additional: GetProductBiddingCategoryConstantAsync(GetProductBiddingCategoryConstantRequest, CancellationToken) // Create client ProductBiddingCategoryConstantServiceClient productBiddingCategoryConstantServiceClient = await ProductBiddingCategoryConstantServiceClient.CreateAsync(); // Initialize request argument(s) GetProductBiddingCategoryConstantRequest request = new GetProductBiddingCategoryConstantRequest { ResourceNameAsProductBiddingCategoryConstantName = ProductBiddingCategoryConstantName.FromProductBiddingCategoryConstant("[PRODUCT_BIDDING_CATEGORY_CONSTANT]"), }; // Make the request ProductBiddingCategoryConstant response = await productBiddingCategoryConstantServiceClient.GetProductBiddingCategoryConstantAsync(request); // End snippet }
public void GetProductBiddingCategoryConstant2() { Mock <ProductBiddingCategoryConstantService.ProductBiddingCategoryConstantServiceClient> mockGrpcClient = new Mock <ProductBiddingCategoryConstantService.ProductBiddingCategoryConstantServiceClient>(MockBehavior.Strict); GetProductBiddingCategoryConstantRequest request = new GetProductBiddingCategoryConstantRequest { ResourceName = new ProductBiddingCategoryConstantName("[PRODUCT_BIDDING_CATEGORY_CONSTANT]").ToString(), }; ProductBiddingCategoryConstant expectedResponse = new ProductBiddingCategoryConstant { ResourceName = "resourceName2625949903", }; mockGrpcClient.Setup(x => x.GetProductBiddingCategoryConstant(request, It.IsAny <CallOptions>())) .Returns(expectedResponse); ProductBiddingCategoryConstantServiceClient client = new ProductBiddingCategoryConstantServiceClientImpl(mockGrpcClient.Object, null); ProductBiddingCategoryConstant response = client.GetProductBiddingCategoryConstant(request); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async Task GetProductBiddingCategoryConstantAsync() { Mock <ProductBiddingCategoryConstantService.ProductBiddingCategoryConstantServiceClient> mockGrpcClient = new Mock <ProductBiddingCategoryConstantService.ProductBiddingCategoryConstantServiceClient>(MockBehavior.Strict); GetProductBiddingCategoryConstantRequest expectedRequest = new GetProductBiddingCategoryConstantRequest { ResourceName = new ProductBiddingCategoryConstantName("[PRODUCT_BIDDING_CATEGORY_CONSTANT]").ToString(), }; ProductBiddingCategoryConstant expectedResponse = new ProductBiddingCategoryConstant { ResourceName = "resourceName2625949903", }; mockGrpcClient.Setup(x => x.GetProductBiddingCategoryConstantAsync(expectedRequest, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <ProductBiddingCategoryConstant>(Task.FromResult(expectedResponse), null, null, null, null)); ProductBiddingCategoryConstantServiceClient client = new ProductBiddingCategoryConstantServiceClientImpl(mockGrpcClient.Object, null); string formattedResourceName = new ProductBiddingCategoryConstantName("[PRODUCT_BIDDING_CATEGORY_CONSTANT]").ToString(); ProductBiddingCategoryConstant response = await client.GetProductBiddingCategoryConstantAsync(formattedResourceName); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
/// <summary> /// Runs the code example. /// </summary> /// <param name="client">The Google Ads client.</param> /// <param name="customerId">The Google Ads customer ID for which the call is made.</param> public void Run(GoogleAdsClient client, long customerId) { // Get the GoogleAdsServiceClient . GoogleAdsServiceClient googleAdsService = client.GetService(Services.V10.GoogleAdsService); // Creates the query. string query = "SELECT product_bidding_category_constant.localized_name, " + "product_bidding_category_constant.product_bidding_category_constant_parent " + "FROM product_bidding_category_constant WHERE " + "product_bidding_category_constant.country_code IN ('US') ORDER BY " + "product_bidding_category_constant.localized_name ASC"; // Creates the request. SearchGoogleAdsRequest request = new SearchGoogleAdsRequest() { CustomerId = customerId.ToString(), Query = query }; // Creates a list of top level category nodes. List <CategoryNode> rootCategories = new List <CategoryNode>(); // Creates a map of category ID to category node for all categories found in the // results. // This Map is a convenience lookup to enable fast retrieval of existing nodes. Dictionary <string, CategoryNode> biddingCategories = new Dictionary <string, CategoryNode>(); try { // Performs the search request. foreach (GoogleAdsRow googleAdsRow in googleAdsService.Search(request)) { ProductBiddingCategoryConstant productBiddingCategory = googleAdsRow.ProductBiddingCategoryConstant; string localizedName = productBiddingCategory.LocalizedName; string resourceName = productBiddingCategory.ResourceName; CategoryNode node = null; if (biddingCategories.ContainsKey(resourceName)) { node = biddingCategories[resourceName]; } else { node = new CategoryNode(resourceName, localizedName); biddingCategories[resourceName] = node; } if (string.IsNullOrEmpty(node.LocalizedName)) { // Ensures that the name attribute for the node is set. Name will be null for //nodes added to biddingCategories as a result of being a parentNode below. node.LocalizedName = localizedName; } if (!string.IsNullOrEmpty( productBiddingCategory.ProductBiddingCategoryConstantParent)) { string parentResourceName = productBiddingCategory.ProductBiddingCategoryConstantParent; CategoryNode parentNode = null; if (biddingCategories.ContainsKey(parentResourceName)) { parentNode = biddingCategories[parentResourceName]; } else { parentNode = new CategoryNode(parentResourceName); biddingCategories[parentResourceName] = parentNode; } parentNode.Children.Add(node); } else { rootCategories.Add(node); } } DisplayCategories(rootCategories, ""); } catch (GoogleAdsException e) { Console.WriteLine("Failure:"); Console.WriteLine($"Message: {e.Message}"); Console.WriteLine($"Failure: {e.Failure}"); Console.WriteLine($"Request ID: {e.RequestId}"); throw; } }