Ejemplo n.º 1
0
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="user">The AdWords user.</param>
        public void Run(AdWordsUser user)
        {
            using (ManagedCustomerService managedCustomerService =
                       (ManagedCustomerService)user.GetService(AdWordsService.v201806
                                                               .ManagedCustomerService))
            {
                // Create account.
                ManagedCustomer customer = new ManagedCustomer
                {
                    name = "Customer created with ManagedCustomerService on " +
                           new DateTime().ToString(),
                    currencyCode = "EUR",
                    dateTimeZone = "Europe/London"
                };

                // Create operations.
                ManagedCustomerOperation operation = new ManagedCustomerOperation
                {
                    operand   = customer,
                    @operator = Operator.ADD
                };

                // For whitelisted users only, uncomment two commands below as part of the
                // ADD operation to invite a user to have access to an account. An email
                // will be sent to that user inviting them to have access to the newly
                // created account.
                // operation.inviteeEmail = "*****@*****.**";
                // operation.inviteeRole = AccessRole.ADMINISTRATIVE;

                try
                {
                    ManagedCustomerOperation[] operations = new ManagedCustomerOperation[]
                    {
                        operation
                    };
                    // Add account.
                    ManagedCustomerReturnValue result = managedCustomerService.mutate(operations);

                    // Display accounts.
                    if (result.value != null && result.value.Length > 0)
                    {
                        ManagedCustomer customerResult = result.value[0];
                        Console.WriteLine("Account with customer ID \"{0}\" was created.",
                                          customerResult.customerId);
                    }
                    else
                    {
                        Console.WriteLine("No accounts were created.");
                    }
                }
                catch (Exception e)
                {
                    throw new System.ApplicationException("Failed to create accounts.", e);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="user">The AdWords user.</param>
        public void Run(AdWordsUser user)
        {
            using (ManagedCustomerService managedCustomerService =
                       (ManagedCustomerService)user.GetService(AdWordsService.v201806
                                                               .ManagedCustomerService))
            {
                // Create account.
                ManagedCustomer customer = new ManagedCustomer
                {
                    name = "Customer created with ManagedCustomerService on " +
                           new DateTime().ToString(),
                    currencyCode = "EUR",
                    dateTimeZone = "Europe/London"
                };

                // Create operations.
                ManagedCustomerOperation operation = new ManagedCustomerOperation
                {
                    operand   = customer,
                    @operator = Operator.ADD
                };

                try
                {
                    ManagedCustomerOperation[] operations = new ManagedCustomerOperation[]
                    {
                        operation
                    };
                    // Add account.
                    ManagedCustomerReturnValue result = managedCustomerService.mutate(operations);

                    // Display accounts.
                    if (result.value != null && result.value.Length > 0)
                    {
                        ManagedCustomer customerResult = result.value[0];
                        Console.WriteLine("Account with customer ID \"{0}\" was created.",
                                          customerResult.customerId);
                    }
                    else
                    {
                        Console.WriteLine("No accounts were created.");
                    }
                }
                catch (Exception e)
                {
                    throw new System.ApplicationException("Failed to create accounts.", e);
                }
            }
        }