Exemple #1
0
        // [END ForecastReach_2]

        /// <summary>
        /// Create a base request to generate a reach forecast.
        /// </summary>
        /// <param name="customerId">The customer ID for the reach forecast.</param>
        /// <param name="productMix">The product mix for the reach forecast.</param>
        /// <param name="locationId">Location ID to plan for. To find a valid location ID, either
        /// see https://developers.google.com/adwords/api/docs/appendix/geotargeting or call
        /// <see cref="ReachPlanServiceClient.ListPlannableLocations"/>.</param>
        /// <param name="currencyCode">Three-character ISO 4217 currency code.</param>
        public GenerateReachForecastRequest BuildReachRequest(
            string customerId, List <PlannedProduct> productMix, string locationId,
            string currencyCode)
        {
            // Valid durations are between 1 and 90 days.
            CampaignDuration duration = new CampaignDuration
            {
                DurationInDays = 28
            };

            GenderInfo[] genders =
            {
                new GenderInfo {
                    Type = GenderType.Female
                },
                new GenderInfo {
                    Type = GenderType.Male
                }
            };

            DeviceInfo[] devices =
            {
                new DeviceInfo {
                    Type = Device.Desktop
                },
                new DeviceInfo {
                    Type = Device.Mobile
                },
                new DeviceInfo {
                    Type = Device.Tablet
                }
            };

            Targeting targeting = new Targeting
            {
                PlannableLocationId = locationId,
                AgeRange            = ReachPlanAgeRange.AgeRange1865Up,
            };

            targeting.Genders.AddRange(genders);
            targeting.Devices.AddRange(devices);

            // See the docs for defaults and valid ranges:
            // https://developers.google.com/google-ads/api/reference/rpc/latest/GenerateReachForecastRequest
            GenerateReachForecastRequest request = new GenerateReachForecastRequest
            {
                CustomerId            = customerId,
                CurrencyCode          = currencyCode,
                CampaignDuration      = duration,
                Targeting             = targeting,
                MinEffectiveFrequency = 1
            };

            request.PlannedProducts.AddRange(productMix);

            return(request);
        }
 /// <summary>Snippet for GenerateReachForecast</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void GenerateReachForecast()
 {
     // Create client
     ReachPlanServiceClient reachPlanServiceClient = ReachPlanServiceClient.Create();
     // Initialize request argument(s)
     string                       customerId       = "";
     CampaignDuration             campaignDuration = new CampaignDuration();
     IEnumerable <PlannedProduct> plannedProducts  = new PlannedProduct[]
     {
         new PlannedProduct(),
     };
     // Make the request
     GenerateReachForecastResponse response = reachPlanServiceClient.GenerateReachForecast(customerId, campaignDuration, plannedProducts);
 }
        /// <summary>Snippet for GenerateReachForecastAsync</summary>
        public async Task GenerateReachForecastAsync()
        {
            // Snippet: GenerateReachForecastAsync(string, CampaignDuration, IEnumerable<PlannedProduct>, CallSettings)
            // Additional: GenerateReachForecastAsync(string, CampaignDuration, IEnumerable<PlannedProduct>, CancellationToken)
            // Create client
            ReachPlanServiceClient reachPlanServiceClient = await ReachPlanServiceClient.CreateAsync();

            // Initialize request argument(s)
            string                       customerId       = "";
            CampaignDuration             campaignDuration = new CampaignDuration();
            IEnumerable <PlannedProduct> plannedProducts  = new PlannedProduct[]
            {
                new PlannedProduct(),
            };
            // Make the request
            GenerateReachForecastResponse response = await reachPlanServiceClient.GenerateReachForecastAsync(customerId, campaignDuration, plannedProducts);

            // End snippet
        }
Exemple #4
0
 /// <summary>
 /// Generates a reach forecast for a given targeting / product mix.
 /// </summary>
 /// <param name="customerId">
 /// Required. The ID of the customer.
 /// </param>
 /// <param name="campaignDuration">
 /// Required. Campaign duration.
 /// </param>
 /// <param name="plannedProducts">
 /// Required. The products to be forecast.
 /// The max number of allowed planned products is 15.
 /// </param>
 /// <param name="cancellationToken">A <see cref="st::CancellationToken"/> to use for this RPC.</param>
 /// <returns>A Task containing the RPC response.</returns>
 public virtual stt::Task <GenerateReachForecastResponse> GenerateReachForecastAsync(string customerId, CampaignDuration campaignDuration, scg::IEnumerable <PlannedProduct> plannedProducts, st::CancellationToken cancellationToken) =>
 GenerateReachForecastAsync(customerId, campaignDuration, plannedProducts, gaxgrpc::CallSettings.FromCancellationToken(cancellationToken));
Exemple #5
0
 /// <summary>
 /// Generates a reach forecast for a given targeting / product mix.
 /// </summary>
 /// <param name="customerId">
 /// Required. The ID of the customer.
 /// </param>
 /// <param name="campaignDuration">
 /// Required. Campaign duration.
 /// </param>
 /// <param name="plannedProducts">
 /// Required. The products to be forecast.
 /// The max number of allowed planned products is 15.
 /// </param>
 /// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
 /// <returns>A Task containing the RPC response.</returns>
 public virtual stt::Task <GenerateReachForecastResponse> GenerateReachForecastAsync(string customerId, CampaignDuration campaignDuration, scg::IEnumerable <PlannedProduct> plannedProducts, gaxgrpc::CallSettings callSettings = null) =>
 GenerateReachForecastAsync(new GenerateReachForecastRequest
 {
     CustomerId       = gax::GaxPreconditions.CheckNotNullOrEmpty(customerId, nameof(customerId)),
     CampaignDuration = gax::GaxPreconditions.CheckNotNull(campaignDuration, nameof(campaignDuration)),
     PlannedProducts  =
     {
         gax::GaxPreconditions.CheckNotNull(plannedProducts, nameof(plannedProducts)),
     },
 }, callSettings);