Ejemplo n.º 1
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}'."
                );
        }
Ejemplo n.º 2
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}'.");
        }
Ejemplo n.º 3
0
 /// <summary>Snippet for GetCustomerAsset</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void GetCustomerAsset()
 {
     // Create client
     CustomerAssetServiceClient customerAssetServiceClient = CustomerAssetServiceClient.Create();
     // Initialize request argument(s)
     string resourceName = "customers/[CUSTOMER_ID]/customerAssets/[ASSET_ID]~[FIELD_TYPE]";
     // Make the request
     CustomerAsset response = customerAssetServiceClient.GetCustomerAsset(resourceName);
 }
 /// <summary>Snippet for GetCustomerAsset</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void GetCustomerAssetResourceNames()
 {
     // Create client
     CustomerAssetServiceClient customerAssetServiceClient = CustomerAssetServiceClient.Create();
     // Initialize request argument(s)
     CustomerAssetName resourceName = CustomerAssetName.FromCustomerAssetFieldType("[CUSTOMER_ID]", "[ASSET_ID]", "[FIELD_TYPE]");
     // Make the request
     CustomerAsset response = customerAssetServiceClient.GetCustomerAsset(resourceName);
 }
Ejemplo n.º 5
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);
 }
Ejemplo n.º 6
0
        /// <summary>Snippet for GetCustomerAssetAsync</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 GetCustomerAssetRequestObjectAsync()
        {
            // Create client
            CustomerAssetServiceClient customerAssetServiceClient = await CustomerAssetServiceClient.CreateAsync();

            // Initialize request argument(s)
            GetCustomerAssetRequest request = new GetCustomerAssetRequest
            {
                ResourceNameAsCustomerAssetName = CustomerAssetName.FromCustomerAssetFieldType("[CUSTOMER_ID]", "[ASSET_ID]", "[FIELD_TYPE]"),
            };
            // Make the request
            CustomerAsset response = await customerAssetServiceClient.GetCustomerAssetAsync(request);
        }
Ejemplo n.º 7
0
        /// <summary>Snippet for GetCustomerAssetAsync</summary>
        public async Task GetCustomerAssetAsync()
        {
            // Snippet: GetCustomerAssetAsync(string, CallSettings)
            // Additional: GetCustomerAssetAsync(string, CancellationToken)
            // Create client
            CustomerAssetServiceClient customerAssetServiceClient = await CustomerAssetServiceClient.CreateAsync();

            // Initialize request argument(s)
            string resourceName = "customers/[CUSTOMER_ID]/customerAssets/[ASSET_ID]~[FIELD_TYPE]";
            // Make the request
            CustomerAsset response = await customerAssetServiceClient.GetCustomerAssetAsync(resourceName);

            // End snippet
        }
Ejemplo n.º 8
0
 /// <summary>Snippet for GetCustomerAsset</summary>
 public void GetCustomerAssetRequestObject()
 {
     // Snippet: GetCustomerAsset(GetCustomerAssetRequest, CallSettings)
     // Create client
     CustomerAssetServiceClient customerAssetServiceClient = CustomerAssetServiceClient.Create();
     // Initialize request argument(s)
     GetCustomerAssetRequest request = new GetCustomerAssetRequest
     {
         ResourceNameAsCustomerAssetName = CustomerAssetName.FromCustomerAssetFieldType("[CUSTOMER_ID]", "[ASSET_ID]", "[FIELD_TYPE]"),
     };
     // Make the request
     CustomerAsset response = customerAssetServiceClient.GetCustomerAsset(request);
     // End snippet
 }
Ejemplo n.º 9
0
        /// <summary>Snippet for GetCustomerAssetAsync</summary>
        public async Task GetCustomerAssetResourceNamesAsync()
        {
            // Snippet: GetCustomerAssetAsync(CustomerAssetName, CallSettings)
            // Additional: GetCustomerAssetAsync(CustomerAssetName, CancellationToken)
            // Create client
            CustomerAssetServiceClient customerAssetServiceClient = await CustomerAssetServiceClient.CreateAsync();

            // Initialize request argument(s)
            CustomerAssetName resourceName = CustomerAssetName.FromCustomerAssetFieldType("[CUSTOMER_ID]", "[ASSET_ID]", "[FIELD_TYPE]");
            // Make the request
            CustomerAsset response = await customerAssetServiceClient.GetCustomerAssetAsync(resourceName);

            // End snippet
        }
Ejemplo n.º 10
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
        }
Ejemplo n.º 11
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 MutateCustomerAssetsRequestObject()
 {
     // Create client
     CustomerAssetServiceClient customerAssetServiceClient = CustomerAssetServiceClient.Create();
     // Initialize request argument(s)
     MutateCustomerAssetsRequest request = new MutateCustomerAssetsRequest
     {
         CustomerId = "",
         Operations =
         {
             new CustomerAssetOperation(),
         },
         PartialFailure = false,
         ValidateOnly   = false,
     };
     // Make the request
     MutateCustomerAssetsResponse response = customerAssetServiceClient.MutateCustomerAssets(request);
 }
        /// <summary>Snippet for MutateCustomerAssetsAsync</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 MutateCustomerAssetsRequestObjectAsync()
        {
            // Create client
            CustomerAssetServiceClient customerAssetServiceClient = await CustomerAssetServiceClient.CreateAsync();

            // Initialize request argument(s)
            MutateCustomerAssetsRequest request = new MutateCustomerAssetsRequest
            {
                CustomerId = "",
                Operations =
                {
                    new CustomerAssetOperation(),
                },
                PartialFailure      = false,
                ValidateOnly        = false,
                ResponseContentType = ResponseContentTypeEnum.Types.ResponseContentType.Unspecified,
            };
            // Make the request
            MutateCustomerAssetsResponse response = await customerAssetServiceClient.MutateCustomerAssetsAsync(request);
        }
Ejemplo n.º 13
0
 /// <summary>Snippet for MutateCustomerAssets</summary>
 public void MutateCustomerAssetsRequestObject()
 {
     // Snippet: MutateCustomerAssets(MutateCustomerAssetsRequest, CallSettings)
     // Create client
     CustomerAssetServiceClient customerAssetServiceClient = CustomerAssetServiceClient.Create();
     // Initialize request argument(s)
     MutateCustomerAssetsRequest request = new MutateCustomerAssetsRequest
     {
         CustomerId = "",
         Operations =
         {
             new CustomerAssetOperation(),
         },
         PartialFailure      = false,
         ValidateOnly        = false,
         ResponseContentType = ResponseContentTypeEnum.Types.ResponseContentType.Unspecified,
     };
     // Make the request
     MutateCustomerAssetsResponse response = customerAssetServiceClient.MutateCustomerAssets(request);
     // End snippet
 }
        /// <summary>Snippet for MutateCustomerAssetsAsync</summary>
        public async Task MutateCustomerAssetsRequestObjectAsync()
        {
            // Snippet: MutateCustomerAssetsAsync(MutateCustomerAssetsRequest, CallSettings)
            // Additional: MutateCustomerAssetsAsync(MutateCustomerAssetsRequest, CancellationToken)
            // Create client
            CustomerAssetServiceClient customerAssetServiceClient = await CustomerAssetServiceClient.CreateAsync();

            // Initialize request argument(s)
            MutateCustomerAssetsRequest request = new MutateCustomerAssetsRequest
            {
                CustomerId = "",
                Operations =
                {
                    new CustomerAssetOperation(),
                },
                PartialFailure = false,
                ValidateOnly   = false,
            };
            // Make the request
            MutateCustomerAssetsResponse response = await customerAssetServiceClient.MutateCustomerAssetsAsync(request);

            // End snippet
        }