def GetTimezones(): """Get a list of available timezones. Returns: list Available timezones. """ return Utils.GetDataFromCsvFile( os.path.join(LIB_HOME, 'data', 'timezones.csv'))
def GetCurrencies(): """Get a list of available currencies. Returns: list available currencies. """ return Utils.GetDataFromCsvFile( os.path.join(LIB_HOME, 'data', 'currencies.csv'))
def GetErrorCodes(): """Get a list of available error codes. Returns: list Available error codes. """ return Utils.GetDataFromCsvFile( os.path.join(LIB_HOME, 'data', 'error_codes.csv'))
def testSinglePartSingleStream(self): """Test whether we can set campaign geo targets using single part job with single stream.""" ops = [] csv_url = 'https://code.google.com/apis/adwords/docs/appendix/cities_us.csv' for city in Utils.GetDataFromCsvFile(csv_url)[:100]: ops.append( { 'xsi_type': 'CampaignTarget', 'operator': 'SET', 'operand': { 'xsi_type': 'GeoTargetList', 'campaignId': self.__class__.campaign_id, 'targets': [{ 'xsi_type': 'CityTarget', 'cityName': city[1].split(',')[0], 'countryCode': 'US' }] } } ) stream = { 'scopingEntityId': { 'type': 'CAMPAIGN_ID', 'value': self.__class__.campaign_id, }, 'operations': ops } part = { 'partIndex': '0', 'operationStreams': [stream] } operation = { 'operator': 'ADD', 'operand': { 'xsi_type': 'BulkMutateJob', 'request': part, 'numRequestParts': '1' } } job = self.__class__.service.Mutate(operation) self.assert_(isinstance(job, tuple)) result = self.__class__.service.DownloadBulkJob(job[0]['id']) self.assert_(isinstance(result, list))
'the latest version of client library at %s.' % LIB_URL) raise MissingPackageError(msg) # Tuple of tuples representing API versions, where each inner tuple is a # combination of the API vesrion and whether API used JAXB. API_VERSIONS_MAP = (('v13', False), ('v200909', True), ('v201003', True), ('v201008', True), ('v201101', True)) API_VERSIONS = [version for version, is_jaxb_api in API_VERSIONS_MAP] MIN_API_VERSION = API_VERSIONS[4] # Accepted combinations of headers which user has to provide. Either one of # these is required in order to make a succesful API request. REQUIRED_SOAP_HEADERS = (('email', 'password', 'useragent', 'developerToken'), ('email', 'password', 'userAgent', 'developerToken'), ('authToken', 'userAgent', 'developerToken'), ('userAgent', 'developerToken')) AUTH_TOKEN_SERVICE = 'adwords' AUTH_TOKEN_EXPIRE = 60 * 60 * 23 ERROR_TYPES = [] for item in Utils.GetDataFromCsvFile( os.path.join(LIB_HOME, 'data', 'error_types.csv')): ERROR_TYPES.append(item[0]) # Read the defintions from the WSDL. WSDL_MAP = pickle.load( open(os.path.join(LIB_HOME, 'data', 'wsdl_type_defs.pkl'), 'r')) OPERATIONS_MAP = pickle.load( open(os.path.join(LIB_HOME, 'data', 'wsdl_ops_defs.pkl'), 'r'))