/// <summary>Snippet for MutateAdParameters</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void MutateAdParameters()
 {
     // Create client
     AdParameterServiceClient adParameterServiceClient = AdParameterServiceClient.Create();
     // Initialize request argument(s)
     string customerId = "";
     IEnumerable <AdParameterOperation> operations = new AdParameterOperation[]
     {
         new AdParameterOperation(),
     };
     // Make the request
     MutateAdParametersResponse response = adParameterServiceClient.MutateAdParameters(customerId, operations);
 }
Exemplo n.º 2
0
        /// <summary>Snippet for MutateAdParametersAsync</summary>
        public async Task MutateAdParametersAsync()
        {
            // Snippet: MutateAdParametersAsync(string, IEnumerable<AdParameterOperation>, CallSettings)
            // Additional: MutateAdParametersAsync(string, IEnumerable<AdParameterOperation>, CancellationToken)
            // Create client
            AdParameterServiceClient adParameterServiceClient = await AdParameterServiceClient.CreateAsync();

            // Initialize request argument(s)
            string customerId = "";
            IEnumerable <AdParameterOperation> operations = new AdParameterOperation[]
            {
                new AdParameterOperation(),
            };
            // Make the request
            MutateAdParametersResponse response = await adParameterServiceClient.MutateAdParametersAsync(customerId, operations);

            // End snippet
        }
Exemplo n.º 3
0
        /// <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;
            }
        }