google-ads-ruby icon indicating copy to clipboard operation
google-ads-ruby copied to clipboard

Using SearchSettings in V18

Open trwong opened this issue 9 months ago • 1 comments

What is your question?

Before V18 I was making the following call:

@config_path = Rails.root.join("...").to_s
@google_ads_client = Google::Ads::GoogleAds::GoogleAdsClient.new(@config_path)
click_view_report = @google_ads_client.service.google_ads.search(
  customer_id: @account_id.delete("-"),
  query: click_view_query,
  return_total_results_count: true
)

After V18 return_total_results_count should be passed as type SearchSettings from the docs here: https://developers.google.com/google-ads/api/docs/release-notes#reporting

I've tried a couple work arounds like passing a Google::Protobuf::Struct.new and a hash like so:

@config_path = Rails.root.join("...").to_s
@google_ads_client = Google::Ads::GoogleAds::GoogleAdsClient.new(@config_path)
click_view_report = @google_ads_client.service.google_ads.search(
  customer_id: @account_id.delete("-"),
  query: click_view_query,
  search_settings: {
    return_total_results_count: true
  }
)

What is the right way to pass search_settings into this call?

trwong avatar Feb 21 '25 18:02 trwong

client = Google::Ads::GoogleAds::GoogleAdsClient.new do |config|
  config.refresh_token = '123'
  config.client_id = '321'
  config.client_secret = 'xxx'
  config.login_customer_id = 123
  config.developer_token= 'zzz'
  config.logger = Rails.logger
end
#<Google::Ads::GoogleAds::GoogleAdsClient:0x0000ffff77c04780
client.resource.search_settings do |s|
  s.return_total_results_count = true
end
# <Google::Ads::GoogleAds::V18::Services::SearchSettings: omit_results: false, return_summary_row: false, return_total_results_count: true>

tmck-code avatar Jun 16 '25 05:06 tmck-code