/// <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}");
            }
        }
Ejemplo n.º 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);
 }
Ejemplo n.º 3
0
        /// <summary>Snippet for MutateBillingSetupAsync</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 MutateBillingSetupAsync()
        {
            // Create client
            BillingSetupServiceClient billingSetupServiceClient = await BillingSetupServiceClient.CreateAsync();

            // Initialize request argument(s)
            string customerId = "";
            BillingSetupOperation operation = new BillingSetupOperation();
            // Make the request
            MutateBillingSetupResponse response = await billingSetupServiceClient.MutateBillingSetupAsync(customerId, operation);
        }
Ejemplo n.º 4
0
        /// <summary>Snippet for MutateBillingSetupAsync</summary>
        public async Task MutateBillingSetupAsync()
        {
            // Snippet: MutateBillingSetupAsync(string, BillingSetupOperation, CallSettings)
            // Additional: MutateBillingSetupAsync(string, BillingSetupOperation, CancellationToken)
            // Create client
            BillingSetupServiceClient billingSetupServiceClient = await BillingSetupServiceClient.CreateAsync();

            // Initialize request argument(s)
            string customerId = "";
            BillingSetupOperation operation = new BillingSetupOperation();
            // Make the request
            MutateBillingSetupResponse response = await billingSetupServiceClient.MutateBillingSetupAsync(customerId, operation);

            // End snippet
        }
Ejemplo n.º 5
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}");
            }
        }
Ejemplo n.º 6
0
        public async Task MutateBillingSetupAsync()
        {
            Mock <BillingSetupService.BillingSetupServiceClient> mockGrpcClient = new Mock <BillingSetupService.BillingSetupServiceClient>(MockBehavior.Strict);
            MutateBillingSetupRequest expectedRequest = new MutateBillingSetupRequest
            {
                CustomerId = "customerId-1772061412",
                Operation  = new BillingSetupOperation(),
            };
            MutateBillingSetupResponse expectedResponse = new MutateBillingSetupResponse();

            mockGrpcClient.Setup(x => x.MutateBillingSetupAsync(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <MutateBillingSetupResponse>(Task.FromResult(expectedResponse), null, null, null, null));
            BillingSetupServiceClient client = new BillingSetupServiceClientImpl(mockGrpcClient.Object, null);
            string customerId = "customerId-1772061412";
            BillingSetupOperation      operation = new BillingSetupOperation();
            MutateBillingSetupResponse response  = await client.MutateBillingSetupAsync(customerId, operation);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Ejemplo n.º 7
0
        public void MutateBillingSetup()
        {
            Mock <BillingSetupService.BillingSetupServiceClient> mockGrpcClient = new Mock <BillingSetupService.BillingSetupServiceClient>(MockBehavior.Strict);
            MutateBillingSetupRequest expectedRequest = new MutateBillingSetupRequest
            {
                CustomerId = "customerId-1772061412",
                Operation  = new BillingSetupOperation(),
            };
            MutateBillingSetupResponse expectedResponse = new MutateBillingSetupResponse();

            mockGrpcClient.Setup(x => x.MutateBillingSetup(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            BillingSetupServiceClient client = new BillingSetupServiceClientImpl(mockGrpcClient.Object, null);
            string customerId = "customerId-1772061412";
            BillingSetupOperation      operation = new BillingSetupOperation();
            MutateBillingSetupResponse response  = client.MutateBillingSetup(customerId, operation);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
 /// <summary>
 /// Creates a billing setup, or cancels an existing billing setup.
 ///
 /// List of thrown errors:
 /// [AuthenticationError]()
 /// [AuthorizationError]()
 /// [BillingSetupError]()
 /// [DateError]()
 /// [FieldError]()
 /// [HeaderError]()
 /// [InternalError]()
 /// [MutateError]()
 /// [QuotaError]()
 /// [RequestError]()
 /// </summary>
 /// <param name="customerId">
 /// Required. Id of the customer to apply the billing setup mutate operation to.
 /// </param>
 /// <param name="operation">
 /// Required. The operation to perform.
 /// </param>
 /// <param name="cancellationToken">A <see cref="st::CancellationToken"/> to use for this RPC.</param>
 /// <returns>A Task containing the RPC response.</returns>
 public virtual stt::Task <MutateBillingSetupResponse> MutateBillingSetupAsync(string customerId, BillingSetupOperation operation, st::CancellationToken cancellationToken) =>
 MutateBillingSetupAsync(customerId, operation, gaxgrpc::CallSettings.FromCancellationToken(cancellationToken));
 /// <summary>
 /// Creates a billing setup, or cancels an existing billing setup.
 ///
 /// List of thrown errors:
 /// [AuthenticationError]()
 /// [AuthorizationError]()
 /// [BillingSetupError]()
 /// [DateError]()
 /// [FieldError]()
 /// [HeaderError]()
 /// [InternalError]()
 /// [MutateError]()
 /// [QuotaError]()
 /// [RequestError]()
 /// </summary>
 /// <param name="customerId">
 /// Required. Id of the customer to apply the billing setup mutate operation to.
 /// </param>
 /// <param name="operation">
 /// Required. The operation to perform.
 /// </param>
 /// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
 /// <returns>A Task containing the RPC response.</returns>
 public virtual stt::Task <MutateBillingSetupResponse> MutateBillingSetupAsync(string customerId, BillingSetupOperation operation, gaxgrpc::CallSettings callSettings = null) =>
 MutateBillingSetupAsync(new MutateBillingSetupRequest
 {
     CustomerId = gax::GaxPreconditions.CheckNotNullOrEmpty(customerId, nameof(customerId)),
     Operation  = gax::GaxPreconditions.CheckNotNull(operation, nameof(operation)),
 }, callSettings);