Exemplo n.º 1
0
        public async stt::Task SuggestSmartCampaignBudgetOptionsRequestObjectAsync()
        {
            moq::Mock <SmartCampaignSuggestService.SmartCampaignSuggestServiceClient> mockGrpcClient = new moq::Mock <SmartCampaignSuggestService.SmartCampaignSuggestServiceClient>(moq::MockBehavior.Strict);
            SuggestSmartCampaignBudgetOptionsRequest request = new SuggestSmartCampaignBudgetOptionsRequest
            {
                CustomerId             = "customer_id3b3724cb",
                CampaignAsCampaignName = gagvr::CampaignName.FromCustomerCampaign("[CUSTOMER_ID]", "[CAMPAIGN_ID]"),
                SuggestionInfo         = new SmartCampaignSuggestionInfo(),
            };
            SuggestSmartCampaignBudgetOptionsResponse expectedResponse = new SuggestSmartCampaignBudgetOptionsResponse
            {
                Low         = new SuggestSmartCampaignBudgetOptionsResponse.Types.BudgetOption(),
                Recommended = new SuggestSmartCampaignBudgetOptionsResponse.Types.BudgetOption(),
                High        = new SuggestSmartCampaignBudgetOptionsResponse.Types.BudgetOption(),
            };

            mockGrpcClient.Setup(x => x.SuggestSmartCampaignBudgetOptionsAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <SuggestSmartCampaignBudgetOptionsResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            SmartCampaignSuggestServiceClient         client = new SmartCampaignSuggestServiceClientImpl(mockGrpcClient.Object, null);
            SuggestSmartCampaignBudgetOptionsResponse responseCallSettings = await client.SuggestSmartCampaignBudgetOptionsAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            SuggestSmartCampaignBudgetOptionsResponse responseCancellationToken = await client.SuggestSmartCampaignBudgetOptionsAsync(request, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
 /// <summary>Snippet for SuggestSmartCampaignBudgetOptions</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void SuggestSmartCampaignBudgetOptionsRequestObject()
 {
     // Create client
     SmartCampaignSuggestServiceClient smartCampaignSuggestServiceClient = SmartCampaignSuggestServiceClient.Create();
     // Initialize request argument(s)
     SuggestSmartCampaignBudgetOptionsRequest request = new SuggestSmartCampaignBudgetOptionsRequest
     {
         CustomerId             = "",
         CampaignAsCampaignName = CampaignName.FromCustomerCampaign("[CUSTOMER_ID]", "[CAMPAIGN_ID]"),
     };
     // Make the request
     SuggestSmartCampaignBudgetOptionsResponse response = smartCampaignSuggestServiceClient.SuggestSmartCampaignBudgetOptions(request);
 }
        /// <summary>Snippet for SuggestSmartCampaignBudgetOptionsAsync</summary>
        public async Task SuggestSmartCampaignBudgetOptionsRequestObjectAsync()
        {
            // Snippet: SuggestSmartCampaignBudgetOptionsAsync(SuggestSmartCampaignBudgetOptionsRequest, CallSettings)
            // Additional: SuggestSmartCampaignBudgetOptionsAsync(SuggestSmartCampaignBudgetOptionsRequest, CancellationToken)
            // Create client
            SmartCampaignSuggestServiceClient smartCampaignSuggestServiceClient = await SmartCampaignSuggestServiceClient.CreateAsync();

            // Initialize request argument(s)
            SuggestSmartCampaignBudgetOptionsRequest request = new SuggestSmartCampaignBudgetOptionsRequest
            {
                CustomerId             = "",
                CampaignAsCampaignName = CampaignName.FromCustomerCampaign("[CUSTOMER_ID]", "[CAMPAIGN_ID]"),
            };
            // Make the request
            SuggestSmartCampaignBudgetOptionsResponse response = await smartCampaignSuggestServiceClient.SuggestSmartCampaignBudgetOptionsAsync(request);

            // End snippet
        }
Exemplo n.º 4
0
        // [END add_smart_campaign_9]

        // [START add_smart_campaign_1]
        /// <summary>
        /// Retrieves a suggested budget amount for a new budget.
        /// Using the SmartCampaignSuggestService to determine a daily budget for new and existing
        /// Smart campaigns is highly recommended because it helps the campaigns achieve optimal
        /// performance.
        /// </summary>
        /// <param name="client">The Google Ads client.</param>
        /// <param name="customerId">The Google Ads customer ID.</param>
        /// <param name="suggestionInfo"></param>
        /// <returns>A daily budget amount in micros.</returns>
        private long GetBudgetSuggestion(GoogleAdsClient client, long customerId,
                                         SmartCampaignSuggestionInfo suggestionInfo)
        {
            SmartCampaignSuggestServiceClient smartCampaignSuggestServiceClient = client.GetService
                                                                                      (Services.V10.SmartCampaignSuggestService);

            SuggestSmartCampaignBudgetOptionsRequest request =
                new SuggestSmartCampaignBudgetOptionsRequest
            {
                CustomerId = customerId.ToString(),
                // You can retrieve suggestions for an existing campaign by setting the
                // "Campaign" field of the request to the resource name of a campaign and
                // leaving the rest of the request fields below unset:
                // Campaign = "INSERT_CAMPAIGN_RESOURCE_NAME_HERE",

                // Since these suggestions are for a new campaign, we're going to use the
                // SuggestionInfo field instead.
                SuggestionInfo = suggestionInfo,
            };

            LocationInfo locationInfo = new LocationInfo
            {
                // Set the location to the resource name of the given geo target constant.
                GeoTargetConstant = ResourceNames.GeoTargetConstant(GEO_TARGET_CONSTANT)
            };

            // Issue a request to retrieve a budget suggestion.
            SuggestSmartCampaignBudgetOptionsResponse response =
                smartCampaignSuggestServiceClient.SuggestSmartCampaignBudgetOptions(request);

            // Three tiers of options will be returned: "low", "high", and "recommended".
            // Here we will use the "recommended" option. The amount is specified in micros, where
            // one million is equivalent to one currency unit.
            Console.WriteLine($"A daily budget amount of " +
                              $"{response.Recommended.DailyAmountMicros}" +
                              $" was suggested, garnering an estimated minimum of " +
                              $"{response.Recommended.Metrics.MinDailyClicks} clicks and an estimated " +
                              $"maximum of {response.Recommended.Metrics.MaxDailyClicks} clicks per day.");

            return(response.Recommended.DailyAmountMicros);
        }
Exemplo n.º 5
0
        public void SuggestSmartCampaignBudgetOptionsRequestObject()
        {
            moq::Mock <SmartCampaignSuggestService.SmartCampaignSuggestServiceClient> mockGrpcClient = new moq::Mock <SmartCampaignSuggestService.SmartCampaignSuggestServiceClient>(moq::MockBehavior.Strict);
            SuggestSmartCampaignBudgetOptionsRequest request = new SuggestSmartCampaignBudgetOptionsRequest
            {
                CustomerId             = "customer_id3b3724cb",
                CampaignAsCampaignName = gagvr::CampaignName.FromCustomerCampaign("[CUSTOMER_ID]", "[CAMPAIGN_ID]"),
                SuggestionInfo         = new SmartCampaignSuggestionInfo(),
            };
            SuggestSmartCampaignBudgetOptionsResponse expectedResponse = new SuggestSmartCampaignBudgetOptionsResponse
            {
                Low         = new SuggestSmartCampaignBudgetOptionsResponse.Types.BudgetOption(),
                Recommended = new SuggestSmartCampaignBudgetOptionsResponse.Types.BudgetOption(),
                High        = new SuggestSmartCampaignBudgetOptionsResponse.Types.BudgetOption(),
            };

            mockGrpcClient.Setup(x => x.SuggestSmartCampaignBudgetOptions(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            SmartCampaignSuggestServiceClient         client   = new SmartCampaignSuggestServiceClientImpl(mockGrpcClient.Object, null);
            SuggestSmartCampaignBudgetOptionsResponse response = client.SuggestSmartCampaignBudgetOptions(request);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }