googleads / google-ads-php

Google Ads API Client Library for PHP
https://developers.google.com/google-ads/api/docs/client-libs/php
Apache License 2.0
290 stars 260 forks source link

Campaign's Primary Status returning as number #905

Closed amitdangwal closed 1 year ago

amitdangwal commented 1 year ago

Hi,

I am using V13 google ads php library. I am trying to fetch the campaigns via below GAQL. I want to fetch the primary status of the campaign (which should come as Eligible, Ended etc i.e the text values of Enum struct supported by primary status). However, when I try to fetch the same I see it returns the primary status as number (5 or 2 etc) and not as text string. So will it return number or a text string on $campaign->getPrimaryStatus(); ? I have contacted "Google Ads API Direct Support" and they are saying it is the bug in the PHP library as it must return the text string as given in the enum structure and I must raise a ticket here in git. $query = "SELECT campaign.primary_status,campaign.id, campaign.name FROM campaign"; $campaign = $googleAdsRow->getCampaign(); .... printf( "Campaign name %s, Primary status: %s",$campaign->getName(),**$campaign->getPrimaryStatus()**, PHP_EOL); $campaign->getPrimaryStatus(); ......

below output I am getting as "5" instead of text value i.e Eligible or Not_Eligible or Ended or Paused etc. Campaign name - MY Campaiign Landing Page Test, **Primary status: 5**

Please guide me as what is the expected output from $campaign->getPrimaryStatus() (number ie. 2/3/4 or text String as Eligible or Not_Eligible or Ended or Paused )

https://developers.google.com/google-ads/api/fields/v13/ad_group_asset#ad_group_asset.primary_status ` ENUM

ELIGIBLE LIMITED NOT_ELIGIBLE PAUSED PENDING REMOVED UNKNOWN UNSPECIFIED `

fiboknacky commented 1 year ago

It's not a bug. You need to translate the number to string by yourself using enum-like classes like shown on this line for criterion types. For your use case, you can use CampaignPrimaryStatus::name