Пример #1
0
        /// <summary>
        /// Adds the price asset to the customer account, allowing it to serve all campaigns under
        /// the account.
        /// </summary>
        /// <param name="client">The Google Ads client.</param>
        /// <param name="customerId">The customer ID for which the call is made.</param>
        /// <param name="priceAssetResourceName">The price asset resource name for which the call is
        /// made.</param>
        private void AddExtensionToAccount(GoogleAdsClient client, long customerId,
                                           string priceAssetResourceName)
        {
            CustomerAsset customerAsset = new CustomerAsset
            {
                Asset     = priceAssetResourceName,
                FieldType = AssetFieldTypeEnum.Types.AssetFieldType.Price,
            };

            // Issues the create request to add the callout.
            CustomerAssetServiceClient customerAssetServiceClient =
                client.GetService(Services.V10.CustomerAssetService);
            CustomerAssetOperation operation = new CustomerAssetOperation
            {
                Create = customerAsset,
            };

            CustomerAssetServiceClient assetClient =
                client.GetService(Services.V10.CustomerAssetService);
            MutateCustomerAssetsResponse response =
                assetClient.MutateCustomerAssets(customerId.ToString(), new[] { operation });

            string resourceName = response.Results[0].ResourceName;

            Console.WriteLine($"Created customer asset with resource name '{resourceName}'.");
        }
Пример #2
0
        /// <summary>
        /// Links the call asset at the account level to serve in all eligible campaigns.
        /// </summary>
        /// <param name="client">The Google Ads client.</param>
        /// <param name="customerId">The Google Ads customer ID.</param>
        /// <param name="assetResourceName">The resource name of the call asset.</param>
        private void LinkAssetToAccount(
            GoogleAdsClient client,
            long customerId,
            string assetResourceName)
        {
            // Creates a customer asset operation wrapping the call asset in a customer asset.
            CustomerAssetOperation customerAssetOperation = new CustomerAssetOperation()
            {
                Create = new CustomerAsset()
                {
                    Asset     = assetResourceName,
                    FieldType = AssetFieldType.Call
                }
            };

            CustomerAssetServiceClient customerAssetServiceClient =
                client.GetService(Services.V10.CustomerAssetService);

            // Issues a mutate request to add the customer asset and prints its information.
            MutateCustomerAssetsResponse response = customerAssetServiceClient.MutateCustomerAssets(
                customerId.ToString(),
                new[] { customerAssetOperation }
                );

            string resourceName = response.Results.First().ResourceName;

            Console.WriteLine(
                $"Created a customer asset with resource name: '{resourceName}'."
                );
        }
Пример #3
0
 /// <summary>Snippet for MutateCustomerAssets</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void MutateCustomerAssets()
 {
     // Create client
     CustomerAssetServiceClient customerAssetServiceClient = CustomerAssetServiceClient.Create();
     // Initialize request argument(s)
     string customerId = "";
     IEnumerable <CustomerAssetOperation> operations = new CustomerAssetOperation[]
     {
         new CustomerAssetOperation(),
     };
     // Make the request
     MutateCustomerAssetsResponse response = customerAssetServiceClient.MutateCustomerAssets(customerId, operations);
 }
Пример #4
0
        /// <summary>Snippet for MutateCustomerAssetsAsync</summary>
        public async Task MutateCustomerAssetsAsync()
        {
            // Snippet: MutateCustomerAssetsAsync(string, IEnumerable<CustomerAssetOperation>, CallSettings)
            // Additional: MutateCustomerAssetsAsync(string, IEnumerable<CustomerAssetOperation>, CancellationToken)
            // Create client
            CustomerAssetServiceClient customerAssetServiceClient = await CustomerAssetServiceClient.CreateAsync();

            // Initialize request argument(s)
            string customerId = "";
            IEnumerable <CustomerAssetOperation> operations = new CustomerAssetOperation[]
            {
                new CustomerAssetOperation(),
            };
            // Make the request
            MutateCustomerAssetsResponse response = await customerAssetServiceClient.MutateCustomerAssetsAsync(customerId, operations);

            // End snippet
        }