2
votes

I'm having a very hard time understanding Google's API documentation and was hoping for some help here.

To me, as an extremely new developer, the Google API documentation makes no sense whatsoever.

I am using the google adwords Python library, and this code may be useful: https://github.com/googleads/googleads-python-lib/blob/b80b8b3741a55f1d00c5974bc58f92540663c6f6/examples/adwords/v201603/account_management/create_account.py. However, I need to link an already existing account by extending an invitation and marking it as pending. I'm not trying to create a new account.

So where do I begin with writing it in Python? I don't understand the documentation and just need to create an account based on a given customer ID. Any tips and tricks would be great!

1
Ads in an Python (desktop) application?linusg
No, I just want to be able to ping a bot with a command in order to link the accounts. So like !command <customerID> and it sends a pending invite. @linusgBadHorse

1 Answers

1
votes

To link an existing account into your MCC account, you also need to use the ManagedCustomerService, specifically the mutateLink method. In Python, it would look something like this:

# Create the service object
managed_customer_service = client.GetService('ManagedCustomerService', version='v201605')

# Construct the operation, operator "ADD" and status "PENDING" results in a new invitation
operation = {
    'operator': 'ADD',
    'operand': {
        'managerCustomerId': YOUR_MCC_ACCOUNT_ID,
        'clientCustomerId': ACCOUNT_ID_TO_BE_INVITED,
        'linkStatus': 'PENDING',
        'pendingDescriptiveName': 'Some text that helps identifying the invitation',
        'isHidden': False  # This can be used to hide the account in your MCC to decrease clutter
    }
}

# Send the operation
response = managed_customer_service.mutateLink([operation])

# Print out the resulting ManagedCustomerLink
pprint.pprint(response.links[0])

Note that I didn't test this code, but it should give you a general idea on how it works. See the reference guide for more details and how to proceed once the client account has accepted the invitation.