Skip to content

Instantly share code, notes, and snippets.

@davedavis
Created June 24, 2020 23:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davedavis/8a7933353a94d97f2929fab285845cbf to your computer and use it in GitHub Desktop.
Save davedavis/8a7933353a94d97f2929fab285845cbf to your computer and use it in GitHub Desktop.
How to get Google Ads API ENUM Text Value From The The Returned Integer Index - Google Ads API ENUM Mapping
The Enum's come with some methods to translate between index and string
# client_service is the GoogleAdsClient object.
channel_types = client_service.get_type('AdvertisingChannelTypeEnum')
channel_types.AdvertisingChannelType.Value('SEARCH')
# => 2
channel_types.AdvertisingChannelType.Name(2)
# => 'SEARCH'
This was found by looking at docstrings, e.g.
channel_types.AdvertisingChannelType.__doc__
# => 'A utility for finding the names of enum values.'
Thanks to Heath-Winning @ StackOverflow for this.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment