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_clientObject

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 an async insights report run 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 an async insights report run 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

Historical keyword metrics (Google Keyword Planner) 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)>

Historical keyword metrics (Google Keyword Planner) 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 Keyword Planner) 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 Keyword Planner) 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 = {}) ⇒ GetAdAnalytics200Response

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<(GetAdAnalytics200Response, 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<(GetAdAnalytics200Response, Integer, Hash)>)

    GetAdAnalytics200Response 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] || 'GetAdAnalytics200Response'

  # 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_campaign_analytics(campaign_id, opts = {}) ⇒ GetCampaignAnalytics200Response

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.

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:



391
392
393
394
# File 'lib/zernio-sdk/api/ad_insights_api.rb', line 391

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<(GetCampaignAnalytics200Response, 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.

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:



405
406
407
408
409
410
411
412
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
# File 'lib/zernio-sdk/api/ad_insights_api.rb', line 405

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] || 'GetCampaignAnalytics200Response'

  # 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

#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. 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).

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.

  • :customer_id (String)

    Google only: numeric customer id (no dashes) when the connection has several Google Ads accounts.

  • :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.

  • :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:



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

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`. `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).

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.

  • :customer_id (String)

    Google only: numeric customer id (no dashes) when the connection has several Google Ads accounts.

  • :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.

  • :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



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
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
# File 'lib/zernio-sdk/api/ad_insights_api.rb', line 508

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[:'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