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

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



98
99
100
101
# File 'lib/zernio-sdk/api/ad_insights_api.rb', line 98

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



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
157
158
159
160
# File 'lib/zernio-sdk/api/ad_insights_api.rb', line 111

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:



170
171
172
173
# File 'lib/zernio-sdk/api/ad_insights_api.rb', line 170

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:



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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
# File 'lib/zernio-sdk/api/ad_insights_api.rb', line 183

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:



255
256
257
258
# File 'lib/zernio-sdk/api/ad_insights_api.rb', line 255

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:



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
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
# File 'lib/zernio-sdk/api/ad_insights_api.rb', line 269

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, object_id, opts = {}) ⇒ QueryAdInsights200Response

Flexible live insights query Live, flexible insights query against Meta's Graph API. Unlike GET /v1/ads/adId/analytics (fixed metric set, cached), this forwards caller-chosen fields, breakdowns and filtering to any Meta insights node and returns Meta's rows verbatim. objectId selects the node: an ad account, campaign, ad set or ad platform id. level sets row granularity independently of the node. 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).

Parameters:

  • account_id (String)

    Zernio SocialAccount id (posting or ads variant) used to resolve the Meta token.

  • object_id (String)

    Meta insights node: act_<n>, campaign id, ad set id or ad id.

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

    the optional parameters

Options Hash (opts):

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



341
342
343
344
# File 'lib/zernio-sdk/api/ad_insights_api.rb', line 341

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

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

Flexible live insights query Live, flexible insights query against Meta's Graph API. Unlike GET /v1/ads/adId/analytics (fixed metric set, cached), this forwards caller-chosen `fields`, `breakdowns` and `filtering` to any Meta insights node and returns Meta's rows verbatim. `objectId` selects the node: an ad account, campaign, ad set or ad platform id. `level` sets row granularity independently of the node. 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).

Parameters:

  • account_id (String)

    Zernio SocialAccount id (posting or ads variant) used to resolve the Meta token.

  • object_id (String)

    Meta insights node: act_<n>, campaign id, ad set id or ad id.

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

    the optional parameters

Options Hash (opts):

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



366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
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
# File 'lib/zernio-sdk/api/ad_insights_api.rb', line 366

def query_ad_insights_with_http_info(, object_id, 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
  # verify the required parameter 'object_id' is set
  if @api_client.config.client_side_validation && object_id.nil?
    fail ArgumentError, "Missing the required parameter 'object_id' when calling AdInsightsApi.query_ad_insights"
  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'] = object_id
  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