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
280 stars 260 forks source link

ResourceNames::forCustomerClient function disappeared #1015

Closed VladymyrKarpov closed 3 months ago

VladymyrKarpov commented 3 months ago

[DO NOT INCLUDE ANY PERSONAL OR SENSITIVE DATA - MAKE SURE TO REDACT CONTENT WHEN NECESSARY]

Your question: Could you please help me. I'm trying to construct resource name for client customer which is: The resource name of the customer client. CustomerClient resource names have the form: customers/{customer_id}/customerClients/{client_customer_id}. On version 19.2.0 there was a function in ResourceNames.php - ResourceNames::forCustomerClient($managerAccount->getId(), $clientId); Now on version 22.1.0 there is no such function. How can I achieve that? Thanks

fiboknacky commented 3 months ago

Some resource names that are not used with any services were removed. Could you please share how you use that method to do what operation?

VladymyrKarpov commented 3 months ago

Sure! I use it to search for particular customer assigned to manager account:

$googleAdsClient = (new GoogleAdsClientBuilder())
                        ->fromFile($settingsPass)
                        ->withOAuth2Credential($oAuth2Credential)
                        ->withLoginCustomerId($managerAccount->getId())
                        ->build();
                    $customerResourceName = ResourceNames::forCustomerClient($managerAccount->getId(), $clientId);
                    $query = "SELECT customer_client.id, customer_client.currency_code, customer_client.status, customer_client.descriptive_name FROM customer_client WHERE customer_client.resource_name = '$customerResourceName' AND customer_client.status = 'ENABLED'";
                    $response = $googleAdsServiceClient->searchStream($googleAdsClient->getLoginCustomerId(), $query);
                    $customer = $response->iterateAllElements()->current();

At this point only way to get what I want is to glue strings. I was surprised because I used that method previously without any issues. Thanks

fiboknacky commented 3 months ago

If you use a report, why don't you use the condition of customer_client.id == $clientId? That would be shorter than trying to glue strings together.

VladymyrKarpov commented 3 months ago

That is possible thanks. But I wonder why did that helper method just removed without any notifications. Thank you for help

fiboknacky commented 3 months ago

Sorry for that. It's due to the new source generation that we rely on. It'll generate the methods that are necessary for sending a mutate request to the API server.