653 في الأربعاء، 1 سبتمبر، 2021 2:33 ص 'EladB' via AdWords API and Google Ads API Forum <adwords-api@googlegroups.com> كتب:
> Hi esteemed, > > I want to audit the mandatory fields of a few ads from different types > (text ads, extended-text ads, responsive text ads). > > How would you do this (python 3.8 compatible)? > > I see my select clause should fetch a few fields. How would you switch > case the ad type while making sure my code resilient for cases when the > `yaml` file doesn't contain `Proto-plus = True` (for enum names: [one > <https://developers.google.com/google-ads/api/docs/client-libs/python/protobuf-messages?hl=en#retrieving_enum_names>], > [two > <https://developers.google.com/google-ads/api/fields/v6/ad_group_ad#ad_group_ad.ad.type> > ]) > > > Thanks! > > My code: > > query = f""" > SELECT > customer.id, > campaign.id, > ad_group_ad.ad.type, > ad_group_ad.ad.text_ad.headline, > ad_group_ad.ad.text_ad.description1, > ad_group_ad.ad.text_ad.description2, > > ad_group_ad.ad.expanded_text_ad.headline_part1, > ad_group_ad.ad.expanded_text_ad.headline_part2, > ad_group_ad.ad.expanded_text_ad.headline_part3, > > ad_group_ad.ad.responsive_search_ad.headlines, > ad_group_ad.ad.responsive_search_ad.descriptions, > ad_group_ad.ad.responsive_search_ad.path1, > ad_group_ad.ad.responsive_search_ad.path2, > > ad_group_ad.ad.id, > ad_group_ad.ad.type, > ad_group_ad.ad_group, > ad_group_ad.policy_summary.approval_status, > ad_group_ad.policy_summary.policy_topic_entries > FROM ad_group_ad > WHERE > ad_group_ad.policy_summary.approval_status = DISAPPROVED""" > > customer_id = account["id"] > rows = serviceWrapper.get_rows(customer_id, query) > for row in rows: > ad_group_ad = row.ad_group_ad > ad = ad_group_ad.ad > if ad.type_.name.upper() == "TEXT_AD": > print( > f'\tad.text_ad.headline: "{ad.text_ad.headline}", > desc1: "{ad.text_ad.description1}", ' > f'desc2: "{ad.text_ad.description2}"') > elif ad.type_.name.upper() == "EXPANDED_TEXT_AD": > print( > f'\tad.expanded_text_ad.headline_part1: > "{ad.expanded_text_ad.headline_part1}", > ad_group_ad.ad.expanded_text_ad.headline_part1: > "{ad_group_ad.ad.expanded_text_ad.headline_part1}", ' > f'ad_group_ad.ad.expanded_text_ad.headline_part2: > "{ad_group_ad.ad.expanded_text_ad.headline_part2}"') > elif ad.type_.name.upper() == "RESPONSIVE_SEARCH_AD": > print( > f'\tad_group_ad.ad.responsive_search_ad.headlines: > "{ad_group_ad.ad.responsive_search_ad.headlines}", > ad_group_ad.ad.responsive_search_ad.descriptions: > "{ad_group_ad.ad.responsive_search_ad.descriptions}", ' > f'ad_group_ad.ad.responsive_search_ad.path1: > "{ad_group_ad.ad.responsive_search_ad.path1}", > ad_group_ad.ad.responsive_search_ad.path2: > "{ad_group_ad.ad.responsive_search_ad.path2}"') > > -- > -- > =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ > Also find us on our blog: > https://googleadsdeveloper.blogspot.com/ > =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ > > You received this message because you are subscribed to the Google > Groups "AdWords API and Google Ads API Forum" group. > To post to this group, send email to adwords-api@googlegroups.com > To unsubscribe from this group, send email to > adwords-api+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/adwords-api?hl=en > --- > You received this message because you are subscribed to the Google Groups > "AdWords API and Google Ads API Forum" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to adwords-api+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/adwords-api/4508bfa9-01b1-4674-a700-f97786f86964n%40googlegroups.com > <https://groups.google.com/d/msgid/adwords-api/4508bfa9-01b1-4674-a700-f97786f86964n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- -- =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ Also find us on our blog: https://googleadsdeveloper.blogspot.com/ =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ You received this message because you are subscribed to the Google Groups "AdWords API and Google Ads API Forum" group. To post to this group, send email to adwords-api@googlegroups.com To unsubscribe from this group, send email to adwords-api+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/adwords-api?hl=en --- You received this message because you are subscribed to the Google Groups "AdWords API and Google Ads API Forum" group. To unsubscribe from this group and stop receiving emails from it, send an email to adwords-api+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-api/CAOmUA%2BRWmKrZv8xwCZT-vLnCBT%3DQW%3Dt2oMRu148eTpbAbrRCDg%40mail.gmail.com.