Hey! 
I am trying to migrate a google script from google-ads version 14.0.1 to 
version 16.0.0 but I've encountered this error when I am executing the 
code. I've found nothing of use on the documentation about this 
get_costumer method so I would like to know what is the current form or use 
of it. 
Heres the code:

class Google():
    def __init__(self):
        settings = {
            'developer_token': os.environ['developer_token'],
            'refresh_token': os.environ['refresh_token'],
            'client_id': os.environ['client_id'],
            'client_secret': os.environ['client_secret'],
            'login_customer_id': os.environ['login_customer_id'],
            'use_proto_plus': True
        }
        
        self._client = GoogleAdsClient.load_from_dict(settings)
        self._DEFAULT_PAGE_SIZE = 10000
        self._get_accounts()
        self._get_campaigns()
    
    def _get_accounts(self):
        self._accounts = []
        seed_customer_ids = []
        query = """
            SELECT
                customer_client.client_customer,
                customer_client.level,
                customer_client.manager,
                customer_client.descriptive_name,
                customer_client.currency_code,
                customer_client.time_zone,
                customer_client.id
            FROM customer_client
            where customer_client.level <= 1"""
        customer_service = self._client.get_service("CustomerService")
        googleads_service = self._client.get_service("GoogleAdsService")

        customer_resource_names = 
(customer_service.list_accessible_customers().resource_names)

        for customer_resource_name in customer_resource_names:
##Here's the error 
            customer = customer_service.get_customer(
                resource_name=customer_resource_name
            )
            # print(customer.id)
            seed_customer_ids.append(customer.id)
        
        for seed_customer_id in seed_customer_ids:
            # Performas a breadth-first search to build a Dictionary that 
maps
            #  managers to their child accounts 
(customerIdsToChildAccounts).
            unprocessed_customer_ids = [seed_customer_id]
            customer_ids_to_child_accounts = dict()
            root_customer_client = None

            while unprocessed_customer_ids:
                customer_id = int(unprocessed_customer_ids.pop(0))
                response = googleads_service.search(
                    customer_id=str(customer_id), query=query
                )

                # Iterates over all rows in all pages to get all customer
                # clients under the specified customer's hierarchy.
                for googleads_row in response:
                    customer_client = googleads_row.customer_client

                    # The customer client that with level 0 is the specified
                    # customer.
                    if customer_client.level == 0:
                        if root_customer_client is None:
                            root_customer_client = customer_client
                        continue
                    else:
                        if customer_client.descriptive_name not in 
['AdsLive Inactivos', 'Cuentas Activas']:
                            self._accounts.append(customer_client)
                    
                    # For all level-1 (direct child) accounts that are a
                    # manager account, the above query will be run against 
them
                    # to create a dictionary of managers mapped to their 
child
                    # accounts to manage the hierarchy afterwards.
                    if customer_id not in customer_ids_to_child_accounts:
                        customer_ids_to_child_accounts[customer_id] = []

                    customer_ids_to_child_accounts[customer_id].append(
                        customer_client
                    )

                    if customer_client.manager:
                        # A customer can be managed by multiple managers, 
so to 
                        # prevent visiting the same customer many times, we
                        # need to check if it's already in the Dictionary.
                        if (
                            customer_client.id not in 
customer_ids_to_child_accounts
                            and customer_client.level == 1
                        ):
                            
unprocessed_customer_ids.append(customer_client.id)
    

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Google Ads API and AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/3477ae53-6c62-4b74-8016-0d5442a2b2ddn%40googlegroups.com.
  • Go... Luis Chutá
    • ... 'Google Ads API Forum Advisor' via Google Ads API and AdWords API Forum

Reply via email to