Created
June 24, 2020 23:16
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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