AI-generated Key Takeaways
-
The ProtoLookupUtil simplifies interactions with the Google Ads API by removing the need to specify API version numbers and namespaces when working with services, operations, enumerations, and resources.
-
Instead of manually instantiating proto classes with complex paths, the utility allows you to create and access them using a more concise and intuitive syntax, such as
client.resource.campaign
instead ofGoogle::Ads::GoogleAds::V18::Resources::Campaign.new
. -
It offers a shortcut for using enumerations directly, like assigning
:PAUSED
to a campaign status, without requiring explicit proto lookups. -
Using
client.service
is recommended for fetching services, as it automatically handles developer token and authentication details.
Fetching references to proto classes when using the API requires that you either have an intrinsic understanding of the API or need to frequently look up the proto reference documentation for the exact path.
ProtoLookupUtil
The proto lookup util lets you look up and create instances of services, operations, enumerations, and resources without having to keep track of API version numbers and namespaces.
Here's how you typically instantiate a campaign:
campaign = Google::Ads::GoogleAds::V21::Resources::Campaign.new
But with the proto lookup util, you can use a simpler form:
campaign = client.resource.campaign
When fetching a resource, service, or operation, an instance of that entity is returned. When fetching an enumeration, a reference to the class is returned, without instantiation.
For enumerations, you can use a shortcut to bypass the need for looking up the enumeration protos.
campaign.status = :PAUSED
We recommend using the client.service
method to fetch services even if you
don't use this utility for any other use cases. There is extra logic built into
this method to pass along your developer token and authentication details, which
you would have to handle manually if you used another method.