Class: Zernio::AdInsightsApi

Inherits:
Object
  • Object
show all
Defined in:
lib/zernio-sdk/api/ad_insights_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ AdInsightsApi

Returns a new instance of AdInsightsApi.



19
20
21
# File 'lib/zernio-sdk/api/ad_insights_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_client ⇒ Object

Returns the value of attribute api_client.



17
18
19
# File 'lib/zernio-sdk/api/ad_insights_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#create_ad_insights_report(create_ad_insights_report_request, opts = {}) ⇒ CreateAdInsightsReport202Response

Submit async insights report Submits an asynchronous Meta insights report. Same query surface as GET /v1/ads/insights, but in the JSON body; Meta processes the report server-side, which is the right choice for long ranges or large accounts where the sync query is slow or rate-limited. Returns a reportRunId to poll via GET /v1/ads/insights/reports/reportRunId.

Parameters:

Returns:



27
28
29
30
# File 'lib/zernio-sdk/api/ad_insights_api.rb', line 27

def create_ad_insights_report(create_ad_insights_report_request, opts = {})
  data, _status_code, _headers = create_ad_insights_report_with_http_info(create_ad_insights_report_request, opts)
  data
end

#create_ad_insights_report_with_http_info(create_ad_insights_report_request, opts = {}) ⇒ Array<(CreateAdInsightsReport202Response, Integer, Hash)>

Submit async insights report Submits an asynchronous Meta insights report. Same query surface as GET /v1/ads/insights, but in the JSON body; Meta processes the report server-side, which is the right choice for long ranges or large accounts where the sync query is slow or rate-limited. Returns a `reportRunId` to poll via GET /v1/ads/insights/reports/reportRunId.

Parameters:

Returns:



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/zernio-sdk/api/ad_insights_api.rb', line 37

def create_ad_insights_report_with_http_info(create_ad_insights_report_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AdInsightsApi.create_ad_insights_report ...'
  end
  # verify the required parameter 'create_ad_insights_report_request' is set
  if @api_client.config.client_side_validation && create_ad_insights_report_request.nil?
    fail ArgumentError, "Missing the required parameter 'create_ad_insights_report_request' when calling AdInsightsApi.create_ad_insights_report"
  end
  # resource path
  local_var_path = '/v1/ads/insights/reports'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(create_ad_insights_report_request)

  # return_type
  return_type = opts[:debug_return_type] || 'CreateAdInsightsReport202Response'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"AdInsightsApi.create_ad_insights_report",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: AdInsightsApi#create_ad_insights_report\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#generate_keyword_historical_metrics(generate_keyword_historical_metrics_request, opts = {}) ⇒ GenerateKeywordHistoricalMetrics200Response

Get historical keyword metrics Google Ads only. Runs Keyword Planner's generateKeywordHistoricalMetrics for up to 1,000 exact keywords: historical search volume, competition and top-of-page bid ranges, plus averageCpcMicros when includeAverageCpc is set. Rows come back verbatim; counters are int64s encoded as strings, bid/CPC values are micros of the account currency.

Parameters:

Returns:



95
96
97
98
# File 'lib/zernio-sdk/api/ad_insights_api.rb', line 95

def generate_keyword_historical_metrics(generate_keyword_historical_metrics_request, opts = {})
  data, _status_code, _headers = generate_keyword_historical_metrics_with_http_info(generate_keyword_historical_metrics_request, opts)
  data
end

#generate_keyword_historical_metrics_with_http_info(generate_keyword_historical_metrics_request, opts = {}) ⇒ Array<(GenerateKeywordHistoricalMetrics200Response, Integer, Hash)>

Get historical keyword metrics Google Ads only. Runs Keyword Planner's generateKeywordHistoricalMetrics for up to 1,000 exact keywords: historical search volume, competition and top-of-page bid ranges, plus averageCpcMicros when includeAverageCpc is set. Rows come back verbatim; counters are int64s encoded as strings, bid/CPC values are micros of the account currency.

Parameters:

Returns:



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/zernio-sdk/api/ad_insights_api.rb', line 105

def generate_keyword_historical_metrics_with_http_info(generate_keyword_historical_metrics_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AdInsightsApi.generate_keyword_historical_metrics ...'
  end
  # verify the required parameter 'generate_keyword_historical_metrics_request' is set
  if @api_client.config.client_side_validation && generate_keyword_historical_metrics_request.nil?
    fail ArgumentError, "Missing the required parameter 'generate_keyword_historical_metrics_request' when calling AdInsightsApi.generate_keyword_historical_metrics"
  end
  # resource path
  local_var_path = '/v1/ads/keywords/historical-metrics'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(generate_keyword_historical_metrics_request)

  # return_type
  return_type = opts[:debug_return_type] || 'GenerateKeywordHistoricalMetrics200Response'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"AdInsightsApi.generate_keyword_historical_metrics",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: AdInsightsApi#generate_keyword_historical_metrics\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#generate_keyword_ideas(generate_keyword_ideas_request, opts = {}) ⇒ GenerateKeywordIdeas200Response

Generate keyword ideas Google Ads only. Runs Keyword Planner's generateKeywordIdeas from seed keywords, a seed URL, or both, returning idea rows verbatim (avgMonthlySearches, competition, competitionIndex, top-of-page bid micros, monthlySearchVolumes). Counters are int64s encoded as strings; bid values are micros of the account currency. Omitting countries targets worldwide.

Parameters:

Returns:



163
164
165
166
# File 'lib/zernio-sdk/api/ad_insights_api.rb', line 163

def generate_keyword_ideas(generate_keyword_ideas_request, opts = {})
  data, _status_code, _headers = generate_keyword_ideas_with_http_info(generate_keyword_ideas_request, opts)
  data
end

#generate_keyword_ideas_with_http_info(generate_keyword_ideas_request, opts = {}) ⇒ Array<(GenerateKeywordIdeas200Response, Integer, Hash)>

Generate keyword ideas Google Ads only. Runs Keyword Planner's generateKeywordIdeas from seed keywords, a seed URL, or both, returning idea rows verbatim (avgMonthlySearches, competition, competitionIndex, top-of-page bid micros, monthlySearchVolumes). Counters are int64s encoded as strings; bid values are micros of the account currency. Omitting `countries` targets worldwide.

Parameters:

Returns:



173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
# File 'lib/zernio-sdk/api/ad_insights_api.rb', line 173

def generate_keyword_ideas_with_http_info(generate_keyword_ideas_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AdInsightsApi.generate_keyword_ideas ...'
  end
  # verify the required parameter 'generate_keyword_ideas_request' is set
  if @api_client.config.client_side_validation && generate_keyword_ideas_request.nil?
    fail ArgumentError, "Missing the required parameter 'generate_keyword_ideas_request' when calling AdInsightsApi.generate_keyword_ideas"
  end
  # resource path
  local_var_path = '/v1/ads/keywords/ideas'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(generate_keyword_ideas_request)

  # return_type
  return_type = opts[:debug_return_type] || 'GenerateKeywordIdeas200Response'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"AdInsightsApi.generate_keyword_ideas",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: AdInsightsApi#generate_keyword_ideas\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_ad_analytics(ad_id, opts = {}) ⇒ AdAnalyticsResponse

Get ad analytics Returns detailed performance analytics for an ad. Includes summary metrics, a daily timeline over the requested date range, and optional demographic breakdowns (Meta and TikTok only). If no date range is provided, defaults to the last 90 days. Date range is capped at 730 days max.

Parameters:

  • ad_id (String)
  • opts (Hash) (defaults to: {}) —

    the optional parameters

Options Hash (opts):

  • :from_date (Date) —

    Start of date range (YYYY-MM-DD). Defaults to 90 days ago.

  • :to_date (Date) —

    End of date range (YYYY-MM-DD). Defaults to today. Max 730-day range.

  • :breakdowns (String) —

    Comma-separated breakdown dimensions. Meta: age, gender, country, publisher_platform, device_platform, region. TikTok: gender, age, country_code, platform, ac, language. LinkedIn (firmographics): job_title, job_function, seniority, industry, company, company_size, country, region. Rows carry the raw pivot `value` plus a resolved `name`. LinkedIn serves these aggregated over the whole range, delays the data 12-24h, and omits segments with fewer than 3 events.

Returns:



234
235
236
237
# File 'lib/zernio-sdk/api/ad_insights_api.rb', line 234

def get_ad_analytics(ad_id, opts = {})
  data, _status_code, _headers = get_ad_analytics_with_http_info(ad_id, opts)
  data
end

#get_ad_analytics_with_http_info(ad_id, opts = {}) ⇒ Array<(AdAnalyticsResponse, Integer, Hash)>

Get ad analytics Returns detailed performance analytics for an ad. Includes summary metrics, a daily timeline over the requested date range, and optional demographic breakdowns (Meta and TikTok only). If no date range is provided, defaults to the last 90 days. Date range is capped at 730 days max.

Parameters:

  • ad_id (String)
  • opts (Hash) (defaults to: {}) —

    the optional parameters

Options Hash (opts):

  • :from_date (Date) —

    Start of date range (YYYY-MM-DD). Defaults to 90 days ago.

  • :to_date (Date) —

    End of date range (YYYY-MM-DD). Defaults to today. Max 730-day range.

  • :breakdowns (String) —

    Comma-separated breakdown dimensions. Meta: age, gender, country, publisher_platform, device_platform, region. TikTok: gender, age, country_code, platform, ac, language. LinkedIn (firmographics): job_title, job_function, seniority, industry, company, company_size, country, region. Rows carry the raw pivot `value` plus a resolved `name`. LinkedIn serves these aggregated over the whole range, delays the data 12-24h, and omits segments with fewer than 3 events.

Returns:

  • (Array<(AdAnalyticsResponse, Integer, Hash)>) —

    AdAnalyticsResponse data, response status code and response headers



247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
# File 'lib/zernio-sdk/api/ad_insights_api.rb', line 247

def get_ad_analytics_with_http_info(ad_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AdInsightsApi.get_ad_analytics ...'
  end
  # verify the required parameter 'ad_id' is set
  if @api_client.config.client_side_validation && ad_id.nil?
    fail ArgumentError, "Missing the required parameter 'ad_id' when calling AdInsightsApi.get_ad_analytics"
  end
  # resource path
  local_var_path = '/v1/ads/{adId}/analytics'.sub('{' + 'adId' + '}', CGI.escape(ad_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'fromDate'] = opts[:'from_date'] if !opts[:'from_date'].nil?
  query_params[:'toDate'] = opts[:'to_date'] if !opts[:'to_date'].nil?
  query_params[:'breakdowns'] = opts[:'breakdowns'] if !opts[:'breakdowns'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'AdAnalyticsResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"AdInsightsApi.get_ad_analytics",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: AdInsightsApi#get_ad_analytics\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_ad_insights_report(report_run_id, account_id, opts = {}) ⇒ GetAdInsightsReport200Response

Poll an async insights report run Status and results for a report run created via POST /v1/ads/insights/reports. While the job runs, returns status and percentCompletion. Once status is "Job Completed" the response also carries a data page, cursor-paginated via limit / after.

Parameters:

  • report_run_id (String)
  • account_id (String) —

    Zernio SocialAccount id used to resolve the Meta token (must be the same connection that created the run).

  • opts (Hash) (defaults to: {}) —

    the optional parameters

Options Hash (opts):

  • :limit (Integer) — default: default to 25
  • :after (String)

Returns:



306
307
308
309
# File 'lib/zernio-sdk/api/ad_insights_api.rb', line 306

def get_ad_insights_report(report_run_id, , opts = {})
  data, _status_code, _headers = get_ad_insights_report_with_http_info(report_run_id, , opts)
  data
end

#get_ad_insights_report_with_http_info(report_run_id, account_id, opts = {}) ⇒ Array<(GetAdInsightsReport200Response, Integer, Hash)>

Poll an async insights report run Status and results for a report run created via POST /v1/ads/insights/reports. While the job runs, returns `status` and `percentCompletion`. Once `status` is &quot;Job Completed&quot; the response also carries a `data` page, cursor-paginated via `limit` / `after`.

Parameters:

  • report_run_id (String)
  • account_id (String) —

    Zernio SocialAccount id used to resolve the Meta token (must be the same connection that created the run).

  • opts (Hash) (defaults to: {}) —

    the optional parameters

Options Hash (opts):

  • :limit (Integer) — default: default to 25
  • :after (String)

Returns:



319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
# File 'lib/zernio-sdk/api/ad_insights_api.rb', line 319

def get_ad_insights_report_with_http_info(report_run_id, , opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AdInsightsApi.get_ad_insights_report ...'
  end
  # verify the required parameter 'report_run_id' is set
  if @api_client.config.client_side_validation && report_run_id.nil?
    fail ArgumentError, "Missing the required parameter 'report_run_id' when calling AdInsightsApi.get_ad_insights_report"
  end
  # verify the required parameter 'account_id' is set
  if @api_client.config.client_side_validation && .nil?
    fail ArgumentError, "Missing the required parameter 'account_id' when calling AdInsightsApi.get_ad_insights_report"
  end
  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 500
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling AdInsightsApi.get_ad_insights_report, must be smaller than or equal to 500.'
  end

  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling AdInsightsApi.get_ad_insights_report, must be greater than or equal to 1.'
  end

  # resource path
  local_var_path = '/v1/ads/insights/reports/{reportRunId}'.sub('{' + 'reportRunId' + '}', CGI.escape(report_run_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'accountId'] = 
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'after'] = opts[:'after'] if !opts[:'after'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'GetAdInsightsReport200Response'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"AdInsightsApi.get_ad_insights_report",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: AdInsightsApi#get_ad_insights_report\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_ads_search_terms(account_id, opts = {}) ⇒ GetAdsSearchTerms200Response

Google Ads search terms report The actual search queries that triggered your ads, with matched-keyword status and spend metrics, the raw material for wasted-spend analysis and negative-keyword lists. Reads Google's search_term_view, cached for the quota window; defaults to the last 30 days. Rows are ordered by cost, descending. Draws on the shared Google Ads operations budget. The response carries cachedAt and stale, set when a quota-exhausted call falls back to the last-good copy instead of a live read.

Parameters:

  • account_id (String) —

    Google ads SocialAccount id.

  • opts (Hash) (defaults to: {}) —

    the optional parameters

Options Hash (opts):

  • :ad_account_id (String) —

    Platform ad account ID (Google customer ID, digits only). Defaults to the account's connected customer.

  • :customer_id (String) —

    Alias of adAccountId, kept for existing callers

  • :from_date (Date) —

    Defaults to 30 days ago.

  • :to_date (Date) —

    Defaults to today.

  • :campaign_id (String) —

    Numeric Google campaign id filter.

  • :ad_set_id (String) —

    Platform ad set ID (Google ad group). Same value as adSetId on listAdKeywords and /ad-sets/adSetId/assets.

  • :ad_group_id (String) —

    Alias of adSetId, kept for existing callers.

  • :page_token (String) —

    Cursor from paging.nextPageToken of the previous page.

Returns:



395
396
397
398
# File 'lib/zernio-sdk/api/ad_insights_api.rb', line 395

def get_ads_search_terms(, opts = {})
  data, _status_code, _headers = get_ads_search_terms_with_http_info(, opts)
  data
end

#get_ads_search_terms_with_http_info(account_id, opts = {}) ⇒ Array<(GetAdsSearchTerms200Response, Integer, Hash)>

Google Ads search terms report The actual search queries that triggered your ads, with matched-keyword status and spend metrics, the raw material for wasted-spend analysis and negative-keyword lists. Reads Google's `search_term_view`, cached for the quota window; defaults to the last 30 days. Rows are ordered by cost, descending. Draws on the shared Google Ads operations budget. The response carries `cachedAt` and `stale`, set when a quota-exhausted call falls back to the last-good copy instead of a live read.

Parameters:

  • account_id (String) —

    Google ads SocialAccount id.

  • opts (Hash) (defaults to: {}) —

    the optional parameters

Options Hash (opts):

  • :ad_account_id (String) —

    Platform ad account ID (Google customer ID, digits only). Defaults to the account's connected customer.

  • :customer_id (String) —

    Alias of adAccountId, kept for existing callers

  • :from_date (Date) —

    Defaults to 30 days ago.

  • :to_date (Date) —

    Defaults to today.

  • :campaign_id (String) —

    Numeric Google campaign id filter.

  • :ad_set_id (String) —

    Platform ad set ID (Google ad group). Same value as adSetId on listAdKeywords and /ad-sets/adSetId/assets.

  • :ad_group_id (String) —

    Alias of adSetId, kept for existing callers.

  • :page_token (String) —

    Cursor from paging.nextPageToken of the previous page.

Returns:



413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
# File 'lib/zernio-sdk/api/ad_insights_api.rb', line 413

def get_ads_search_terms_with_http_info(, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AdInsightsApi.get_ads_search_terms ...'
  end
  # verify the required parameter 'account_id' is set
  if @api_client.config.client_side_validation && .nil?
    fail ArgumentError, "Missing the required parameter 'account_id' when calling AdInsightsApi.get_ads_search_terms"
  end
  # resource path
  local_var_path = '/v1/ads/search-terms'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'accountId'] = 
  query_params[:'adAccountId'] = opts[:'ad_account_id'] if !opts[:'ad_account_id'].nil?
  query_params[:'customerId'] = opts[:'customer_id'] if !opts[:'customer_id'].nil?
  query_params[:'fromDate'] = opts[:'from_date'] if !opts[:'from_date'].nil?
  query_params[:'toDate'] = opts[:'to_date'] if !opts[:'to_date'].nil?
  query_params[:'campaignId'] = opts[:'campaign_id'] if !opts[:'campaign_id'].nil?
  query_params[:'adSetId'] = opts[:'ad_set_id'] if !opts[:'ad_set_id'].nil?
  query_params[:'adGroupId'] = opts[:'ad_group_id'] if !opts[:'ad_group_id'].nil?
  query_params[:'pageToken'] = opts[:'page_token'] if !opts[:'page_token'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'GetAdsSearchTerms200Response'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"AdInsightsApi.get_ads_search_terms",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: AdInsightsApi#get_ads_search_terms\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_campaign_analytics(campaign_id, opts = {}) ⇒ CampaignAnalyticsResponse

Get campaign analytics Returns performance analytics for a whole campaign in one call: summary metrics, a daily timeline over the requested date range (summed across the campaign's ads), and optional demographic breakdowns. Breakdowns are fetched live from Meta at the campaign level (one call per dimension, no per-ad fan-out), so an agency dashboard gets campaign-level age/gender/etc. without summing thousands of per-ad reads. campaignId is the platform campaign id; pass platform when a campaign id could be ambiguous across platforms. If no date range is provided, defaults to the last 90 days. Date range is capped at 730 days max. Google adds searchImpressionShare, searchBudgetLostImpressionShare, searchRankLostImpressionShare, searchTopImpressionShare and searchAbsoluteTopImpressionShare under analytics.summary for the requested inclusive range. These ratios are queried together without daily segmentation and cached for 10 minutes. Unavailable values are null. analytics.impressionShareCache reports cachedAt and stale independently of synced metrics.

Parameters:

  • campaign_id (String) —

    Platform campaign id (platformCampaignId).

  • opts (Hash) (defaults to: {}) —

    the optional parameters

Options Hash (opts):

  • :platform (String) —

    Disambiguate when the campaign id exists across platforms (e.g. facebook, instagram).

  • :from_date (Date) —

    Start of date range (YYYY-MM-DD). Defaults to 90 days ago.

  • :to_date (Date) —

    End of date range (YYYY-MM-DD). Defaults to today. Max 730-day range.

  • :breakdowns (String) —

    Comma-separated breakdown dimensions. Meta: age, gender, country, publisher_platform, device_platform, region, platform_position, impression_device, video_asset, image_asset, body_asset, title_asset. LinkedIn (firmographics): job_title, job_function, seniority, industry, company, company_size, country, region. Rows carry the raw pivot `value` plus a resolved `name`. LinkedIn serves these aggregated over the whole range, delays the data 12-24h, and omits segments with fewer than 3 events.

Returns:



479
480
481
482
# File 'lib/zernio-sdk/api/ad_insights_api.rb', line 479

def get_campaign_analytics(campaign_id, opts = {})
  data, _status_code, _headers = get_campaign_analytics_with_http_info(campaign_id, opts)
  data
end

#get_campaign_analytics_with_http_info(campaign_id, opts = {}) ⇒ Array<(CampaignAnalyticsResponse, Integer, Hash)>

Get campaign analytics Returns performance analytics for a whole campaign in one call: summary metrics, a daily timeline over the requested date range (summed across the campaign's ads), and optional demographic breakdowns. Breakdowns are fetched live from Meta at the campaign level (one call per dimension, no per-ad fan-out), so an agency dashboard gets campaign-level age/gender/etc. without summing thousands of per-ad reads. `campaignId` is the platform campaign id; pass `platform` when a campaign id could be ambiguous across platforms. If no date range is provided, defaults to the last 90 days. Date range is capped at 730 days max. Google adds searchImpressionShare, searchBudgetLostImpressionShare, searchRankLostImpressionShare, searchTopImpressionShare and searchAbsoluteTopImpressionShare under analytics.summary for the requested inclusive range. These ratios are queried together without daily segmentation and cached for 10 minutes. Unavailable values are null. analytics.impressionShareCache reports cachedAt and stale independently of synced metrics.

Parameters:

  • campaign_id (String) —

    Platform campaign id (platformCampaignId).

  • opts (Hash) (defaults to: {}) —

    the optional parameters

Options Hash (opts):

  • :platform (String) —

    Disambiguate when the campaign id exists across platforms (e.g. facebook, instagram).

  • :from_date (Date) —

    Start of date range (YYYY-MM-DD). Defaults to 90 days ago.

  • :to_date (Date) —

    End of date range (YYYY-MM-DD). Defaults to today. Max 730-day range.

  • :breakdowns (String) —

    Comma-separated breakdown dimensions. Meta: age, gender, country, publisher_platform, device_platform, region, platform_position, impression_device, video_asset, image_asset, body_asset, title_asset. LinkedIn (firmographics): job_title, job_function, seniority, industry, company, company_size, country, region. Rows carry the raw pivot `value` plus a resolved `name`. LinkedIn serves these aggregated over the whole range, delays the data 12-24h, and omits segments with fewer than 3 events.

Returns:

  • (Array<(CampaignAnalyticsResponse, Integer, Hash)>) —

    CampaignAnalyticsResponse data, response status code and response headers



493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
# File 'lib/zernio-sdk/api/ad_insights_api.rb', line 493

def get_campaign_analytics_with_http_info(campaign_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AdInsightsApi.get_campaign_analytics ...'
  end
  # verify the required parameter 'campaign_id' is set
  if @api_client.config.client_side_validation && campaign_id.nil?
    fail ArgumentError, "Missing the required parameter 'campaign_id' when calling AdInsightsApi.get_campaign_analytics"
  end
  # resource path
  local_var_path = '/v1/ads/campaigns/{campaignId}/analytics'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'platform'] = opts[:'platform'] if !opts[:'platform'].nil?
  query_params[:'fromDate'] = opts[:'from_date'] if !opts[:'from_date'].nil?
  query_params[:'toDate'] = opts[:'to_date'] if !opts[:'to_date'].nil?
  query_params[:'breakdowns'] = opts[:'breakdowns'] if !opts[:'breakdowns'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'CampaignAnalyticsResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"AdInsightsApi.get_campaign_analytics",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: AdInsightsApi#get_campaign_analytics\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_tik_tok_smart_plus_material_report(account_id, ad_account_id, start_date, end_date, opts = {}) ⇒ GetTikTokSmartPlusMaterialReport200Response

Per-creative performance inside TikTok Smart+ ads Breaks a Smart+ ad (or ad group) down by creative material, one row per Spark post, video or image, from TikTok's Smart+ material report. For a Spark post tiktokItemId is the TikTok post id. Conversion metrics are TikTok web (pixel) events. TikTok allows two dimensions per report, so rows are keyed by the Smart+ ad (level=ad) or by the ad group (level=adGroup), not both. Metrics TikTok returns empty come back as null.

Parameters:

  • account_id (String) —

    A tiktok or tiktokads account ID

  • ad_account_id (String) —

    TikTok advertiser ID

  • start_date (Date) —

    YYYY-MM-DD, in the advertiser's time zone

  • end_date (Date) —

    YYYY-MM-DD, on or after startDate

  • opts (Hash) (defaults to: {}) —

    the optional parameters

Options Hash (opts):

  • :level (String) —

    Key each row by Smart+ ad or by ad group (default to 'ad')

  • :smart_plus_ad_ids (String) —

    Comma-separated Smart+ ad ids to filter by (up to 100)

  • :ad_group_ids (String) —

    Comma-separated ad group ids to filter by (up to 100)

  • :page (Integer) — default: default to 1
  • :page_size (Integer) — default: default to 100

Returns:



558
559
560
561
# File 'lib/zernio-sdk/api/ad_insights_api.rb', line 558

def get_tik_tok_smart_plus_material_report(, , start_date, end_date, opts = {})
  data, _status_code, _headers = get_tik_tok_smart_plus_material_report_with_http_info(, , start_date, end_date, opts)
  data
end

#get_tik_tok_smart_plus_material_report_with_http_info(account_id, ad_account_id, start_date, end_date, opts = {}) ⇒ Array<(GetTikTokSmartPlusMaterialReport200Response, Integer, Hash)>

Per-creative performance inside TikTok Smart+ ads Breaks a Smart+ ad (or ad group) down by creative material, one row per Spark post, video or image, from TikTok's Smart+ material report. For a Spark post `tiktokItemId` is the TikTok post id. Conversion metrics are TikTok web (pixel) events. TikTok allows two dimensions per report, so rows are keyed by the Smart+ ad (`level=ad`) or by the ad group (`level=adGroup`), not both. Metrics TikTok returns empty come back as null.

Parameters:

  • account_id (String) —

    A tiktok or tiktokads account ID

  • ad_account_id (String) —

    TikTok advertiser ID

  • start_date (Date) —

    YYYY-MM-DD, in the advertiser's time zone

  • end_date (Date) —

    YYYY-MM-DD, on or after startDate

  • opts (Hash) (defaults to: {}) —

    the optional parameters

Options Hash (opts):

  • :level (String) —

    Key each row by Smart+ ad or by ad group (default to 'ad')

  • :smart_plus_ad_ids (String) —

    Comma-separated Smart+ ad ids to filter by (up to 100)

  • :ad_group_ids (String) —

    Comma-separated ad group ids to filter by (up to 100)

  • :page (Integer) — default: default to 1
  • :page_size (Integer) — default: default to 100

Returns:



576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
# File 'lib/zernio-sdk/api/ad_insights_api.rb', line 576

def get_tik_tok_smart_plus_material_report_with_http_info(, , start_date, end_date, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AdInsightsApi.get_tik_tok_smart_plus_material_report ...'
  end
  # verify the required parameter 'account_id' is set
  if @api_client.config.client_side_validation && .nil?
    fail ArgumentError, "Missing the required parameter 'account_id' when calling AdInsightsApi.get_tik_tok_smart_plus_material_report"
  end
  # verify the required parameter 'ad_account_id' is set
  if @api_client.config.client_side_validation && .nil?
    fail ArgumentError, "Missing the required parameter 'ad_account_id' when calling AdInsightsApi.get_tik_tok_smart_plus_material_report"
  end
  # verify the required parameter 'start_date' is set
  if @api_client.config.client_side_validation && start_date.nil?
    fail ArgumentError, "Missing the required parameter 'start_date' when calling AdInsightsApi.get_tik_tok_smart_plus_material_report"
  end
  # verify the required parameter 'end_date' is set
  if @api_client.config.client_side_validation && end_date.nil?
    fail ArgumentError, "Missing the required parameter 'end_date' when calling AdInsightsApi.get_tik_tok_smart_plus_material_report"
  end
  allowable_values = ["ad", "adGroup"]
  if @api_client.config.client_side_validation && opts[:'level'] && !allowable_values.include?(opts[:'level'])
    fail ArgumentError, "invalid value for \"level\", must be one of #{allowable_values}"
  end
  if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] < 1
    fail ArgumentError, 'invalid value for "opts[:"page"]" when calling AdInsightsApi.get_tik_tok_smart_plus_material_report, must be greater than or equal to 1.'
  end

  if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] > 1000
    fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling AdInsightsApi.get_tik_tok_smart_plus_material_report, must be smaller than or equal to 1000.'
  end

  if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] < 1
    fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling AdInsightsApi.get_tik_tok_smart_plus_material_report, must be greater than or equal to 1.'
  end

  # resource path
  local_var_path = '/v1/ads/tiktok-smart-plus-materials'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'accountId'] = 
  query_params[:'adAccountId'] = 
  query_params[:'startDate'] = start_date
  query_params[:'endDate'] = end_date
  query_params[:'level'] = opts[:'level'] if !opts[:'level'].nil?
  query_params[:'smartPlusAdIds'] = opts[:'smart_plus_ad_ids'] if !opts[:'smart_plus_ad_ids'].nil?
  query_params[:'adGroupIds'] = opts[:'ad_group_ids'] if !opts[:'ad_group_ids'].nil?
  query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
  query_params[:'pageSize'] = opts[:'page_size'] if !opts[:'page_size'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'GetTikTokSmartPlusMaterialReport200Response'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"AdInsightsApi.get_tik_tok_smart_plus_material_report",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: AdInsightsApi#get_tik_tok_smart_plus_material_report\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_local_services_lead_conversations(lead_id, account_id, opts = {}) ⇒ ListLocalServicesLeadConversations200Response

List lead conversations Conversation entries of one Local Services lead: phone calls (duration, recording URL) and messages (text, attachment URLs), oldest first. Read live from local_services_lead_conversation, always scoped to a single lead. Call-recording URLs require read access on the Google Ads account. Draws on the shared Google Ads operations budget.

Parameters:

  • lead_id (String) —

    Numeric lead id from /v1/ads/local-services/leads.

  • account_id (String) —

    Google ads SocialAccount id.

  • opts (Hash) (defaults to: {}) —

    the optional parameters

Options Hash (opts):

  • :ad_account_id (String) —

    Platform ad account ID (Google customer ID, digits only). Defaults to the account's connected customer.

  • :customer_id (String) —

    Alias of adAccountId, kept for existing callers

  • :page_token (String) —

    Cursor from paging.nextPageToken of the previous page.

Returns:



670
671
672
673
# File 'lib/zernio-sdk/api/ad_insights_api.rb', line 670

def list_local_services_lead_conversations(lead_id, , opts = {})
  data, _status_code, _headers = list_local_services_lead_conversations_with_http_info(lead_id, , opts)
  data
end

#list_local_services_lead_conversations_with_http_info(lead_id, account_id, opts = {}) ⇒ Array<(ListLocalServicesLeadConversations200Response, Integer, Hash)>

List lead conversations Conversation entries of one Local Services lead: phone calls (duration, recording URL) and messages (text, attachment URLs), oldest first. Read live from `local_services_lead_conversation`, always scoped to a single lead. Call-recording URLs require read access on the Google Ads account. Draws on the shared Google Ads operations budget.

Parameters:

  • lead_id (String) —

    Numeric lead id from /v1/ads/local-services/leads.

  • account_id (String) —

    Google ads SocialAccount id.

  • opts (Hash) (defaults to: {}) —

    the optional parameters

Options Hash (opts):

  • :ad_account_id (String) —

    Platform ad account ID (Google customer ID, digits only). Defaults to the account's connected customer.

  • :customer_id (String) —

    Alias of adAccountId, kept for existing callers

  • :page_token (String) —

    Cursor from paging.nextPageToken of the previous page.

Returns:



684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
# File 'lib/zernio-sdk/api/ad_insights_api.rb', line 684

def list_local_services_lead_conversations_with_http_info(lead_id, , opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AdInsightsApi.list_local_services_lead_conversations ...'
  end
  # verify the required parameter 'lead_id' is set
  if @api_client.config.client_side_validation && lead_id.nil?
    fail ArgumentError, "Missing the required parameter 'lead_id' when calling AdInsightsApi.list_local_services_lead_conversations"
  end
  # verify the required parameter 'account_id' is set
  if @api_client.config.client_side_validation && .nil?
    fail ArgumentError, "Missing the required parameter 'account_id' when calling AdInsightsApi.list_local_services_lead_conversations"
  end
  # resource path
  local_var_path = '/v1/ads/local-services/leads/{leadId}/conversations'.sub('{' + 'leadId' + '}', CGI.escape(lead_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'accountId'] = 
  query_params[:'adAccountId'] = opts[:'ad_account_id'] if !opts[:'ad_account_id'].nil?
  query_params[:'customerId'] = opts[:'customer_id'] if !opts[:'customer_id'].nil?
  query_params[:'pageToken'] = opts[:'page_token'] if !opts[:'page_token'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'ListLocalServicesLeadConversations200Response'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"AdInsightsApi.list_local_services_lead_conversations",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: AdInsightsApi#list_local_services_lead_conversations\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_local_services_leads(account_id, opts = {}) ⇒ ListLocalServicesLeads200Response

Google Local Services Ads leads Leads generated by Local Services Ads (phone calls, messages, bookings), read live from Google's local_services_lead resource, newest first. No persistence: Google is the source of truth and lead/credit statuses keep changing server-side. Google never returns healthcare-category leads, and WIPED_OUT leads arrive with contact erased (contact is null). Draws on the shared Google Ads operations budget.

Parameters:

  • account_id (String) —

    Google ads SocialAccount id.

  • opts (Hash) (defaults to: {}) —

    the optional parameters

Options Hash (opts):

  • :ad_account_id (String) —

    Platform ad account ID (Google customer ID, digits only). Defaults to the account's connected customer.

  • :customer_id (String) —

    Alias of adAccountId, kept for existing callers

  • :from_date (Date) —

    Leads created at/after this day.

  • :to_date (Date) —

    Leads created at/before this day.

  • :lead_type (String)
  • :lead_status (String) —

    Google LocalServicesLeadStatus enum value (e.g. NEW, BOOKED, WIPED_OUT).

  • :charged_only (Boolean) —

    true = only leads Google charged for.

  • :page_token (String) —

    Cursor from paging.nextPageToken of the previous page.

Returns:



753
754
755
756
# File 'lib/zernio-sdk/api/ad_insights_api.rb', line 753

def list_local_services_leads(, opts = {})
  data, _status_code, _headers = list_local_services_leads_with_http_info(, opts)
  data
end

#list_local_services_leads_with_http_info(account_id, opts = {}) ⇒ Array<(ListLocalServicesLeads200Response, Integer, Hash)>

Google Local Services Ads leads Leads generated by Local Services Ads (phone calls, messages, bookings), read live from Google's `local_services_lead` resource, newest first. No persistence: Google is the source of truth and lead/credit statuses keep changing server-side. Google never returns healthcare-category leads, and `WIPED_OUT` leads arrive with contact erased (`contact` is null). Draws on the shared Google Ads operations budget.

Parameters:

  • account_id (String) —

    Google ads SocialAccount id.

  • opts (Hash) (defaults to: {}) —

    the optional parameters

Options Hash (opts):

  • :ad_account_id (String) —

    Platform ad account ID (Google customer ID, digits only). Defaults to the account's connected customer.

  • :customer_id (String) —

    Alias of adAccountId, kept for existing callers

  • :from_date (Date) —

    Leads created at/after this day.

  • :to_date (Date) —

    Leads created at/before this day.

  • :lead_type (String)
  • :lead_status (String) —

    Google LocalServicesLeadStatus enum value (e.g. NEW, BOOKED, WIPED_OUT).

  • :charged_only (Boolean) —

    true = only leads Google charged for.

  • :page_token (String) —

    Cursor from paging.nextPageToken of the previous page.

Returns:



771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
# File 'lib/zernio-sdk/api/ad_insights_api.rb', line 771

def list_local_services_leads_with_http_info(, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AdInsightsApi.list_local_services_leads ...'
  end
  # verify the required parameter 'account_id' is set
  if @api_client.config.client_side_validation && .nil?
    fail ArgumentError, "Missing the required parameter 'account_id' when calling AdInsightsApi.list_local_services_leads"
  end
  allowable_values = ["PHONE_CALL", "MESSAGE", "BOOKING"]
  if @api_client.config.client_side_validation && opts[:'lead_type'] && !allowable_values.include?(opts[:'lead_type'])
    fail ArgumentError, "invalid value for \"lead_type\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/v1/ads/local-services/leads'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'accountId'] = 
  query_params[:'adAccountId'] = opts[:'ad_account_id'] if !opts[:'ad_account_id'].nil?
  query_params[:'customerId'] = opts[:'customer_id'] if !opts[:'customer_id'].nil?
  query_params[:'fromDate'] = opts[:'from_date'] if !opts[:'from_date'].nil?
  query_params[:'toDate'] = opts[:'to_date'] if !opts[:'to_date'].nil?
  query_params[:'leadType'] = opts[:'lead_type'] if !opts[:'lead_type'].nil?
  query_params[:'leadStatus'] = opts[:'lead_status'] if !opts[:'lead_status'].nil?
  query_params[:'chargedOnly'] = opts[:'charged_only'] if !opts[:'charged_only'].nil?
  query_params[:'pageToken'] = opts[:'page_token'] if !opts[:'page_token'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'ListLocalServicesLeads200Response'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"AdInsightsApi.list_local_services_leads",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: AdInsightsApi#list_local_services_leads\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#query_ad_insights(account_id, opts = {}) ⇒ QueryAdInsights200Response

Flexible live insights query Live, flexible insights query. The account's platform picks the contract: Meta (facebook/instagram): forwards caller-chosen fields, breakdowns and filtering to any Meta insights node and returns Meta's rows verbatim. objectId (required) selects the node; level sets row granularity. Semantic validation is Meta's: an unknown field or invalid breakdown combination returns a 400 carrying Meta's message. For long ranges or agency-scale accounts prefer the async variant (POST /v1/ads/insights/reports). Google Ads (googleads): raw GAQL passthrough. Send any read-only GAQL SELECT via query (campaign/keyword/search-term/geo/demographic/asset/shopping resources, change_event, any segments.*) and rows come back verbatim (camelCase, counters as strings). Results are paged at a fixed 10,000 rows; follow paging.nextPageToken with pageToken. adAccountId (alias customerId) is only needed when the connection has several Google Ads accounts. Semantic validation is Google's: an invalid query returns a 400 carrying Google's message (note: selecting segments.date requires a finite date filter). Queries run against Google Ads API v25, so write GAQL against the v25 field reference. One exception is translated for backward compatibility: the legacy campaign.start_date / campaign.end_date (removed by Google in v23) are rewritten to campaign.start_date_time / campaign.end_date_time, and rows still carry campaign.startDate / campaign.endDate as YYYY-MM-DD. In WHERE, =, <, <=, >, >=, BETWEEN and IS [NOT] NULL against a 'YYYY-MM-DD' literal are translated; any other form returns Google's 400. New code should select the _date_time fields directly.

Parameters:

  • account_id (String) —

    Zernio SocialAccount id (posting or ads variant); its platform selects the Meta or Google contract.

  • opts (Hash) (defaults to: {}) —

    the optional parameters

Options Hash (opts):

  • :object_id (String) —

    Meta only (required there): insights node (act_<n>, campaign id, ad set id or ad id).

  • :query (String) —

    Google only (required there): the GAQL SELECT statement to run.

  • :ad_account_id (String) —

    Google only: platform ad account ID (Google customer ID, digits only) when the connection has several Google Ads accounts.

  • :customer_id (String) —

    Alias of adAccountId, kept for existing callers

  • :page_token (String) —

    Google only: cursor from paging.nextPageToken of the previous page.

  • :level (String) —

    Row granularity

  • :fields (String) —

    Comma-separated Graph insights fields (e.g. spend,impressions,frequency,website_purchase_roas). Omitted = Meta's default set.

  • :breakdowns (String) —

    Comma-separated Graph breakdowns (e.g. age,gender or publisher_platform).

  • :action_breakdowns (String) —

    Comma-separated Graph action breakdowns; segments the actions arrays in each row. Pass `none` to clear Meta's default action_type breakdown, required to combine some non-action breakdowns such as instagram_ads_follow_type (otherwise Meta returns a (#100) invalid-combination error).

  • :action_attribution_windows (String) —

    Comma-separated Meta attribution windows. Action values are returned keyed per window.

  • :action_report_time (String) —

    When actions are counted: impression, conversion or mixed.

  • :use_unified_attribution_setting (Boolean) —

    Use the ad sets' own attribution settings for action counting.

  • :filtering (String) —

    JSON array of Meta filter objects: [\"operator\", \"value\"]. Applied server-side by Meta.

  • :date_preset (String) —

    Meta date_preset (e.g. last_7d, last_30d, this_month). Mutually exclusive with fromDate/toDate.

  • :from_date (Date) —

    Start of range (YYYY-MM-DD); requires toDate.

  • :to_date (Date) —

    End of range (YYYY-MM-DD); requires fromDate.

  • :time_increment (String) —

    Days per row (1-90), monthly, or all_days.

  • :limit (Integer) —

    Rows per page (default to 25)

  • :after (String) —

    Cursor from paging.after of the previous page.

Returns:



856
857
858
859
# File 'lib/zernio-sdk/api/ad_insights_api.rb', line 856

def query_ad_insights(, opts = {})
  data, _status_code, _headers = query_ad_insights_with_http_info(, opts)
  data
end

#query_ad_insights_with_http_info(account_id, opts = {}) ⇒ Array<(QueryAdInsights200Response, Integer, Hash)>

Flexible live insights query Live, flexible insights query. The account's platform picks the contract: Meta (facebook/instagram): forwards caller-chosen `fields`, `breakdowns` and `filtering` to any Meta insights node and returns Meta's rows verbatim. `objectId` (required) selects the node; `level` sets row granularity. Semantic validation is Meta's: an unknown field or invalid breakdown combination returns a 400 carrying Meta's message. For long ranges or agency-scale accounts prefer the async variant (POST /v1/ads/insights/reports). Google Ads (googleads): raw GAQL passthrough. Send any read-only GAQL SELECT via `query` (campaign/keyword/search-term/geo/demographic/asset/shopping resources, `change_event`, any `segments.*`) and rows come back verbatim (camelCase, counters as strings). Results are paged at a fixed 10,000 rows; follow `paging.nextPageToken` with `pageToken`. `adAccountId` (alias `customerId`) is only needed when the connection has several Google Ads accounts. Semantic validation is Google's: an invalid query returns a 400 carrying Google's message (note: selecting `segments.date` requires a finite date filter). Queries run against Google Ads API v25, so write GAQL against the v25 field reference. One exception is translated for backward compatibility: the legacy `campaign.start_date` / `campaign.end_date` (removed by Google in v23) are rewritten to `campaign.start_date_time` / `campaign.end_date_time`, and rows still carry `campaign.startDate` / `campaign.endDate` as `YYYY-MM-DD`. In WHERE, `=`, `<`, `<=`, `>`, `>=`, `BETWEEN` and `IS [NOT] NULL` against a `'YYYY-MM-DD'` literal are translated; any other form returns Google's 400. New code should select the `_date_time` fields directly.

Parameters:

  • account_id (String) —

    Zernio SocialAccount id (posting or ads variant); its platform selects the Meta or Google contract.

  • opts (Hash) (defaults to: {}) —

    the optional parameters

Options Hash (opts):

  • :object_id (String) —

    Meta only (required there): insights node (act_<n>, campaign id, ad set id or ad id).

  • :query (String) —

    Google only (required there): the GAQL SELECT statement to run.

  • :ad_account_id (String) —

    Google only: platform ad account ID (Google customer ID, digits only) when the connection has several Google Ads accounts.

  • :customer_id (String) —

    Alias of adAccountId, kept for existing callers

  • :page_token (String) —

    Google only: cursor from paging.nextPageToken of the previous page.

  • :level (String) —

    Row granularity

  • :fields (String) —

    Comma-separated Graph insights fields (e.g. spend,impressions,frequency,website_purchase_roas). Omitted = Meta's default set.

  • :breakdowns (String) —

    Comma-separated Graph breakdowns (e.g. age,gender or publisher_platform).

  • :action_breakdowns (String) —

    Comma-separated Graph action breakdowns; segments the actions arrays in each row. Pass `none` to clear Meta's default action_type breakdown, required to combine some non-action breakdowns such as instagram_ads_follow_type (otherwise Meta returns a (#100) invalid-combination error).

  • :action_attribution_windows (String) —

    Comma-separated Meta attribution windows. Action values are returned keyed per window.

  • :action_report_time (String) —

    When actions are counted: impression, conversion or mixed.

  • :use_unified_attribution_setting (Boolean) —

    Use the ad sets' own attribution settings for action counting.

  • :filtering (String) —

    JSON array of Meta filter objects: [\"operator\", \"value\"]. Applied server-side by Meta.

  • :date_preset (String) —

    Meta date_preset (e.g. last_7d, last_30d, this_month). Mutually exclusive with fromDate/toDate.

  • :from_date (Date) —

    Start of range (YYYY-MM-DD); requires toDate.

  • :to_date (Date) —

    End of range (YYYY-MM-DD); requires fromDate.

  • :time_increment (String) —

    Days per row (1-90), monthly, or all_days.

  • :limit (Integer) —

    Rows per page (default to 25)

  • :after (String) —

    Cursor from paging.after of the previous page.

Returns:

  • (Array<(QueryAdInsights200Response, Integer, Hash)>) —

    QueryAdInsights200Response data, response status code and response headers



885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
# File 'lib/zernio-sdk/api/ad_insights_api.rb', line 885

def query_ad_insights_with_http_info(, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AdInsightsApi.query_ad_insights ...'
  end
  # verify the required parameter 'account_id' is set
  if @api_client.config.client_side_validation && .nil?
    fail ArgumentError, "Missing the required parameter 'account_id' when calling AdInsightsApi.query_ad_insights"
  end
  if @api_client.config.client_side_validation && !opts[:'query'].nil? && opts[:'query'].to_s.length > 10000
    fail ArgumentError, 'invalid value for "opts[:"query"]" when calling AdInsightsApi.query_ad_insights, the character length must be smaller than or equal to 10000.'
  end

  allowable_values = ["ad", "adset", "campaign", "account"]
  if @api_client.config.client_side_validation && opts[:'level'] && !allowable_values.include?(opts[:'level'])
    fail ArgumentError, "invalid value for \"level\", must be one of #{allowable_values}"
  end
  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 500
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling AdInsightsApi.query_ad_insights, must be smaller than or equal to 500.'
  end

  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling AdInsightsApi.query_ad_insights, must be greater than or equal to 1.'
  end

  # resource path
  local_var_path = '/v1/ads/insights'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'accountId'] = 
  query_params[:'objectId'] = opts[:'object_id'] if !opts[:'object_id'].nil?
  query_params[:'query'] = opts[:'query'] if !opts[:'query'].nil?
  query_params[:'adAccountId'] = opts[:'ad_account_id'] if !opts[:'ad_account_id'].nil?
  query_params[:'customerId'] = opts[:'customer_id'] if !opts[:'customer_id'].nil?
  query_params[:'pageToken'] = opts[:'page_token'] if !opts[:'page_token'].nil?
  query_params[:'level'] = opts[:'level'] if !opts[:'level'].nil?
  query_params[:'fields'] = opts[:'fields'] if !opts[:'fields'].nil?
  query_params[:'breakdowns'] = opts[:'breakdowns'] if !opts[:'breakdowns'].nil?
  query_params[:'actionBreakdowns'] = opts[:'action_breakdowns'] if !opts[:'action_breakdowns'].nil?
  query_params[:'actionAttributionWindows'] = opts[:'action_attribution_windows'] if !opts[:'action_attribution_windows'].nil?
  query_params[:'actionReportTime'] = opts[:'action_report_time'] if !opts[:'action_report_time'].nil?
  query_params[:'useUnifiedAttributionSetting'] = opts[:'use_unified_attribution_setting'] if !opts[:'use_unified_attribution_setting'].nil?
  query_params[:'filtering'] = opts[:'filtering'] if !opts[:'filtering'].nil?
  query_params[:'datePreset'] = opts[:'date_preset'] if !opts[:'date_preset'].nil?
  query_params[:'fromDate'] = opts[:'from_date'] if !opts[:'from_date'].nil?
  query_params[:'toDate'] = opts[:'to_date'] if !opts[:'to_date'].nil?
  query_params[:'timeIncrement'] = opts[:'time_increment'] if !opts[:'time_increment'].nil?
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'after'] = opts[:'after'] if !opts[:'after'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'QueryAdInsights200Response'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"AdInsightsApi.query_ad_insights",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: AdInsightsApi#query_ad_insights\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end