/// <summary>Snippet for GetAdParameter</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void GetAdParameterResourceNames() { // Create client AdParameterServiceClient adParameterServiceClient = AdParameterServiceClient.Create(); // Initialize request argument(s) AdParameterName resourceName = AdParameterName.FromCustomerAdGroupCriterionParameterIndex("[CUSTOMER_ID]", "[AD_GROUP_ID]", "[CRITERION_ID]", "[PARAMETER_INDEX]"); // Make the request AdParameter response = adParameterServiceClient.GetAdParameter(resourceName); }
/// <summary>Snippet for GetAdParameter</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void GetAdParameter() { // Create client AdParameterServiceClient adParameterServiceClient = AdParameterServiceClient.Create(); // Initialize request argument(s) string resourceName = "customers/[CUSTOMER_ID]/adParameters/[AD_GROUP_ID]~[CRITERION_ID]~[PARAMETER_INDEX]"; // Make the request AdParameter response = adParameterServiceClient.GetAdParameter(resourceName); }
/// <summary>Snippet for GetAdParameter</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void GetAdParameterResourceNames() { // Create client AdParameterServiceClient adParameterServiceClient = AdParameterServiceClient.Create(); // Initialize request argument(s) AdParameterName resourceName = AdParameterName.FromCustomerAdParameter("[CUSTOMER]", "[AD_PARAMETER]"); // Make the request AdParameter response = adParameterServiceClient.GetAdParameter(resourceName); }
/// <summary>Snippet for GetAdParameterAsync</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 GetAdParameterAsync() { // Create client AdParameterServiceClient adParameterServiceClient = await AdParameterServiceClient.CreateAsync(); // Initialize request argument(s) string resourceName = "customers/[CUSTOMER]/adParameters/[AD_PARAMETER]"; // Make the request AdParameter response = await adParameterServiceClient.GetAdParameterAsync(resourceName); }
/// <summary>Snippet for GetAdParameter</summary> public void GetAdParameter() { // Snippet: GetAdParameter(string, CallSettings) // Create client AdParameterServiceClient adParameterServiceClient = AdParameterServiceClient.Create(); // Initialize request argument(s) string resourceName = "customers/[CUSTOMER]/adParameters/[AD_PARAMETER]"; // Make the request AdParameter response = adParameterServiceClient.GetAdParameter(resourceName); // End snippet }
/// <summary>Snippet for GetAdParameterAsync</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 GetAdParameterRequestObjectAsync() { // Create client AdParameterServiceClient adParameterServiceClient = await AdParameterServiceClient.CreateAsync(); // Initialize request argument(s) GetAdParameterRequest request = new GetAdParameterRequest { ResourceNameAsAdParameterName = AdParameterName.FromCustomerAdParameter("[CUSTOMER]", "[AD_PARAMETER]"), }; // Make the request AdParameter response = await adParameterServiceClient.GetAdParameterAsync(request); }
/// <summary>Snippet for GetAdParameterAsync</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 GetAdParameterRequestObjectAsync() { // Create client AdParameterServiceClient adParameterServiceClient = await AdParameterServiceClient.CreateAsync(); // Initialize request argument(s) GetAdParameterRequest request = new GetAdParameterRequest { ResourceNameAsAdParameterName = AdParameterName.FromCustomerAdGroupCriterionParameterIndex("[CUSTOMER_ID]", "[AD_GROUP_ID]", "[CRITERION_ID]", "[PARAMETER_INDEX]"), }; // Make the request AdParameter response = await adParameterServiceClient.GetAdParameterAsync(request); }
/// <summary>Snippet for GetAdParameterAsync</summary> public async Task GetAdParameterAsync() { // Snippet: GetAdParameterAsync(string, CallSettings) // Additional: GetAdParameterAsync(string, CancellationToken) // Create client AdParameterServiceClient adParameterServiceClient = await AdParameterServiceClient.CreateAsync(); // Initialize request argument(s) string resourceName = "customers/[CUSTOMER]/adParameters/[AD_PARAMETER]"; // Make the request AdParameter response = await adParameterServiceClient.GetAdParameterAsync(resourceName); // End snippet }
/// <summary>Snippet for GetAdParameter</summary> public void GetAdParameterRequestObject() { // Snippet: GetAdParameter(GetAdParameterRequest, CallSettings) // Create client AdParameterServiceClient adParameterServiceClient = AdParameterServiceClient.Create(); // Initialize request argument(s) GetAdParameterRequest request = new GetAdParameterRequest { ResourceNameAsAdParameterName = AdParameterName.FromCustomerAdParameter("[CUSTOMER]", "[AD_PARAMETER]"), }; // Make the request AdParameter response = adParameterServiceClient.GetAdParameter(request); // End snippet }
/// <summary>Snippet for GetAdParameterAsync</summary> public async Task GetAdParameterResourceNamesAsync() { // Snippet: GetAdParameterAsync(AdParameterName, CallSettings) // Additional: GetAdParameterAsync(AdParameterName, CancellationToken) // Create client AdParameterServiceClient adParameterServiceClient = await AdParameterServiceClient.CreateAsync(); // Initialize request argument(s) AdParameterName resourceName = AdParameterName.FromCustomerAdParameter("[CUSTOMER]", "[AD_PARAMETER]"); // Make the request AdParameter response = await adParameterServiceClient.GetAdParameterAsync(resourceName); // End snippet }
public void GetAdParameter2() { Mock <AdParameterService.AdParameterServiceClient> mockGrpcClient = new Mock <AdParameterService.AdParameterServiceClient>(MockBehavior.Strict); GetAdParameterRequest request = new GetAdParameterRequest { ResourceName = new AdParameterName("[CUSTOMER]", "[AD_PARAMETER]").ToString(), }; AdParameter expectedResponse = new AdParameter { ResourceName = "resourceName2625949903", }; mockGrpcClient.Setup(x => x.GetAdParameter(request, It.IsAny <CallOptions>())) .Returns(expectedResponse); AdParameterServiceClient client = new AdParameterServiceClientImpl(mockGrpcClient.Object, null); AdParameter response = client.GetAdParameter(request); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async Task GetAdParameterAsync2() { Mock <AdParameterService.AdParameterServiceClient> mockGrpcClient = new Mock <AdParameterService.AdParameterServiceClient>(MockBehavior.Strict); GetAdParameterRequest request = new GetAdParameterRequest { ResourceName = new AdParameterName("[CUSTOMER]", "[AD_PARAMETER]").ToString(), }; AdParameter expectedResponse = new AdParameter { ResourceName = "resourceName2625949903", }; mockGrpcClient.Setup(x => x.GetAdParameterAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <AdParameter>(Task.FromResult(expectedResponse), null, null, null, null)); AdParameterServiceClient client = new AdParameterServiceClientImpl(mockGrpcClient.Object, null); AdParameter response = await client.GetAdParameterAsync(request); 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> /// <param name="adGroupId">ID of the ad group that contains the keywrd. /// </param> /// <param name="criterionId">ID of the keyword to which ad parameters are attached.</param> public void Run(GoogleAdsClient client, long customerId, long adGroupId, long criterionId) { // Get the AdParameterServiceClient. AdParameterServiceClient adParameterService = client.GetService(Services.V10.AdParameterService); // Creates ad parameters. // There can be a maximum of two AdParameters per ad group criterion. // (One with parameter_index = 1 and one with parameter_index = 2.) AdParameter adParameter1 = new AdParameter() { AdGroupCriterion = ResourceNames.AdGroupCriterion( customerId, adGroupId, criterionId), // The unique index of this ad parameter. Must be either 1 or 2. ParameterIndex = 1, // String containing a numeric value to insert into the ad text. // The following restrictions apply: (a) can use comma or period as a separator, // with an optional period or comma (respectively) for fractional values, // (b) can be prepended or appended with a currency code, (c) can use plus or minus, // (d) can use '/' between two numbers. InsertionText = "100" }; AdParameter adParameter2 = new AdParameter() { AdGroupCriterion = ResourceNames.AdGroupCriterion( customerId, adGroupId, criterionId), ParameterIndex = 2, InsertionText = "$40" }; AdParameterOperation[] operations = new AdParameterOperation[] { new AdParameterOperation() { Create = adParameter1 }, new AdParameterOperation() { Create = adParameter2 }, }; try { MutateAdParametersResponse response = adParameterService.MutateAdParameters(customerId.ToString(), operations); Console.WriteLine($"Set {response.Results.Count} ad params:"); foreach (MutateAdParameterResult result in response.Results) { Console.WriteLine(result.ResourceName); } } catch (GoogleAdsException e) { Console.WriteLine("Failure:"); Console.WriteLine($"Message: {e.Message}"); Console.WriteLine($"Failure: {e.Failure}"); Console.WriteLine($"Request ID: {e.RequestId}"); throw; } }