Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ManagedCustomerService fields values and capitalization #141

Closed
jaradc opened this issue Aug 11, 2016 · 1 comment
Closed

ManagedCustomerService fields values and capitalization #141

jaradc opened this issue Aug 11, 2016 · 1 comment

Comments

@jaradc
Copy link

jaradc commented Aug 11, 2016

My question is regarding the 'fields': ['CustomerId'] below for a ManagedCustomerService service object. The documentation shows uncapitalized customerId as the string but the below code only works when it's capitalized CustomerId. Is the documentation I'm looking at no relevant to Python? Also, is there a way to check programmatically what the options are via the API?

Thanks

import logging
import sys
import webbrowser
import os
import yaml
from googleads import adwords, oauth2
from io import StringIO
from oauth2client import client
import time
import datetime
import codecs

PATH = os.getcwd()+'\\googleads.yaml'

# open the yaml file to get credentials from it
with open(PATH, 'r') as f:
  # yaml_data is a json-like nested dict - first key is "adwords"
  yaml_data = yaml.safe_load(f.read())
  # for each key in the yaml_data
  for yaml_key in yaml_data:
    # get credentials related to each key
    auth_data = yaml_data.get(yaml_key)
    # use auth_data to create an oauth client
    oauth2_client = oauth2.GoogleRefreshTokenClient(
      auth_data['client_id'],
      auth_data['client_secret'],
      auth_data['refresh_token']
      )
    # use the oauth2_client created above as a parameter to make an adwords_client
    adwords_client = adwords.AdWordsClient(
      auth_data['developer_token'],
      oauth2_client,
      auth_data['user_agent'],
      client_customer_id = auth_data['client_customer_id']
      )
    # creates a service object using the adwords_client to create a managed service object
    managed_customer_service = adwords_client.GetService(
      'ManagedCustomerService', version='v201607')
    # CustomerId NEEDS to be capitalized even though documentation shows otherwise
    mcc_accounts = managed_customer_service.get(
      {'fields': ['CustomerId'],
       'predicates': [{
        'field': 'CanManageClients',
        'operator': 'NOT_EQUALS',
        'values': True
        }]
      })
@jaradc
Copy link
Author

jaradc commented Aug 11, 2016

My apologies. I understand now. CustomerID is a field of ManagedCustomerService.

@jaradc jaradc closed this as completed Aug 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant