Example #1
0
 /// <summary>Snippet for GetSmartCampaignSetting</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void GetSmartCampaignSetting()
 {
     // Create client
     SmartCampaignSettingServiceClient smartCampaignSettingServiceClient = SmartCampaignSettingServiceClient.Create();
     // Initialize request argument(s)
     string resourceName = "customers/[CUSTOMER_ID]/smartCampaignSettings/[CAMPAIGN_ID]";
     // Make the request
     SmartCampaignSetting response = smartCampaignSettingServiceClient.GetSmartCampaignSetting(resourceName);
 }
 /// <summary>Snippet for GetSmartCampaignSetting</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void GetSmartCampaignSettingResourceNames()
 {
     // Create client
     SmartCampaignSettingServiceClient smartCampaignSettingServiceClient = SmartCampaignSettingServiceClient.Create();
     // Initialize request argument(s)
     SmartCampaignSettingName resourceName = SmartCampaignSettingName.FromCustomerCampaign("[CUSTOMER_ID]", "[CAMPAIGN_ID]");
     // Make the request
     SmartCampaignSetting response = smartCampaignSettingServiceClient.GetSmartCampaignSetting(resourceName);
 }
        /// <summary>Snippet for GetSmartCampaignSettingAsync</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 GetSmartCampaignSettingRequestObjectAsync()
        {
            // Create client
            SmartCampaignSettingServiceClient smartCampaignSettingServiceClient = await SmartCampaignSettingServiceClient.CreateAsync();

            // Initialize request argument(s)
            GetSmartCampaignSettingRequest request = new GetSmartCampaignSettingRequest
            {
                ResourceNameAsSmartCampaignSettingName = SmartCampaignSettingName.FromCustomerCampaign("[CUSTOMER_ID]", "[CAMPAIGN_ID]"),
            };
            // Make the request
            SmartCampaignSetting response = await smartCampaignSettingServiceClient.GetSmartCampaignSettingAsync(request);
        }
Example #4
0
        /// <summary>Snippet for GetSmartCampaignSettingAsync</summary>
        public async Task GetSmartCampaignSettingAsync()
        {
            // Snippet: GetSmartCampaignSettingAsync(string, CallSettings)
            // Additional: GetSmartCampaignSettingAsync(string, CancellationToken)
            // Create client
            SmartCampaignSettingServiceClient smartCampaignSettingServiceClient = await SmartCampaignSettingServiceClient.CreateAsync();

            // Initialize request argument(s)
            string resourceName = "customers/[CUSTOMER_ID]/smartCampaignSettings/[CAMPAIGN_ID]";
            // Make the request
            SmartCampaignSetting response = await smartCampaignSettingServiceClient.GetSmartCampaignSettingAsync(resourceName);

            // End snippet
        }
Example #5
0
 /// <summary>Snippet for GetSmartCampaignSetting</summary>
 public void GetSmartCampaignSettingRequestObject()
 {
     // Snippet: GetSmartCampaignSetting(GetSmartCampaignSettingRequest, CallSettings)
     // Create client
     SmartCampaignSettingServiceClient smartCampaignSettingServiceClient = SmartCampaignSettingServiceClient.Create();
     // Initialize request argument(s)
     GetSmartCampaignSettingRequest request = new GetSmartCampaignSettingRequest
     {
         ResourceNameAsSmartCampaignSettingName = SmartCampaignSettingName.FromCustomerCampaign("[CUSTOMER_ID]", "[CAMPAIGN_ID]"),
     };
     // Make the request
     SmartCampaignSetting response = smartCampaignSettingServiceClient.GetSmartCampaignSetting(request);
     // End snippet
 }
Example #6
0
        /// <summary>Snippet for GetSmartCampaignSettingAsync</summary>
        public async Task GetSmartCampaignSettingResourceNamesAsync()
        {
            // Snippet: GetSmartCampaignSettingAsync(SmartCampaignSettingName, CallSettings)
            // Additional: GetSmartCampaignSettingAsync(SmartCampaignSettingName, CancellationToken)
            // Create client
            SmartCampaignSettingServiceClient smartCampaignSettingServiceClient = await SmartCampaignSettingServiceClient.CreateAsync();

            // Initialize request argument(s)
            SmartCampaignSettingName resourceName = SmartCampaignSettingName.FromCustomerCampaign("[CUSTOMER_ID]", "[CAMPAIGN_ID]");
            // Make the request
            SmartCampaignSetting response = await smartCampaignSettingServiceClient.GetSmartCampaignSettingAsync(resourceName);

            // End snippet
        }
Example #7
0
        // [END add_smart_campaign_3]

        // [START add_smart_campaign_4]
        /// <summary>
        /// Creates a MutateOperation to create a new SmartCampaignSetting. SmartCampaignSettings
        /// are unique in that they only support UPDATE operations, which are used to update and
        /// create them. Below we will use a temporary ID in the resource name to associate it with
        /// the campaign created in the previous step.
        /// </summary>
        /// <param name="customerId">The Google Ads customer ID.</param>
        /// <param name="businessLocationId">The ID of a Business Profile location.</param>
        /// <param name="businessName">The name of a Business Profile business.</param>
        /// <returns>A MutateOperation that creates a SmartCampaignSetting.</returns>
        private MutateOperation CreateSmartCampaignSettingOperation(long customerId,
                                                                    ulong?businessLocationId, string businessName)
        {
            SmartCampaignSetting smartCampaignSetting = new SmartCampaignSetting
            {
                // Set a temporary ID in the campaign setting's resource name to associate it with
                // the campaign created in the previous step.
                ResourceName =
                    ResourceNames.SmartCampaignSetting(customerId, SMART_CAMPAIGN_TEMPORARY_ID),
                // Below we configure the SmartCampaignSetting using many of the same details used
                // to generate a budget suggestion.
                PhoneNumber = new SmartCampaignSetting.Types.PhoneNumber
                {
                    CountryCode  = COUNTRY_CODE,
                    PhoneNumber_ = PHONE_NUMBER
                },
                FinalUrl = LANDING_PAGE_URL,
                AdvertisingLanguageCode = LANGUAGE_CODE
            };

            // Either a business location ID or a business name must be added to the
            // SmartCampaignSetting.
            if (businessLocationId.HasValue)
            {
                // Transform Google Business Location ID to a compatible format before
                // passing it onto the API.
                smartCampaignSetting.BusinessLocationId =
                    ConvertBusinessLocationId(businessLocationId.Value);
            }
            else
            {
                smartCampaignSetting.BusinessName = businessName;
            }

            return(new MutateOperation
            {
                SmartCampaignSettingOperation = new SmartCampaignSettingOperation
                {
                    Update = smartCampaignSetting,
                    // Set the update mask on the operation. This is required since the smart
                    // campaign setting is created in an UPDATE operation. Here the update mask
                    // will be a list of all the fields that were set on the SmartCampaignSetting.
                    UpdateMask = FieldMasks.AllSetFieldsOf(smartCampaignSetting)
                }
            });
        }