public async stt::Task GenerateReachForecastAsync() { moq::Mock <ReachPlanService.ReachPlanServiceClient> mockGrpcClient = new moq::Mock <ReachPlanService.ReachPlanServiceClient>(moq::MockBehavior.Strict); GenerateReachForecastRequest request = new GenerateReachForecastRequest { CustomerId = "customer_id3b3724cb", CampaignDuration = new CampaignDuration(), PlannedProducts = { new PlannedProduct(), }, }; GenerateReachForecastResponse expectedResponse = new GenerateReachForecastResponse { OnTargetAudienceMetrics = new OnTargetAudienceMetrics(), ReachCurve = new ReachCurve(), }; mockGrpcClient.Setup(x => x.GenerateReachForecastAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <GenerateReachForecastResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); ReachPlanServiceClient client = new ReachPlanServiceClientImpl(mockGrpcClient.Object, null); GenerateReachForecastResponse responseCallSettings = await client.GenerateReachForecastAsync(request.CustomerId, request.CampaignDuration, request.PlannedProducts, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); Assert.AreEqual(expectedResponse, responseCallSettings); GenerateReachForecastResponse responseCancellationToken = await client.GenerateReachForecastAsync(request.CustomerId, request.CampaignDuration, request.PlannedProducts, st::CancellationToken.None); Assert.AreEqual(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public async stt::Task GenerateReachForecastRequestObjectAsync() { moq::Mock <ReachPlanService.ReachPlanServiceClient> mockGrpcClient = new moq::Mock <ReachPlanService.ReachPlanServiceClient>(moq::MockBehavior.Strict); GenerateReachForecastRequest request = new GenerateReachForecastRequest { CustomerId = "customer_id3b3724cb", CampaignDuration = new CampaignDuration(), Targeting = new Targeting(), PlannedProducts = { new PlannedProduct(), }, CookieFrequencyCapSetting = new FrequencyCap(), CurrencyCode = "currency_code7f81e352", CookieFrequencyCap = 1624044206, MinEffectiveFrequency = -519821093, EffectiveFrequencyLimit = new EffectiveFrequencyLimit(), }; GenerateReachForecastResponse expectedResponse = new GenerateReachForecastResponse { OnTargetAudienceMetrics = new OnTargetAudienceMetrics(), ReachCurve = new ReachCurve(), }; mockGrpcClient.Setup(x => x.GenerateReachForecastAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <GenerateReachForecastResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); ReachPlanServiceClient client = new ReachPlanServiceClientImpl(mockGrpcClient.Object, null); GenerateReachForecastResponse responseCallSettings = await client.GenerateReachForecastAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); Assert.AreEqual(expectedResponse, responseCallSettings); GenerateReachForecastResponse responseCancellationToken = await client.GenerateReachForecastAsync(request, st::CancellationToken.None); Assert.AreEqual(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void GenerateReachForecast() { moq::Mock <ReachPlanService.ReachPlanServiceClient> mockGrpcClient = new moq::Mock <ReachPlanService.ReachPlanServiceClient>(moq::MockBehavior.Strict); GenerateReachForecastRequest request = new GenerateReachForecastRequest { CustomerId = "customer_id3b3724cb", CampaignDuration = new CampaignDuration(), PlannedProducts = { new PlannedProduct(), }, }; GenerateReachForecastResponse expectedResponse = new GenerateReachForecastResponse { OnTargetAudienceMetrics = new OnTargetAudienceMetrics(), ReachCurve = new ReachCurve(), }; mockGrpcClient.Setup(x => x.GenerateReachForecast(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); ReachPlanServiceClient client = new ReachPlanServiceClientImpl(mockGrpcClient.Object, null); GenerateReachForecastResponse response = client.GenerateReachForecast(request.CustomerId, request.CampaignDuration, request.PlannedProducts); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
/// <summary> /// Generates a reach forecast for a given targeting / product mix. /// </summary> /// <param name="request"> /// The request object containing all of the parameters for the API call. /// </param> /// <param name="callSettings"> /// If not null, applies overrides to this RPC call. /// </param> /// <returns> /// The RPC response. /// </returns> public override GenerateReachForecastResponse GenerateReachForecast( GenerateReachForecastRequest request, gaxgrpc::CallSettings callSettings = null) { Modify_GenerateReachForecastRequest(ref request, ref callSettings); return(_callGenerateReachForecast.Sync(request, callSettings)); }
public void GenerateReachForecastRequestObject() { moq::Mock <ReachPlanService.ReachPlanServiceClient> mockGrpcClient = new moq::Mock <ReachPlanService.ReachPlanServiceClient>(moq::MockBehavior.Strict); GenerateReachForecastRequest request = new GenerateReachForecastRequest { CustomerId = "customer_id3b3724cb", CampaignDuration = new CampaignDuration(), Targeting = new Targeting(), PlannedProducts = { new PlannedProduct(), }, CookieFrequencyCapSetting = new FrequencyCap(), CurrencyCode = "currency_code7f81e352", CookieFrequencyCap = 1624044206, MinEffectiveFrequency = -519821093, EffectiveFrequencyLimit = new EffectiveFrequencyLimit(), }; GenerateReachForecastResponse expectedResponse = new GenerateReachForecastResponse { OnTargetAudienceMetrics = new OnTargetAudienceMetrics(), ReachCurve = new ReachCurve(), }; mockGrpcClient.Setup(x => x.GenerateReachForecast(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); ReachPlanServiceClient client = new ReachPlanServiceClientImpl(mockGrpcClient.Object, null); GenerateReachForecastResponse response = client.GenerateReachForecast(request); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
/// <summary> /// Pulls a forecast for a budget split 15% and 85% between two products. /// </summary> /// <param name="reachPlanService">Instance of Reach Plan Service client.</param> /// <param name="customerId">The customer ID for the reach forecast.</param> /// <param name="locationId">Location ID to plan for. To find a valid locaction 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> /// <param name="budgetMicros">Budget in currency to plan for.</param> public void ForecastManualMix( ReachPlanServiceClient reachPlanService, string customerId, string locationId, string currencyCode, long budgetMicros) { List <PlannedProduct> productMix = new List <PlannedProduct>(); // Set up a ratio to split the budget between two products. double trueviewAllocation = 0.15; double bumperAllocation = 1 - trueviewAllocation; // See listPlannableProducts on ReachPlanService to retrieve a list // of valid PlannableProductCode's for a given location: // https://developers.google.com/google-ads/api/reference/rpc/Google.Ads.GoogleAds.V3.services#reachplanservice productMix.Add(new PlannedProduct() { PlannableProductCode = "TRUEVIEW_IN_STREAM", BudgetMicros = Convert.ToInt64((double)budgetMicros * trueviewAllocation) }); productMix.Add(new PlannedProduct() { PlannableProductCode = "BUMPER", BudgetMicros = Convert.ToInt64((double)budgetMicros * bumperAllocation) }); GenerateReachForecastRequest request = BuildReachRequest(customerId, productMix, locationId, currencyCode); PullReachCurve(reachPlanService, request); }
/// <summary>Snippet for GenerateReachForecastAsync</summary> public async Task GenerateReachForecastRequestObjectAsync() { // Snippet: GenerateReachForecastAsync(GenerateReachForecastRequest, CallSettings) // Additional: GenerateReachForecastAsync(GenerateReachForecastRequest, CancellationToken) // Create client ReachPlanServiceClient reachPlanServiceClient = await ReachPlanServiceClient.CreateAsync(); // Initialize request argument(s) GenerateReachForecastRequest request = new GenerateReachForecastRequest { CustomerId = "", CampaignDuration = new CampaignDuration(), Targeting = new Targeting(), PlannedProducts = { new PlannedProduct(), }, CookieFrequencyCapSetting = new FrequencyCap(), CurrencyCode = "", CookieFrequencyCap = 0, MinEffectiveFrequency = 0, }; // Make the request GenerateReachForecastResponse response = await reachPlanServiceClient.GenerateReachForecastAsync(request); // End snippet }
/// <summary> /// Pulls and prints the reach curve for the given request. /// </summary> /// <param name="reachPlanService">Instance of Reach Plan Service client.</param> /// <param name="request">An already-populated reach curve request.</param> public void PullReachCurve( ReachPlanServiceClient reachPlanService, GenerateReachForecastRequest request) { GenerateReachForecastResponse response = reachPlanService.GenerateReachForecast( request); Console.WriteLine("Reach curve output:"); Console.WriteLine( "Currency,\tCost Micros,\tOn-Target Reach,\tOn-Target Imprs,\tTotal Reach," + "\tTotal Imprs,\tProducts"); foreach (ReachForecast point in response.ReachCurve.ReachForecasts) { Console.Write($"{request.CurrencyCode},\t"); Console.Write($"{point.CostMicros},\t"); Console.Write($"{point.Forecast.OnTargetReach},\t"); Console.Write($"{point.Forecast.OnTargetImpressions},\t"); Console.Write($"{point.Forecast.TotalReach},\t"); Console.Write($"{point.Forecast.TotalImpressions},\t"); Console.Write($"\"["); foreach (ProductAllocation product in point.ForecastedProductAllocations) { Console.Write($"(Product: {product.PlannableProductCode}, "); Console.Write($"Budget Micros: {product.BudgetMicros}), "); } Console.WriteLine($"]\""); } }
// [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> /// Pulls a forecast for a product mix suggested based on preferences for whether the ad /// would have a guaranteed price, play with sound, would be skippable, would include top /// content, and a desired ad length. /// </summary> /// <param name="reachPlanService">Instance of Reach Plan Service client.</param> /// <param name="customerId">The customer ID for the reach forecast.</param> /// <param name="locationId">Location ID to plan for. To find a valid locaction 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> /// <param name="budgetMicros">Budget in currency micro-units to plan for.</param> public void ForecastSuggestedMix( ReachPlanServiceClient reachPlanService, string customerId, string locationId, string currencyCode, long budgetMicros) { // Note: If preferences are too restrictive, then the response will be empty. Preferences preferences = new Preferences() { HasGuaranteedPrice = true, StartsWithSound = true, IsSkippable = false, TopContentOnly = true, AdLength = ReachPlanAdLength.FifteenOrTwentySeconds }; GenerateProductMixIdeasRequest mixRequest = new GenerateProductMixIdeasRequest() { BudgetMicros = Convert.ToInt64((double)budgetMicros), CurrencyCode = currencyCode, CustomerId = customerId, PlannableLocationId = locationId, Preferences = preferences }; GenerateProductMixIdeasResponse mixResponse = reachPlanService.GenerateProductMixIdeas(mixRequest); List <PlannedProduct> productMix = new List <PlannedProduct>(); foreach (ProductAllocation product in mixResponse.ProductAllocation) { productMix.Add( new PlannedProduct() { PlannableProductCode = product.PlannableProductCode, BudgetMicros = product.BudgetMicros }); } GenerateReachForecastRequest curveRequest = BuildReachRequest(customerId, productMix, locationId, currencyCode); PullReachCurve(reachPlanService, curveRequest); }
/// <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 GenerateReachForecastRequestObject() { // Create client ReachPlanServiceClient reachPlanServiceClient = ReachPlanServiceClient.Create(); // Initialize request argument(s) GenerateReachForecastRequest request = new GenerateReachForecastRequest { CustomerId = "", CampaignDuration = new CampaignDuration(), Targeting = new Targeting(), PlannedProducts = { new PlannedProduct(), }, CookieFrequencyCapSetting = new FrequencyCap(), CurrencyCode = "", CookieFrequencyCap = 0, MinEffectiveFrequency = 0, }; // Make the request GenerateReachForecastResponse response = reachPlanServiceClient.GenerateReachForecast(request); }
public async Task GenerateReachForecastAsync() { Mock <ReachPlanService.ReachPlanServiceClient> mockGrpcClient = new Mock <ReachPlanService.ReachPlanServiceClient>(MockBehavior.Strict); GenerateReachForecastRequest request = new GenerateReachForecastRequest { CustomerId = "customerId-1772061412", CurrencyCode = null, CampaignDuration = new CampaignDuration(), CookieFrequencyCap = null, MinEffectiveFrequency = null, Targeting = new Targeting(), PlannedProducts = { }, }; GenerateReachForecastResponse expectedResponse = new GenerateReachForecastResponse(); mockGrpcClient.Setup(x => x.GenerateReachForecastAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <GenerateReachForecastResponse>(Task.FromResult(expectedResponse), null, null, null, null)); ReachPlanServiceClient client = new ReachPlanServiceClientImpl(mockGrpcClient.Object, null); GenerateReachForecastResponse response = await client.GenerateReachForecastAsync(request); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
partial void Modify_GenerateReachForecastRequest(ref GenerateReachForecastRequest request, ref gaxgrpc::CallSettings settings);
/// <summary> /// Generates a reach forecast for a given targeting / product mix. /// </summary> /// <param name="request"> /// The request object containing all of the parameters for the API call. /// </param> /// <param name="callSettings"> /// If not null, applies overrides to this RPC call. /// </param> /// <returns> /// The RPC response. /// </returns> public virtual GenerateReachForecastResponse GenerateReachForecast( GenerateReachForecastRequest request, gaxgrpc::CallSettings callSettings = null) { throw new sys::NotImplementedException(); }
/// <summary> /// Generates a reach forecast for a given targeting / product mix. /// </summary> /// <param name="request"> /// The request object containing all of the parameters for the API call. /// </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( GenerateReachForecastRequest request, st::CancellationToken cancellationToken) => GenerateReachForecastAsync( request, gaxgrpc::CallSettings.FromCancellationToken(cancellationToken));
/// <summary> /// Generates a reach forecast for a given targeting / product mix. /// </summary> /// <param name="request">The request object containing all of the parameters for the API call.</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(GenerateReachForecastRequest request, gaxgrpc::CallSettings callSettings = null) => throw new sys::NotImplementedException();