コード例 #1
0
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="client">The Google Ads client.</param>
        /// <param name="customerId">The Google Ads customer ID for which the call is made.</param>
        /// <param name="billingSetupId">ID of the billing setup to remove.</param>
        public void Run(GoogleAdsClient client, long customerId, long billingSetupId)
        {
            // Get the BillingSetupServiceClient.
            BillingSetupServiceClient billingSetupService = client.GetService(
                Services.V1.BillingSetupService);

            // Create the billing setup resource.
            String billingSetupResource = ResourceNames.BillingSetup(customerId, billingSetupId);

            // Construct an operation that will remove the billing setup.
            BillingSetupOperation operation = new BillingSetupOperation()
            {
                Remove = billingSetupResource
            };

            try
            {
                // Send the operation in a mutate request.
                MutateBillingSetupResponse response =
                    billingSetupService.MutateBillingSetup(customerId.ToString(), operation);

                Console.WriteLine("Removed billing setup with resource name '{0}'.",
                                  response.Result.ResourceName);
            }
            catch (GoogleAdsException e)
            {
                Console.WriteLine("Failure:");
                Console.WriteLine($"Message: {e.Message}");
                Console.WriteLine($"Failure: {e.Failure}");
                Console.WriteLine($"Request ID: {e.RequestId}");
            }
        }
コード例 #2
0
 /// <summary>Snippet for MutateBillingSetup</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void MutateBillingSetup()
 {
     // Create client
     BillingSetupServiceClient billingSetupServiceClient = BillingSetupServiceClient.Create();
     // Initialize request argument(s)
     string customerId = "";
     BillingSetupOperation operation = new BillingSetupOperation();
     // Make the request
     MutateBillingSetupResponse response = billingSetupServiceClient.MutateBillingSetup(customerId, operation);
 }
コード例 #3
0
 /// <summary>Snippet for MutateBillingSetup</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void MutateBillingSetupRequestObject()
 {
     // Create client
     BillingSetupServiceClient billingSetupServiceClient = BillingSetupServiceClient.Create();
     // Initialize request argument(s)
     MutateBillingSetupRequest request = new MutateBillingSetupRequest
     {
         CustomerId = "",
         Operation  = new BillingSetupOperation(),
     };
     // Make the request
     MutateBillingSetupResponse response = billingSetupServiceClient.MutateBillingSetup(request);
 }
コード例 #4
0
        /// <summary>
        /// Runs the code example. Either a payments account ID or a payments profile ID
        /// must be provided for the example to run successfully. If both are provided, only the
        /// payments account ID will be used.
        /// </summary>
        /// <param name="client">The Google Ads client.</param>
        /// <param name="customerId">The Google Ads customer ID for which the call is made.</param>
        /// <param name="paymentsAccountId">Optional payments account ID to attach to the new
        ///     billing setup. Must be formatted as "1234-5678-9012-3456".</param>
        /// <param name="paymentsProfileId">Optional payments profile ID to attach to a new payments
        ///     account and to the new billing setup. Must be formatted as "1234-5678-9012".</param>
        public void Run(GoogleAdsClient client, long customerId, string paymentsAccountId,
                        string paymentsProfileId)
        {
            // Gets the GoogleAdsServiceClient.
            GoogleAdsServiceClient googleAdsService = client.GetService(
                Services.V4.GoogleAdsService);

            // Gets the BillingSetupServiceClient.
            BillingSetupServiceClient billingSetupServiceClient =
                client.GetService(Services.V4.BillingSetupService);

            try
            {
                // Constructs a new billing setup.
                BillingSetup billingSetup =
                    CreateBillingSetup(customerId, paymentsAccountId, paymentsProfileId);

                SetBillingSetupStartDateTime(googleAdsService, customerId, billingSetup);

                // Creates the billing setup operation.
                BillingSetupOperation operation = new BillingSetupOperation()
                {
                    Create = billingSetup
                };

                // Issues a mutate request to add the billing setup.
                MutateBillingSetupResponse billingResponse =
                    billingSetupServiceClient.MutateBillingSetup(customerId.ToString(), operation);

                Console.WriteLine("Added new billing setup with resource name: " +
                                  $"{billingResponse.Result.ResourceName}");
            }
            catch (GoogleAdsException e)
            {
                Console.WriteLine("Failure:");
                Console.WriteLine($"Message: {e.Message}");
                Console.WriteLine($"Failure: {e.Failure}");
                Console.WriteLine($"Request ID: {e.RequestId}");
                throw;
            }
            catch (Exception e)
            {
                Console.WriteLine("Failure:");
                Console.WriteLine($"Message: {e.Message}");
                Console.WriteLine($"Trace: {e.StackTrace}");
            }
        }