Class: Zernio::AdCampaignsApi

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ AdCampaignsApi

Returns a new instance of AdCampaignsApi.



19
20
21
# File 'lib/zernio-sdk/api/ad_campaigns_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_campaigns_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#boost_post(boost_post_request, opts = {}) ⇒ UpdateAd200Response

Boost post as ad Creates a paid ad campaign from an existing published post. Creates the full platform campaign hierarchy (campaign, ad set, ad).

Parameters:

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

    the optional parameters

Returns:



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

def boost_post(boost_post_request, opts = {})
  data, _status_code, _headers = boost_post_with_http_info(boost_post_request, opts)
  data
end

#boost_post_with_http_info(boost_post_request, opts = {}) ⇒ Array<(UpdateAd200Response, Integer, Hash)>

Boost post as ad Creates a paid ad campaign from an existing published post. Creates the full platform campaign hierarchy (campaign, ad set, ad).

Parameters:

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

    the optional parameters

Returns:

  • (Array<(UpdateAd200Response, Integer, Hash)>)

    UpdateAd200Response data, response status code and response headers



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_campaigns_api.rb', line 37

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

  # 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(boost_post_request)

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

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

  new_options = opts.merge(
    :operation => :"AdCampaignsApi.boost_post",
    :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: AdCampaignsApi#boost_post\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#bulk_update_ad_campaign_status(bulk_update_ad_campaign_status_request, opts = {}) ⇒ BulkUpdateAdCampaignStatus200Response

Pause or resume many campaigns Process up to 50 campaigns in one call. Each campaign is updated concurrently and the response contains a per-campaign result so a single bad row does not fail the whole batch.

Parameters:

Returns:



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

def bulk_update_ad_campaign_status(bulk_update_ad_campaign_status_request, opts = {})
  data, _status_code, _headers = bulk_update_ad_campaign_status_with_http_info(bulk_update_ad_campaign_status_request, opts)
  data
end

#bulk_update_ad_campaign_status_with_http_info(bulk_update_ad_campaign_status_request, opts = {}) ⇒ Array<(BulkUpdateAdCampaignStatus200Response, Integer, Hash)>

Pause or resume many campaigns Process up to 50 campaigns in one call. Each campaign is updated concurrently and the response contains a per-campaign result so a single bad row does not fail the whole batch.

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_campaigns_api.rb', line 105

def bulk_update_ad_campaign_status_with_http_info(bulk_update_ad_campaign_status_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AdCampaignsApi.bulk_update_ad_campaign_status ...'
  end
  # verify the required parameter 'bulk_update_ad_campaign_status_request' is set
  if @api_client.config.client_side_validation && bulk_update_ad_campaign_status_request.nil?
    fail ArgumentError, "Missing the required parameter 'bulk_update_ad_campaign_status_request' when calling AdCampaignsApi.bulk_update_ad_campaign_status"
  end
  # resource path
  local_var_path = '/v1/ads/campaigns/bulk-status'

  # 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(bulk_update_ad_campaign_status_request)

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

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

  new_options = opts.merge(
    :operation => :"AdCampaignsApi.bulk_update_ad_campaign_status",
    :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: AdCampaignsApi#bulk_update_ad_campaign_status\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#create_ad_campaign(create_ad_campaign_request, opts = {}) ⇒ CreateAdCampaign201Response

Create a standalone campaign Creates a campaign WITHOUT its first ad set / ad (the ODAX shell only). Ad sets join it later via existingCampaignId on the create endpoints. A budget here is campaign-level (CBO) by definition; omit it for ABO (each ad set carries its own budget). Created PAUSED unless status: ACTIVE. The campaign materializes in /v1/ads/tree via the next sync discovery pass.

Parameters:

Returns:



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

def create_ad_campaign(create_ad_campaign_request, opts = {})
  data, _status_code, _headers = create_ad_campaign_with_http_info(create_ad_campaign_request, opts)
  data
end

#create_ad_campaign_with_http_info(create_ad_campaign_request, opts = {}) ⇒ Array<(CreateAdCampaign201Response, Integer, Hash)>

Create a standalone campaign Creates a campaign WITHOUT its first ad set / ad (the ODAX shell only). Ad sets join it later via `existingCampaignId` on the create endpoints. A budget here is campaign-level (CBO) by definition; omit it for ABO (each ad set carries its own budget). Created `PAUSED` unless `status: ACTIVE`. The campaign materializes in `/v1/ads/tree` via the next sync discovery pass.

Parameters:

Returns:

  • (Array<(CreateAdCampaign201Response, Integer, Hash)>)

    CreateAdCampaign201Response data, response status code and response headers



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_campaigns_api.rb', line 173

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

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

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

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

  new_options = opts.merge(
    :operation => :"AdCampaignsApi.create_ad_campaign",
    :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: AdCampaignsApi#create_ad_campaign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#create_standalone_ad(create_standalone_ad_request, opts = {}) ⇒ CreateStandaloneAd200Response

Create standalone ad Creates a paid ad with custom creative across Meta, Google Ads, Pinterest, TikTok, X/Twitter, LinkedIn, and OpenAI Ads (ChatGPT Ads). Supports three mutually-exclusive request shapes selected by the body, a legacy single-creative shape (all platforms, default), a Meta-only multi-creative shape via the creatives array (one ad set with N ads sharing budget and targeting), and a Meta-only attach shape via adSetId (adds one new ad to an existing ad set). Per-platform required fields, budget minimums, and video-ad rules are documented on each property below. LinkedIn creates a Single Image or Single Video Ad backed by a Direct Sponsored Content "dark post" authored by a Company Page (see organizationId); supported goals are engagement, traffic, awareness, and video_views (video ads use the video field; video_views requires a video), and traffic ads require linkUrl. Idempotency: this endpoint is not idempotent at the platform level (a blind retry creates a second campaign/ad set/ad). Send an Idempotency-Key header to make retries safe: the first request with a given key creates the ad and we store the response; a retry with the same key replays that exact response (with Idempotent-Replayed: true) instead of creating duplicates. Reusing a key with a different body returns 422; a key whose first request is still in flight returns 409 (retry after a short backoff). Keys are scoped to your credential and expire after 24h.

Parameters:

Options Hash (opts):

  • :idempotency_key (String)

    Optional client-generated unique key (e.g. a UUID) that makes create retries safe. Same key + same body replays the original response; same key + different body → 422; key still processing → 409.

Returns:



232
233
234
235
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 232

def create_standalone_ad(create_standalone_ad_request, opts = {})
  data, _status_code, _headers = create_standalone_ad_with_http_info(create_standalone_ad_request, opts)
  data
end

#create_standalone_ad_with_http_info(create_standalone_ad_request, opts = {}) ⇒ Array<(CreateStandaloneAd200Response, Integer, Hash)>

Create standalone ad Creates a paid ad with custom creative across Meta, Google Ads, Pinterest, TikTok, X/Twitter, LinkedIn, and OpenAI Ads (ChatGPT Ads). Supports three mutually-exclusive request shapes selected by the body, a legacy single-creative shape (all platforms, default), a Meta-only multi-creative shape via the creatives array (one ad set with N ads sharing budget and targeting), and a Meta-only attach shape via adSetId (adds one new ad to an existing ad set). Per-platform required fields, budget minimums, and video-ad rules are documented on each property below. LinkedIn creates a Single Image or Single Video Ad backed by a Direct Sponsored Content &quot;dark post&quot; authored by a Company Page (see `organizationId`); supported goals are engagement, traffic, awareness, and video_views (video ads use the `video` field; video_views requires a video), and traffic ads require `linkUrl`. Idempotency: this endpoint is not idempotent at the platform level (a blind retry creates a second campaign/ad set/ad). Send an `Idempotency-Key` header to make retries safe: the first request with a given key creates the ad and we store the response; a retry with the same key replays that exact response (with `Idempotent-Replayed: true`) instead of creating duplicates. Reusing a key with a different body returns 422; a key whose first request is still in flight returns 409 (retry after a short backoff). Keys are scoped to your credential and expire after 24h.

Parameters:

Options Hash (opts):

  • :idempotency_key (String)

    Optional client-generated unique key (e.g. a UUID) that makes create retries safe. Same key + same body replays the original response; same key + different body → 422; key still processing → 409.

Returns:



243
244
245
246
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
297
298
299
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 243

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

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

  # 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
  header_params[:'Idempotency-Key'] = opts[:'idempotency_key'] if !opts[:'idempotency_key'].nil?

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

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

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

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

  new_options = opts.merge(
    :operation => :"AdCampaignsApi.create_standalone_ad",
    :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: AdCampaignsApi#create_standalone_ad\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#delete_ad(ad_id, opts = {}) ⇒ DeleteAccountGroup200Response

Cancel an ad Cancels the ad on the platform and marks it as cancelled in the database. The ad is preserved for history. OpenAI Ads has no delete API; the ad is archived instead (a terminal state, the closest equivalent).

Parameters:

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

    the optional parameters

Returns:



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

def delete_ad(ad_id, opts = {})
  data, _status_code, _headers = delete_ad_with_http_info(ad_id, opts)
  data
end

#delete_ad_campaign(campaign_id, delete_ad_campaign_request, opts = {}) ⇒ DeleteAdCampaign200Response

Delete a campaign Deletes the whole campaign on the platform, cascading to its ad sets and ads. Locally, all Ad documents for this campaign are marked status: cancelled. Meta-only for now. Other platforms return 501 Not Implemented — fall back to DELETE /v1/ads/adId per ad in the meantime.

Parameters:

  • campaign_id (String)

    Platform campaign ID

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

    the optional parameters

Returns:



370
371
372
373
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 370

def delete_ad_campaign(campaign_id, delete_ad_campaign_request, opts = {})
  data, _status_code, _headers = delete_ad_campaign_with_http_info(campaign_id, delete_ad_campaign_request, opts)
  data
end

#delete_ad_campaign_with_http_info(campaign_id, delete_ad_campaign_request, opts = {}) ⇒ Array<(DeleteAdCampaign200Response, Integer, Hash)>

Delete a campaign Deletes the whole campaign on the platform, cascading to its ad sets and ads. Locally, all Ad documents for this campaign are marked `status: cancelled`. Meta-only for now. Other platforms return 501 Not Implemented — fall back to DELETE /v1/ads/adId per ad in the meantime.

Parameters:

  • campaign_id (String)

    Platform campaign ID

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

    the optional parameters

Returns:

  • (Array<(DeleteAdCampaign200Response, Integer, Hash)>)

    DeleteAdCampaign200Response data, response status code and response headers



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
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 381

def delete_ad_campaign_with_http_info(campaign_id, delete_ad_campaign_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AdCampaignsApi.delete_ad_campaign ...'
  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 AdCampaignsApi.delete_ad_campaign"
  end
  # verify the required parameter 'delete_ad_campaign_request' is set
  if @api_client.config.client_side_validation && delete_ad_campaign_request.nil?
    fail ArgumentError, "Missing the required parameter 'delete_ad_campaign_request' when calling AdCampaignsApi.delete_ad_campaign"
  end
  # resource path
  local_var_path = '/v1/ads/campaigns/{campaignId}'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_id.to_s))

  # 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(delete_ad_campaign_request)

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

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

  new_options = opts.merge(
    :operation => :"AdCampaignsApi.delete_ad_campaign",
    :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(:DELETE, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: AdCampaignsApi#delete_ad_campaign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#delete_ad_with_http_info(ad_id, opts = {}) ⇒ Array<(DeleteAccountGroup200Response, Integer, Hash)>

Cancel an ad Cancels the ad on the platform and marks it as cancelled in the database. The ad is preserved for history. OpenAI Ads has no delete API; the ad is archived instead (a terminal state, the closest equivalent).

Parameters:

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

    the optional parameters

Returns:



316
317
318
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
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 316

def delete_ad_with_http_info(ad_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AdCampaignsApi.delete_ad ...'
  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 AdCampaignsApi.delete_ad"
  end
  # resource path
  local_var_path = '/v1/ads/{adId}'.sub('{' + 'adId' + '}', CGI.escape(ad_id.to_s))

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

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

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

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

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

  new_options = opts.merge(
    :operation => :"AdCampaignsApi.delete_ad",
    :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(:DELETE, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: AdCampaignsApi#delete_ad\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#duplicate_ad(ad_id, opts = {}) ⇒ DuplicateAd200Response

Duplicate an ad Duplicates a single ad via Meta's native POST /{ad-id}/copies. The copy is created paused. adSetId retargets the copy into another ad set; omitted = the source's own ad set. Accepts the Zernio ad id or the platform ad id. Sync discovery is triggered automatically (syncAfter: false to skip).

Parameters:

  • ad_id (String)

    Zernio ad ID or platform ad ID

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

    the optional parameters

Options Hash (opts):

Returns:



444
445
446
447
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 444

def duplicate_ad(ad_id, opts = {})
  data, _status_code, _headers = duplicate_ad_with_http_info(ad_id, opts)
  data
end

#duplicate_ad_campaign(campaign_id, duplicate_ad_campaign_request, opts = {}) ⇒ DuplicateAdCampaign200Response

Duplicate a campaign Duplicates a campaign, including its ad sets, ads, creatives, and targeting by default (deepCopy: true). The copy is created paused so callers can review before launching. Per-platform implementation: - Meta uses the native POST /{campaign-id}/copies endpoint. - TikTok has no native copy primitive; Zernio walks the source graph (/v2/campaign/get/, /v2/adgroup/get/, /v2/ad/get/) and recreates each entity via the corresponding /create/ endpoints, carrying over budget / targeting / bid_type / bid_price / deep_bid_type / creative fields. Spark Ad linkage (tiktok_item_id) is preserved. - LinkedIn has no native copy primitive; Zernio walks the source CampaignGroup → Campaigns → Creatives and recreates each entity, carrying over type / costType / unitCost / optimizationTargetType / creativeSelection / objectiveType / format / dailyBudget / totalBudget / targetingCriteria / runSchedule and every Creative's content object verbatim. statusOption: INHERITED_FROM_SOURCE is evaluated per entity: any Group / Campaign / Creative whose source is ACTIVE gets its clone activated too. Duplicating an ACTIVE campaign with INHERITED_FROM_SOURCE starts a second front of spend the moment the clone activates — the safe default is PAUSED. The new hierarchy is asynchronous to materialize in our DB — we trigger sync discovery automatically. Set syncAfter: false to skip and poll /v1/ads/tree on your own cadence. Other platforms return 501 Not Implemented.

Parameters:

  • campaign_id (String)

    Source platform campaign ID

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

    the optional parameters

Returns:



514
515
516
517
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 514

def duplicate_ad_campaign(campaign_id, duplicate_ad_campaign_request, opts = {})
  data, _status_code, _headers = duplicate_ad_campaign_with_http_info(campaign_id, duplicate_ad_campaign_request, opts)
  data
end

#duplicate_ad_campaign_with_http_info(campaign_id, duplicate_ad_campaign_request, opts = {}) ⇒ Array<(DuplicateAdCampaign200Response, Integer, Hash)>

Duplicate a campaign Duplicates a campaign, including its ad sets, ads, creatives, and targeting by default (`deepCopy: true`). The copy is created paused so callers can review before launching. Per-platform implementation: - Meta uses the native `POST /campaign-id/copies` endpoint. - TikTok has no native copy primitive; Zernio walks the source graph (`/v2/campaign/get/`, `/v2/adgroup/get/`, `/v2/ad/get/`) and recreates each entity via the corresponding `/create/` endpoints, carrying over budget / targeting / bid_type / bid_price / deep_bid_type / creative fields. Spark Ad linkage (`tiktok_item_id`) is preserved. - LinkedIn has no native copy primitive; Zernio walks the source CampaignGroup → Campaigns → Creatives and recreates each entity, carrying over `type` / `costType` / `unitCost` / `optimizationTargetType` / `creativeSelection` / `objectiveType` / `format` / `dailyBudget` / `totalBudget` / `targetingCriteria` / `runSchedule` and every Creative's `content` object verbatim. `statusOption: INHERITED_FROM_SOURCE` is evaluated per entity: any Group / Campaign / Creative whose source is `ACTIVE` gets its clone activated too. Duplicating an ACTIVE campaign with `INHERITED_FROM_SOURCE` starts a second front of spend the moment the clone activates — the safe default is `PAUSED`. The new hierarchy is asynchronous to materialize in our DB — we trigger sync discovery automatically. Set `syncAfter: false` to skip and poll `/v1/ads/tree` on your own cadence. Other platforms return 501 Not Implemented.

Parameters:

  • campaign_id (String)

    Source platform campaign ID

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

    the optional parameters

Returns:



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
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 525

def duplicate_ad_campaign_with_http_info(campaign_id, duplicate_ad_campaign_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AdCampaignsApi.duplicate_ad_campaign ...'
  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 AdCampaignsApi.duplicate_ad_campaign"
  end
  # verify the required parameter 'duplicate_ad_campaign_request' is set
  if @api_client.config.client_side_validation && duplicate_ad_campaign_request.nil?
    fail ArgumentError, "Missing the required parameter 'duplicate_ad_campaign_request' when calling AdCampaignsApi.duplicate_ad_campaign"
  end
  # resource path
  local_var_path = '/v1/ads/campaigns/{campaignId}/duplicate'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_id.to_s))

  # 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(duplicate_ad_campaign_request)

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

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

  new_options = opts.merge(
    :operation => :"AdCampaignsApi.duplicate_ad_campaign",
    :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: AdCampaignsApi#duplicate_ad_campaign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#duplicate_ad_set(ad_set_id, duplicate_ad_set_request, opts = {}) ⇒ DuplicateAdSet200Response

Duplicate an ad set Duplicates an ad set, including its ads and creatives by default (deepCopy: true), via Meta's native POST /{adset-id}/copies. The copy is created paused so callers can review before launching. campaignId retargets the copy into another campaign; omitted = the source's own campaign. The new hierarchy materializes asynchronously — sync discovery is triggered automatically (syncAfter: false to skip).

Parameters:

  • ad_set_id (String)

    Source platform ad set ID

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

    the optional parameters

Returns:



588
589
590
591
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 588

def duplicate_ad_set(ad_set_id, duplicate_ad_set_request, opts = {})
  data, _status_code, _headers = duplicate_ad_set_with_http_info(ad_set_id, duplicate_ad_set_request, opts)
  data
end

#duplicate_ad_set_with_http_info(ad_set_id, duplicate_ad_set_request, opts = {}) ⇒ Array<(DuplicateAdSet200Response, Integer, Hash)>

Duplicate an ad set Duplicates an ad set, including its ads and creatives by default (`deepCopy: true`), via Meta's native `POST /adset-id/copies`. The copy is created paused so callers can review before launching. `campaignId` retargets the copy into another campaign; omitted = the source's own campaign. The new hierarchy materializes asynchronously — sync discovery is triggered automatically (`syncAfter: false` to skip).

Parameters:

  • ad_set_id (String)

    Source platform ad set ID

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

    the optional parameters

Returns:

  • (Array<(DuplicateAdSet200Response, Integer, Hash)>)

    DuplicateAdSet200Response data, response status code and response headers



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
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 599

def duplicate_ad_set_with_http_info(ad_set_id, duplicate_ad_set_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AdCampaignsApi.duplicate_ad_set ...'
  end
  # verify the required parameter 'ad_set_id' is set
  if @api_client.config.client_side_validation && ad_set_id.nil?
    fail ArgumentError, "Missing the required parameter 'ad_set_id' when calling AdCampaignsApi.duplicate_ad_set"
  end
  # verify the required parameter 'duplicate_ad_set_request' is set
  if @api_client.config.client_side_validation && duplicate_ad_set_request.nil?
    fail ArgumentError, "Missing the required parameter 'duplicate_ad_set_request' when calling AdCampaignsApi.duplicate_ad_set"
  end
  # resource path
  local_var_path = '/v1/ads/ad-sets/{adSetId}/duplicate'.sub('{' + 'adSetId' + '}', CGI.escape(ad_set_id.to_s))

  # 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(duplicate_ad_set_request)

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

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

  new_options = opts.merge(
    :operation => :"AdCampaignsApi.duplicate_ad_set",
    :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: AdCampaignsApi#duplicate_ad_set\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#duplicate_ad_with_http_info(ad_id, opts = {}) ⇒ Array<(DuplicateAd200Response, Integer, Hash)>

Duplicate an ad Duplicates a single ad via Meta's native `POST /ad-id/copies`. The copy is created paused. `adSetId` retargets the copy into another ad set; omitted = the source's own ad set. Accepts the Zernio ad id or the platform ad id. Sync discovery is triggered automatically (`syncAfter: false` to skip).

Parameters:

  • ad_id (String)

    Zernio ad ID or platform ad ID

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

    the optional parameters

Options Hash (opts):

Returns:

  • (Array<(DuplicateAd200Response, Integer, Hash)>)

    DuplicateAd200Response data, response status code and response headers



455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 455

def duplicate_ad_with_http_info(ad_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AdCampaignsApi.duplicate_ad ...'
  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 AdCampaignsApi.duplicate_ad"
  end
  # resource path
  local_var_path = '/v1/ads/{adId}/duplicate'.sub('{' + 'adId' + '}', CGI.escape(ad_id.to_s))

  # 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(opts[:'duplicate_ad_request'])

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

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

  new_options = opts.merge(
    :operation => :"AdCampaignsApi.duplicate_ad",
    :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: AdCampaignsApi#duplicate_ad\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_ad(ad_id, opts = {}) ⇒ GetAd200Response

Get ad details Returns an ad with its creative, targeting, status, and performance metrics. The {adId} path segment accepts any identifier dialect Zernio indexes for the ad: - the Zernio internal _id (24-char hex) - Meta's numeric platformAdId (the value shipped in comment.received webhooks as comment.ad.id) - the creative's effective_object_story_id ({pageId}_{postId} shape, Facebook side) - the creative's effective_instagram_media_id (Instagram side) Any of the four resolve to the same ad. Caller doesn't need a translation step.

Parameters:

  • ad_id (String)

    Zernio `_id` (hex), Meta `platformAdId` (numeric), or one of the creative's effective story/media IDs. See description for details.

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

    the optional parameters

Returns:



661
662
663
664
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 661

def get_ad(ad_id, opts = {})
  data, _status_code, _headers = get_ad_with_http_info(ad_id, opts)
  data
end

#get_ad_set_details(ad_set_id, account_id, opts = {}) ⇒ GetAdSetDetails200Response

Live ad-set details incl. learning phase Reads the ad set live from Meta, returned verbatim. The default projection includes learning_stage_info (learning-phase status: LEARNING / SUCCESS / FAIL / WAIVING — Meta omits its status key on paused ad sets), delivery settings, budgets, schedule and targeting. fields is a raw-passthrough override; unknown fields return Meta's 400 verbatim.

Parameters:

  • ad_set_id (String)

    Meta ad set id (platformAdSetId).

  • account_id (String)

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

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

    the optional parameters

Options Hash (opts):

  • :fields (String)

    Comma-separated Graph field override (supports nested {} projections).

Returns:



726
727
728
729
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 726

def get_ad_set_details(ad_set_id, , opts = {})
  data, _status_code, _headers = get_ad_set_details_with_http_info(ad_set_id, , opts)
  data
end

#get_ad_set_details_with_http_info(ad_set_id, account_id, opts = {}) ⇒ Array<(GetAdSetDetails200Response, Integer, Hash)>

Live ad-set details incl. learning phase Reads the ad set live from Meta, returned verbatim. The default projection includes `learning_stage_info` (learning-phase status: LEARNING / SUCCESS / FAIL / WAIVING — Meta omits its `status` key on paused ad sets), delivery settings, budgets, schedule and targeting. `fields` is a raw-passthrough override; unknown fields return Meta's 400 verbatim.

Parameters:

  • ad_set_id (String)

    Meta ad set id (platformAdSetId).

  • account_id (String)

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

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

    the optional parameters

Options Hash (opts):

  • :fields (String)

    Comma-separated Graph field override (supports nested {} projections).

Returns:

  • (Array<(GetAdSetDetails200Response, Integer, Hash)>)

    GetAdSetDetails200Response data, response status code and response headers



738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 738

def get_ad_set_details_with_http_info(ad_set_id, , opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AdCampaignsApi.get_ad_set_details ...'
  end
  # verify the required parameter 'ad_set_id' is set
  if @api_client.config.client_side_validation && ad_set_id.nil?
    fail ArgumentError, "Missing the required parameter 'ad_set_id' when calling AdCampaignsApi.get_ad_set_details"
  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 AdCampaignsApi.get_ad_set_details"
  end
  # resource path
  local_var_path = '/v1/ads/ad-sets/{adSetId}'.sub('{' + 'adSetId' + '}', CGI.escape(ad_set_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'accountId'] = 
  query_params[:'fields'] = opts[:'fields'] if !opts[:'fields'].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] || 'GetAdSetDetails200Response'

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

  new_options = opts.merge(
    :operation => :"AdCampaignsApi.get_ad_set_details",
    :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: AdCampaignsApi#get_ad_set_details\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_ad_tree(opts = {}) ⇒ GetAdTree200Response

Get campaign tree Returns a nested Campaign > Ad Set > Ad hierarchy with rolled-up metrics at each level. Uses a two-stage aggregation: ads are grouped into ad sets, then ad sets into campaigns. Metrics are computed over an optional date range, then rolled up from ad level to ad set and campaign levels. Pagination is at the campaign level. Ads without a campaign or ad set ID are grouped into synthetic "Ungrouped" buckets. If no date range is provided, defaults to the last 90 days. Date range is capped at 730 days max. Pass timeIncrement=1 to also get a daily breakdown: each node gains a daily[] array of per-day metrics (same fields as the aggregated metrics) in the same call. Use dailyLevel (campaign default, or adset / ad) to choose which levels carry the series. This replaces calling the tree once per day for per-campaign daily trends.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :page (Integer)

    Page number (1-based) (default to 1)

  • :limit (Integer)

    Campaigns per page (default to 20)

  • :source (String)

    `all` (default) returns both Zernio-created ads and those discovered from the platform's ad manager — matches the web UI's default view. Pass `zernio` to restrict to isExternal=false only. Status is NOT filtered by default — use the `status` param for that. (default to 'all')

  • :platform (String)
  • :status (AdStatus)

    Filter by derived campaign status (post-aggregation)

  • :ad_account_id (String)

    Platform ad account ID

  • :account_id (String)

    Social account ID

  • :profile_id (String)

    Profile ID

  • :campaign_id (String)

    Restrict the tree to a single campaign by its platform campaign id (the id the platform assigns, e.g. Meta's numeric campaign id). Filters the campaign set itself, so it works regardless of account size and pagination — pass this when you already hold a campaign id instead of paging the tree to find it. Mirrors the `campaignId` filter on GET /v1/ads.

  • :from_date (Date)

    Start of the METRICS date range (YYYY-MM-DD). Affects only the spend/impression numbers overlaid on each node, NOT which campaigns are returned. Defaults to 90 days ago.

  • :to_date (Date)

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

  • :sort (String)

    Campaign-level sort order. `newest` (default) / `oldest` order by the campaign's newest-ad createdAt. `spend_desc` / `spend_asc` order by aggregated spend in the requested date range; campaigns with no spend land at the end. (default to 'newest')

  • :time_increment (Integer)

    Set to `1` to also return a daily breakdown. Mirrors Meta Insights' `time_increment=1`: each node gains a `daily` array of per-day metrics (same fields as the aggregated `metrics`) alongside the range total, so you get per-entity daily trends in ONE call instead of calling the tree once per day. Only `1` (daily) is supported. The daily series covers the same date range and uses the same source data as `metrics`. See `dailyLevel` to control which levels carry it.

  • :daily_level (String)

    Which tree levels get the `daily` series when `timeIncrement=1`. `campaign` (default) attaches it on campaign nodes only — the common per-campaign-trend case, and the smallest payload. `adset` adds it on ad sets too; `ad` adds it on every ad in `ads` as well (heaviest — a long range × up to 100 ads per ad set). Scope with `campaignId` to keep `ad`-level responses small. Ignored when `timeIncrement` is unset. (default to 'campaign')

Returns:



810
811
812
813
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 810

def get_ad_tree(opts = {})
  data, _status_code, _headers = get_ad_tree_with_http_info(opts)
  data
end

#get_ad_tree_with_http_info(opts = {}) ⇒ Array<(GetAdTree200Response, Integer, Hash)>

Get campaign tree Returns a nested Campaign > Ad Set > Ad hierarchy with rolled-up metrics at each level. Uses a two-stage aggregation: ads are grouped into ad sets, then ad sets into campaigns. Metrics are computed over an optional date range, then rolled up from ad level to ad set and campaign levels. Pagination is at the campaign level. Ads without a campaign or ad set ID are grouped into synthetic &quot;Ungrouped&quot; buckets. If no date range is provided, defaults to the last 90 days. Date range is capped at 730 days max. Pass `timeIncrement=1` to also get a daily breakdown: each node gains a `daily` array of per-day metrics (same fields as the aggregated `metrics`) in the same call. Use `dailyLevel` (`campaign` default, or `adset` / `ad`) to choose which levels carry the series. This replaces calling the tree once per day for per-campaign daily trends.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :page (Integer)

    Page number (1-based) (default to 1)

  • :limit (Integer)

    Campaigns per page (default to 20)

  • :source (String)

    `all` (default) returns both Zernio-created ads and those discovered from the platform's ad manager — matches the web UI's default view. Pass `zernio` to restrict to isExternal=false only. Status is NOT filtered by default — use the `status` param for that. (default to 'all')

  • :platform (String)
  • :status (AdStatus)

    Filter by derived campaign status (post-aggregation)

  • :ad_account_id (String)

    Platform ad account ID

  • :account_id (String)

    Social account ID

  • :profile_id (String)

    Profile ID

  • :campaign_id (String)

    Restrict the tree to a single campaign by its platform campaign id (the id the platform assigns, e.g. Meta's numeric campaign id). Filters the campaign set itself, so it works regardless of account size and pagination — pass this when you already hold a campaign id instead of paging the tree to find it. Mirrors the `campaignId` filter on GET /v1/ads.

  • :from_date (Date)

    Start of the METRICS date range (YYYY-MM-DD). Affects only the spend/impression numbers overlaid on each node, NOT which campaigns are returned. Defaults to 90 days ago.

  • :to_date (Date)

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

  • :sort (String)

    Campaign-level sort order. `newest` (default) / `oldest` order by the campaign's newest-ad createdAt. `spend_desc` / `spend_asc` order by aggregated spend in the requested date range; campaigns with no spend land at the end. (default to 'newest')

  • :time_increment (Integer)

    Set to `1` to also return a daily breakdown. Mirrors Meta Insights' `time_increment=1`: each node gains a `daily` array of per-day metrics (same fields as the aggregated `metrics`) alongside the range total, so you get per-entity daily trends in ONE call instead of calling the tree once per day. Only `1` (daily) is supported. The daily series covers the same date range and uses the same source data as `metrics`. See `dailyLevel` to control which levels carry it.

  • :daily_level (String)

    Which tree levels get the `daily` series when `timeIncrement=1`. `campaign` (default) attaches it on campaign nodes only — the common per-campaign-trend case, and the smallest payload. `adset` adds it on ad sets too; `ad` adds it on every ad in `ads` as well (heaviest — a long range × up to 100 ads per ad set). Scope with `campaignId` to keep `ad`-level responses small. Ignored when `timeIncrement` is unset. (default to 'campaign')

Returns:

  • (Array<(GetAdTree200Response, Integer, Hash)>)

    GetAdTree200Response data, response status code and response headers



833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
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
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 833

def get_ad_tree_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AdCampaignsApi.get_ad_tree ...'
  end
  if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] < 1
    fail ArgumentError, 'invalid value for "opts[:"page"]" when calling AdCampaignsApi.get_ad_tree, must be greater than or equal to 1.'
  end

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

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

  allowable_values = ["zernio", "all"]
  if @api_client.config.client_side_validation && opts[:'source'] && !allowable_values.include?(opts[:'source'])
    fail ArgumentError, "invalid value for \"source\", must be one of #{allowable_values}"
  end
  allowable_values = ["facebook", "instagram", "tiktok", "linkedin", "pinterest", "google", "twitter", "openai"]
  if @api_client.config.client_side_validation && opts[:'platform'] && !allowable_values.include?(opts[:'platform'])
    fail ArgumentError, "invalid value for \"platform\", must be one of #{allowable_values}"
  end
  allowable_values = ["newest", "oldest", "spend_desc", "spend_asc"]
  if @api_client.config.client_side_validation && opts[:'sort'] && !allowable_values.include?(opts[:'sort'])
    fail ArgumentError, "invalid value for \"sort\", must be one of #{allowable_values}"
  end
  allowable_values = [1]
  if @api_client.config.client_side_validation && opts[:'time_increment'] && !allowable_values.include?(opts[:'time_increment'])
    fail ArgumentError, "invalid value for \"time_increment\", must be one of #{allowable_values}"
  end
  allowable_values = ["campaign", "adset", "ad"]
  if @api_client.config.client_side_validation && opts[:'daily_level'] && !allowable_values.include?(opts[:'daily_level'])
    fail ArgumentError, "invalid value for \"daily_level\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/v1/ads/tree'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'source'] = opts[:'source'] if !opts[:'source'].nil?
  query_params[:'platform'] = opts[:'platform'] if !opts[:'platform'].nil?
  query_params[:'status'] = opts[:'status'] if !opts[:'status'].nil?
  query_params[:'adAccountId'] = opts[:'ad_account_id'] if !opts[:'ad_account_id'].nil?
  query_params[:'accountId'] = opts[:'account_id'] if !opts[:'account_id'].nil?
  query_params[:'profileId'] = opts[:'profile_id'] if !opts[:'profile_id'].nil?
  query_params[:'campaignId'] = opts[:'campaign_id'] if !opts[:'campaign_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[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?
  query_params[:'timeIncrement'] = opts[:'time_increment'] if !opts[:'time_increment'].nil?
  query_params[:'dailyLevel'] = opts[:'daily_level'] if !opts[:'daily_level'].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] || 'GetAdTree200Response'

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

  new_options = opts.merge(
    :operation => :"AdCampaignsApi.get_ad_tree",
    :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: AdCampaignsApi#get_ad_tree\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_ad_with_http_info(ad_id, opts = {}) ⇒ Array<(GetAd200Response, Integer, Hash)>

Get ad details Returns an ad with its creative, targeting, status, and performance metrics. The `adId` path segment accepts any identifier dialect Zernio indexes for the ad: - the Zernio internal `_id` (24-char hex) - Meta's numeric `platformAdId` (the value shipped in `comment.received` webhooks as `comment.ad.id`) - the creative's `effective_object_story_id` (`pageId_postId` shape, Facebook side) - the creative's `effective_instagram_media_id` (Instagram side) Any of the four resolve to the same ad. Caller doesn't need a translation step.

Parameters:

  • ad_id (String)

    Zernio `_id` (hex), Meta `platformAdId` (numeric), or one of the creative's effective story/media IDs. See description for details.

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

    the optional parameters

Returns:

  • (Array<(GetAd200Response, Integer, Hash)>)

    GetAd200Response data, response status code and response headers



671
672
673
674
675
676
677
678
679
680
681
682
683
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
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 671

def get_ad_with_http_info(ad_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AdCampaignsApi.get_ad ...'
  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 AdCampaignsApi.get_ad"
  end
  # resource path
  local_var_path = '/v1/ads/{adId}'.sub('{' + 'adId' + '}', CGI.escape(ad_id.to_s))

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

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

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

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

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

  new_options = opts.merge(
    :operation => :"AdCampaignsApi.get_ad",
    :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: AdCampaignsApi#get_ad\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_ads_timeline(account_id, opts = {}) ⇒ GetAdsTimeline200Response

Get daily account metrics Returns daily aggregate metrics across all ads in a SocialAccount as a single time series — one row per calendar day in the requested range. Use this for dashboards that draw a daily-spend or daily-conversions chart, instead of calling /v1/ads/tree once per day. accountId is required. The lookup is sibling-expanded so passing the metaads ID also includes ads under the linked facebook / instagram posting account (and vice-versa) — same convention as /v1/ads/tree and /v1/ads. Date range defaults to the last 90 days. Capped at 730 days. Ranges older than the ingested history return a 202 immediately with the covered part and backfillPending: true while the rest is backfilled in the background; repeat the request shortly until it returns 200 with full data.

Parameters:

  • account_id (String)

    Social account ID. Sibling-expanded to its linked posting↔ads pair.

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

    the optional parameters

Options Hash (opts):

  • :ad_account_id (String)

    Optional platform-native ad account ID (e.g. Meta `act_…`, TikTok advertiser ID). Use when the connection wraps multiple platform ad accounts and the chart should show one only. Note: rows ingested before 2026-05-13 don't carry this column; the recurring 7-day re-sync repopulates them naturally.

  • :from_date (Date)

    Inclusive start of metrics range (YYYY-MM-DD). Defaults to 90 days ago.

  • :to_date (Date)

    Inclusive end of metrics range (YYYY-MM-DD). Defaults to today. Max 730-day range.

  • :platform (String)

    Restrict to one platform.

Returns:



932
933
934
935
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 932

def get_ads_timeline(, opts = {})
  data, _status_code, _headers = get_ads_timeline_with_http_info(, opts)
  data
end

#get_ads_timeline_with_http_info(account_id, opts = {}) ⇒ Array<(GetAdsTimeline200Response, Integer, Hash)>

Get daily account metrics Returns daily aggregate metrics across all ads in a SocialAccount as a single time series — one row per calendar day in the requested range. Use this for dashboards that draw a daily-spend or daily-conversions chart, instead of calling `/v1/ads/tree` once per day. `accountId` is required. The lookup is sibling-expanded so passing the `metaads` ID also includes ads under the linked `facebook` / `instagram` posting account (and vice-versa) — same convention as `/v1/ads/tree` and `/v1/ads`. Date range defaults to the last 90 days. Capped at 730 days. Ranges older than the ingested history return a `202` immediately with the covered part and `backfillPending: true` while the rest is backfilled in the background; repeat the request shortly until it returns 200 with full data.

Parameters:

  • account_id (String)

    Social account ID. Sibling-expanded to its linked posting↔ads pair.

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

    the optional parameters

Options Hash (opts):

  • :ad_account_id (String)

    Optional platform-native ad account ID (e.g. Meta `act_…`, TikTok advertiser ID). Use when the connection wraps multiple platform ad accounts and the chart should show one only. Note: rows ingested before 2026-05-13 don't carry this column; the recurring 7-day re-sync repopulates them naturally.

  • :from_date (Date)

    Inclusive start of metrics range (YYYY-MM-DD). Defaults to 90 days ago.

  • :to_date (Date)

    Inclusive end of metrics range (YYYY-MM-DD). Defaults to today. Max 730-day range.

  • :platform (String)

    Restrict to one platform.

Returns:

  • (Array<(GetAdsTimeline200Response, Integer, Hash)>)

    GetAdsTimeline200Response data, response status code and response headers



946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 946

def get_ads_timeline_with_http_info(, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AdCampaignsApi.get_ads_timeline ...'
  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 AdCampaignsApi.get_ads_timeline"
  end
  allowable_values = ["facebook", "instagram", "tiktok", "linkedin", "pinterest", "google", "twitter", "openai"]
  if @api_client.config.client_side_validation && opts[:'platform'] && !allowable_values.include?(opts[:'platform'])
    fail ArgumentError, "invalid value for \"platform\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/v1/ads/timeline'

  # 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[:'fromDate'] = opts[:'from_date'] if !opts[:'from_date'].nil?
  query_params[:'toDate'] = opts[:'to_date'] if !opts[:'to_date'].nil?
  query_params[:'platform'] = opts[:'platform'] if !opts[:'platform'].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] || 'GetAdsTimeline200Response'

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

  new_options = opts.merge(
    :operation => :"AdCampaignsApi.get_ads_timeline",
    :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: AdCampaignsApi#get_ads_timeline\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_ad_campaigns(opts = {}) ⇒ ListAdCampaigns200Response

List campaigns Returns campaigns as virtual aggregations over ad documents grouped by platform campaign ID. Metrics (spend, impressions, clicks, etc.) are summed across all ads in each campaign. Campaign status is derived from child ad statuses (active > pending_review > paused > error > completed > cancelled > rejected).

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :page (Integer)

    Page number (1-based) (default to 1)

  • :limit (Integer) — default: default to 20
  • :source (String)

    `all` (default) returns both Zernio-created ads and those discovered from the platform's ad manager — matches the web UI's default view. Pass `zernio` to restrict to isExternal=false only. Status is NOT filtered by default — use the `status` param for that. (default to 'all')

  • :platform (String)
  • :status (AdStatus)

    Filter by derived campaign status (post-aggregation)

  • :ad_account_id (String)

    Platform ad account ID (e.g. act_123 for Meta)

  • :account_id (String)

    Social account ID

  • :profile_id (String)

    Profile ID

  • :from_date (Date)

    Start of metrics date range (YYYY-MM-DD, inclusive). Defaults to 90 days ago when both date params are omitted.

  • :to_date (Date)

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

Returns:



1017
1018
1019
1020
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 1017

def list_ad_campaigns(opts = {})
  data, _status_code, _headers = list_ad_campaigns_with_http_info(opts)
  data
end

#list_ad_campaigns_with_http_info(opts = {}) ⇒ Array<(ListAdCampaigns200Response, Integer, Hash)>

List campaigns Returns campaigns as virtual aggregations over ad documents grouped by platform campaign ID. Metrics (spend, impressions, clicks, etc.) are summed across all ads in each campaign. Campaign status is derived from child ad statuses (active > pending_review > paused > error > completed > cancelled > rejected).

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :page (Integer)

    Page number (1-based) (default to 1)

  • :limit (Integer) — default: default to 20
  • :source (String)

    `all` (default) returns both Zernio-created ads and those discovered from the platform's ad manager — matches the web UI's default view. Pass `zernio` to restrict to isExternal=false only. Status is NOT filtered by default — use the `status` param for that. (default to 'all')

  • :platform (String)
  • :status (AdStatus)

    Filter by derived campaign status (post-aggregation)

  • :ad_account_id (String)

    Platform ad account ID (e.g. act_123 for Meta)

  • :account_id (String)

    Social account ID

  • :profile_id (String)

    Profile ID

  • :from_date (Date)

    Start of metrics date range (YYYY-MM-DD, inclusive). Defaults to 90 days ago when both date params are omitted.

  • :to_date (Date)

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

Returns:

  • (Array<(ListAdCampaigns200Response, Integer, Hash)>)

    ListAdCampaigns200Response data, response status code and response headers



1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 1036

def list_ad_campaigns_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AdCampaignsApi.list_ad_campaigns ...'
  end
  if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] < 1
    fail ArgumentError, 'invalid value for "opts[:"page"]" when calling AdCampaignsApi.list_ad_campaigns, must be greater than or equal to 1.'
  end

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

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

  allowable_values = ["zernio", "all"]
  if @api_client.config.client_side_validation && opts[:'source'] && !allowable_values.include?(opts[:'source'])
    fail ArgumentError, "invalid value for \"source\", must be one of #{allowable_values}"
  end
  allowable_values = ["facebook", "instagram", "tiktok", "linkedin", "pinterest", "google", "twitter", "openai"]
  if @api_client.config.client_side_validation && opts[:'platform'] && !allowable_values.include?(opts[:'platform'])
    fail ArgumentError, "invalid value for \"platform\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/v1/ads/campaigns'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'source'] = opts[:'source'] if !opts[:'source'].nil?
  query_params[:'platform'] = opts[:'platform'] if !opts[:'platform'].nil?
  query_params[:'status'] = opts[:'status'] if !opts[:'status'].nil?
  query_params[:'adAccountId'] = opts[:'ad_account_id'] if !opts[:'ad_account_id'].nil?
  query_params[:'accountId'] = opts[:'account_id'] if !opts[:'account_id'].nil?
  query_params[:'profileId'] = opts[:'profile_id'] if !opts[:'profile_id'].nil?
  query_params[:'fromDate'] = opts[:'from_date'] if !opts[:'from_date'].nil?
  query_params[:'toDate'] = opts[:'to_date'] if !opts[:'to_date'].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] || 'ListAdCampaigns200Response'

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

  new_options = opts.merge(
    :operation => :"AdCampaignsApi.list_ad_campaigns",
    :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: AdCampaignsApi#list_ad_campaigns\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_ads(opts = {}) ⇒ ListAds200Response

List ads Returns a paginated list of ads with metrics computed over an optional date range. Use source=all to include externally-synced ads from platform ad managers. If no date range is provided, defaults to the last 90 days. Date range is capped at 730 days max. To find the Zernio ad behind a comment you see in Meta Business Manager, filter by platformAdId (the Meta ad ID), effectiveObjectStoryId (Facebook), or effectiveInstagramMediaId (Instagram) — those are the post/media the ad's engagement lives on, and are also returned on each ad's creative object. Then call GET /v1/ads/adId/comments with the returned ad id.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :page (Integer)

    Page number (1-based) (default to 1)

  • :limit (Integer) — default: default to 50
  • :source (String)

    all (default) = Zernio-created + platform-discovered ads. zernio = restrict to Zernio-created only. (default to 'all')

  • :status (AdStatus)
  • :platform (String)
  • :account_id (String)

    Social account ID

  • :ad_account_id (String)

    Platform ad account ID (e.g. act_123 for Meta). Mirrors the same filter on /v1/ads/campaigns and /v1/ads/tree.

  • :profile_id (String)

    Profile ID

  • :campaign_id (String)

    Platform campaign ID (filter ads within a campaign)

  • :platform_ad_id (String)

    Meta ad ID. Returns the ad with this platform-side ad ID.

  • :effective_object_story_id (String)

    Facebook `pageId_postId` of the post the ad's engagement lives on (Meta `effective_object_story_id`). Use to map a Business-Manager-visible post back to the Zernio ad.

  • :effective_instagram_media_id (String)

    Instagram media ID of the boosted post (Meta `effective_instagram_media_id`). Use to map a Business-Manager-visible IG post back to the Zernio ad.

  • :from_date (Date)

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

  • :to_date (Date)

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

Returns:



1128
1129
1130
1131
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 1128

def list_ads(opts = {})
  data, _status_code, _headers = list_ads_with_http_info(opts)
  data
end

#list_ads_with_http_info(opts = {}) ⇒ Array<(ListAds200Response, Integer, Hash)>

List ads Returns a paginated list of ads with metrics computed over an optional date range. Use source=all to include externally-synced ads from platform ad managers. If no date range is provided, defaults to the last 90 days. Date range is capped at 730 days max. To find the Zernio ad behind a comment you see in Meta Business Manager, filter by platformAdId (the Meta ad ID), effectiveObjectStoryId (Facebook), or effectiveInstagramMediaId (Instagram) — those are the post/media the ad's engagement lives on, and are also returned on each ad's `creative` object. Then call GET /v1/ads/adId/comments with the returned ad id.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :page (Integer)

    Page number (1-based) (default to 1)

  • :limit (Integer) — default: default to 50
  • :source (String)

    all (default) = Zernio-created + platform-discovered ads. zernio = restrict to Zernio-created only. (default to 'all')

  • :status (AdStatus)
  • :platform (String)
  • :account_id (String)

    Social account ID

  • :ad_account_id (String)

    Platform ad account ID (e.g. act_123 for Meta). Mirrors the same filter on /v1/ads/campaigns and /v1/ads/tree.

  • :profile_id (String)

    Profile ID

  • :campaign_id (String)

    Platform campaign ID (filter ads within a campaign)

  • :platform_ad_id (String)

    Meta ad ID. Returns the ad with this platform-side ad ID.

  • :effective_object_story_id (String)

    Facebook `pageId_postId` of the post the ad's engagement lives on (Meta `effective_object_story_id`). Use to map a Business-Manager-visible post back to the Zernio ad.

  • :effective_instagram_media_id (String)

    Instagram media ID of the boosted post (Meta `effective_instagram_media_id`). Use to map a Business-Manager-visible IG post back to the Zernio ad.

  • :from_date (Date)

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

  • :to_date (Date)

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

Returns:

  • (Array<(ListAds200Response, Integer, Hash)>)

    ListAds200Response data, response status code and response headers



1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 1151

def list_ads_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AdCampaignsApi.list_ads ...'
  end
  if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] < 1
    fail ArgumentError, 'invalid value for "opts[:"page"]" when calling AdCampaignsApi.list_ads, must be greater than or equal to 1.'
  end

  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 500
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling AdCampaignsApi.list_ads, 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 AdCampaignsApi.list_ads, must be greater than or equal to 1.'
  end

  allowable_values = ["zernio", "all"]
  if @api_client.config.client_side_validation && opts[:'source'] && !allowable_values.include?(opts[:'source'])
    fail ArgumentError, "invalid value for \"source\", must be one of #{allowable_values}"
  end
  allowable_values = ["facebook", "instagram", "tiktok", "linkedin", "pinterest", "google", "twitter", "openai"]
  if @api_client.config.client_side_validation && opts[:'platform'] && !allowable_values.include?(opts[:'platform'])
    fail ArgumentError, "invalid value for \"platform\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/v1/ads'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'source'] = opts[:'source'] if !opts[:'source'].nil?
  query_params[:'status'] = opts[:'status'] if !opts[:'status'].nil?
  query_params[:'platform'] = opts[:'platform'] if !opts[:'platform'].nil?
  query_params[:'accountId'] = opts[:'account_id'] if !opts[:'account_id'].nil?
  query_params[:'adAccountId'] = opts[:'ad_account_id'] if !opts[:'ad_account_id'].nil?
  query_params[:'profileId'] = opts[:'profile_id'] if !opts[:'profile_id'].nil?
  query_params[:'campaignId'] = opts[:'campaign_id'] if !opts[:'campaign_id'].nil?
  query_params[:'platformAdId'] = opts[:'platform_ad_id'] if !opts[:'platform_ad_id'].nil?
  query_params[:'effectiveObjectStoryId'] = opts[:'effective_object_story_id'] if !opts[:'effective_object_story_id'].nil?
  query_params[:'effectiveInstagramMediaId'] = opts[:'effective_instagram_media_id'] if !opts[:'effective_instagram_media_id'].nil?
  query_params[:'fromDate'] = opts[:'from_date'] if !opts[:'from_date'].nil?
  query_params[:'toDate'] = opts[:'to_date'] if !opts[:'to_date'].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] || 'ListAds200Response'

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

  new_options = opts.merge(
    :operation => :"AdCampaignsApi.list_ads",
    :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: AdCampaignsApi#list_ads\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#update_ad(ad_id, update_ad_request, opts = {}) ⇒ UpdateAd200Response

Update ad Patch one or more fields on an ad. Status, budget, targeting, and creative changes are propagated to the platform. Per-platform support: - Meta (Facebook + Instagram): all fields supported. - TikTok: status, budget, targeting (via /v2/adgroup/update/), and creative (via /v2/ad/update/ patch-style — headline is ignored, body becomes ad_text). - Pinterest / X / LinkedIn / Google / OpenAI Ads: status + budget only. Sending targeting or creative returns 501 with code unsupported_platform_operation. OpenAI Ads budget is lifetime-only (see budget.type below).

Parameters:

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

    the optional parameters

Returns:



1235
1236
1237
1238
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 1235

def update_ad(ad_id, update_ad_request, opts = {})
  data, _status_code, _headers = update_ad_with_http_info(ad_id, update_ad_request, opts)
  data
end

#update_ad_campaign(campaign_id, update_ad_campaign_request, opts = {}) ⇒ UpdateAdCampaign200Response

Update a campaign Campaign-level edits. At least one of budget, bidStrategy, name or platformSpecificData is required. - budget updates the CBO (Campaign Budget Optimization) budget. For ABO campaigns (where the budget lives on the ad set), use PUT /v1/ads/ad-sets/adSetId instead — this endpoint will return 409 with code BUDGET_LEVEL_MISMATCH. - bidStrategy sets the campaign-level default bid strategy. Per Meta's spec, bid_amount and bid_constraints do NOT exist at the campaign level — pass them via PUT /v1/ads/ad-sets/adSetId. - platformSpecificData.spendCap (Meta only) sets the campaign's lifetime spend cap, in the ad account's currency. Meta-only for now. Other platforms return 501 Not Implemented.

Parameters:

  • campaign_id (String)

    Platform campaign ID

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

    the optional parameters

Returns:



1309
1310
1311
1312
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 1309

def update_ad_campaign(campaign_id, update_ad_campaign_request, opts = {})
  data, _status_code, _headers = update_ad_campaign_with_http_info(campaign_id, update_ad_campaign_request, opts)
  data
end

#update_ad_campaign_status(campaign_id, update_ad_campaign_status_request, opts = {}) ⇒ UpdateAdCampaignStatus200Response

Pause or resume a campaign Updates the status of all ads in a campaign. Makes one platform API call (not per-ad) since status cascades through the campaign hierarchy. Ads in terminal statuses (rejected, completed, cancelled) are automatically skipped.

Parameters:

  • campaign_id (String)

    Platform campaign ID

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

    the optional parameters

Returns:



1383
1384
1385
1386
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 1383

def update_ad_campaign_status(campaign_id, update_ad_campaign_status_request, opts = {})
  data, _status_code, _headers = update_ad_campaign_status_with_http_info(campaign_id, update_ad_campaign_status_request, opts)
  data
end

#update_ad_campaign_status_with_http_info(campaign_id, update_ad_campaign_status_request, opts = {}) ⇒ Array<(UpdateAdCampaignStatus200Response, Integer, Hash)>

Pause or resume a campaign Updates the status of all ads in a campaign. Makes one platform API call (not per-ad) since status cascades through the campaign hierarchy. Ads in terminal statuses (rejected, completed, cancelled) are automatically skipped.

Parameters:

  • campaign_id (String)

    Platform campaign ID

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

    the optional parameters

Returns:



1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 1394

def update_ad_campaign_status_with_http_info(campaign_id, update_ad_campaign_status_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AdCampaignsApi.update_ad_campaign_status ...'
  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 AdCampaignsApi.update_ad_campaign_status"
  end
  # verify the required parameter 'update_ad_campaign_status_request' is set
  if @api_client.config.client_side_validation && update_ad_campaign_status_request.nil?
    fail ArgumentError, "Missing the required parameter 'update_ad_campaign_status_request' when calling AdCampaignsApi.update_ad_campaign_status"
  end
  # resource path
  local_var_path = '/v1/ads/campaigns/{campaignId}/status'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_id.to_s))

  # 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(update_ad_campaign_status_request)

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

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

  new_options = opts.merge(
    :operation => :"AdCampaignsApi.update_ad_campaign_status",
    :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(:PUT, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: AdCampaignsApi#update_ad_campaign_status\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#update_ad_campaign_with_http_info(campaign_id, update_ad_campaign_request, opts = {}) ⇒ Array<(UpdateAdCampaign200Response, Integer, Hash)>

Update a campaign Campaign-level edits. At least one of `budget`, `bidStrategy`, `name` or `platformSpecificData` is required. - `budget` updates the CBO (Campaign Budget Optimization) budget. For ABO campaigns (where the budget lives on the ad set), use PUT /v1/ads/ad-sets/adSetId instead — this endpoint will return 409 with code BUDGET_LEVEL_MISMATCH. - `bidStrategy` sets the campaign-level default bid strategy. Per Meta's spec, `bid_amount` and `bid_constraints` do NOT exist at the campaign level — pass them via PUT /v1/ads/ad-sets/adSetId. - `platformSpecificData.spendCap` (Meta only) sets the campaign's lifetime spend cap, in the ad account's currency. Meta-only for now. Other platforms return 501 Not Implemented.

Parameters:

  • campaign_id (String)

    Platform campaign ID

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

    the optional parameters

Returns:

  • (Array<(UpdateAdCampaign200Response, Integer, Hash)>)

    UpdateAdCampaign200Response data, response status code and response headers



1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 1320

def update_ad_campaign_with_http_info(campaign_id, update_ad_campaign_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AdCampaignsApi.update_ad_campaign ...'
  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 AdCampaignsApi.update_ad_campaign"
  end
  # verify the required parameter 'update_ad_campaign_request' is set
  if @api_client.config.client_side_validation && update_ad_campaign_request.nil?
    fail ArgumentError, "Missing the required parameter 'update_ad_campaign_request' when calling AdCampaignsApi.update_ad_campaign"
  end
  # resource path
  local_var_path = '/v1/ads/campaigns/{campaignId}'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_id.to_s))

  # 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(update_ad_campaign_request)

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

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

  new_options = opts.merge(
    :operation => :"AdCampaignsApi.update_ad_campaign",
    :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(:PUT, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: AdCampaignsApi#update_ad_campaign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#update_ad_set(ad_set_id, update_ad_set_request, opts = {}) ⇒ UpdateAdSet200Response

Update an ad set Ad-set-level writes. Use this for ABO budget updates, ad-set-scoped pause/resume, bid-strategy edits, and Meta-only post-launch delivery settings via platformSpecificData. At least one updatable field is required. Bid strategy compatibility (per Meta's spec): - LOWEST_COST_WITHOUT_CAP: no bidAmount, no roasAverageFloor. - LOWEST_COST_WITH_BID_CAP / COST_CAP: bidAmount REQUIRED (whole currency units). - LOWEST_COST_WITH_MIN_ROAS: roasAverageFloor REQUIRED (decimal multiplier, e.g. 2.0 = 2.0x ROAS). Delivery settings are validated by Meta against the campaign objective; incompatible combinations (e.g. a billingEvent the optimization goal doesn't allow) surface as 400s from Meta. When updating budget on an ABO campaign: if the parent campaign is CBO, the response is 409 with code BUDGET_LEVEL_MISMATCH — route to PUT /v1/ads/campaigns/campaignId instead.

Parameters:

  • ad_set_id (String)

    Platform ad set ID

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

    the optional parameters

Returns:



1457
1458
1459
1460
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 1457

def update_ad_set(ad_set_id, update_ad_set_request, opts = {})
  data, _status_code, _headers = update_ad_set_with_http_info(ad_set_id, update_ad_set_request, opts)
  data
end

#update_ad_set_status(ad_set_id, update_ad_campaign_status_request, opts = {}) ⇒ UpdateAdSetStatus200Response

Pause or resume a single ad set Ad-set-scoped pause/resume (doesn't touch sibling ad sets). Thin wrapper over PUT /v1/ads/ad-sets/adSetId for callers that only want the status toggle and prefer a symmetric URL to /v1/ads/campaigns/campaignId/status.

Parameters:

  • ad_set_id (String)

    Platform ad set ID

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

    the optional parameters

Returns:



1531
1532
1533
1534
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 1531

def update_ad_set_status(ad_set_id, update_ad_campaign_status_request, opts = {})
  data, _status_code, _headers = update_ad_set_status_with_http_info(ad_set_id, update_ad_campaign_status_request, opts)
  data
end

#update_ad_set_status_with_http_info(ad_set_id, update_ad_campaign_status_request, opts = {}) ⇒ Array<(UpdateAdSetStatus200Response, Integer, Hash)>

Pause or resume a single ad set Ad-set-scoped pause/resume (doesn't touch sibling ad sets). Thin wrapper over PUT /v1/ads/ad-sets/adSetId for callers that only want the status toggle and prefer a symmetric URL to /v1/ads/campaigns/campaignId/status.

Parameters:

  • ad_set_id (String)

    Platform ad set ID

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

    the optional parameters

Returns:



1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 1542

def update_ad_set_status_with_http_info(ad_set_id, update_ad_campaign_status_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AdCampaignsApi.update_ad_set_status ...'
  end
  # verify the required parameter 'ad_set_id' is set
  if @api_client.config.client_side_validation && ad_set_id.nil?
    fail ArgumentError, "Missing the required parameter 'ad_set_id' when calling AdCampaignsApi.update_ad_set_status"
  end
  # verify the required parameter 'update_ad_campaign_status_request' is set
  if @api_client.config.client_side_validation && update_ad_campaign_status_request.nil?
    fail ArgumentError, "Missing the required parameter 'update_ad_campaign_status_request' when calling AdCampaignsApi.update_ad_set_status"
  end
  # resource path
  local_var_path = '/v1/ads/ad-sets/{adSetId}/status'.sub('{' + 'adSetId' + '}', CGI.escape(ad_set_id.to_s))

  # 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(update_ad_campaign_status_request)

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

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

  new_options = opts.merge(
    :operation => :"AdCampaignsApi.update_ad_set_status",
    :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(:PUT, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: AdCampaignsApi#update_ad_set_status\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#update_ad_set_with_http_info(ad_set_id, update_ad_set_request, opts = {}) ⇒ Array<(UpdateAdSet200Response, Integer, Hash)>

Update an ad set Ad-set-level writes. Use this for ABO budget updates, ad-set-scoped pause/resume, bid-strategy edits, and Meta-only post-launch delivery settings via `platformSpecificData`. At least one updatable field is required. Bid strategy compatibility (per Meta's spec): - `LOWEST_COST_WITHOUT_CAP`: no `bidAmount`, no `roasAverageFloor`. - `LOWEST_COST_WITH_BID_CAP` / `COST_CAP`: `bidAmount` REQUIRED (whole currency units). - `LOWEST_COST_WITH_MIN_ROAS`: `roasAverageFloor` REQUIRED (decimal multiplier, e.g. 2.0 = 2.0x ROAS). Delivery settings are validated by Meta against the campaign objective; incompatible combinations (e.g. a billingEvent the optimization goal doesn't allow) surface as 400s from Meta. When updating `budget` on an ABO campaign: if the parent campaign is CBO, the response is 409 with code BUDGET_LEVEL_MISMATCH — route to PUT /v1/ads/campaigns/campaignId instead.

Parameters:

  • ad_set_id (String)

    Platform ad set ID

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

    the optional parameters

Returns:

  • (Array<(UpdateAdSet200Response, Integer, Hash)>)

    UpdateAdSet200Response data, response status code and response headers



1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 1468

def update_ad_set_with_http_info(ad_set_id, update_ad_set_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AdCampaignsApi.update_ad_set ...'
  end
  # verify the required parameter 'ad_set_id' is set
  if @api_client.config.client_side_validation && ad_set_id.nil?
    fail ArgumentError, "Missing the required parameter 'ad_set_id' when calling AdCampaignsApi.update_ad_set"
  end
  # verify the required parameter 'update_ad_set_request' is set
  if @api_client.config.client_side_validation && update_ad_set_request.nil?
    fail ArgumentError, "Missing the required parameter 'update_ad_set_request' when calling AdCampaignsApi.update_ad_set"
  end
  # resource path
  local_var_path = '/v1/ads/ad-sets/{adSetId}'.sub('{' + 'adSetId' + '}', CGI.escape(ad_set_id.to_s))

  # 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(update_ad_set_request)

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

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

  new_options = opts.merge(
    :operation => :"AdCampaignsApi.update_ad_set",
    :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(:PUT, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: AdCampaignsApi#update_ad_set\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#update_ad_status(ad_id, update_ad_status_request, opts = {}) ⇒ UpdateAdStatus200Response

Pause or resume a single ad Ad-scoped pause/resume — touches ONLY this ad, never its parent ad set or campaign (so sibling ads keep running). Thin wrapper over the status field of PUT /v1/ads/adId, for callers that want a URL symmetric to /v1/ads/campaigns/campaignId/status and /v1/ads/ad-sets/adSetId/status. {adId} accepts the same identifier dialects as GET/PUT /v1/ads/adId (Zernio hex _id, Meta numeric platformAdId, or the creative's effective story/media IDs). platform is inferred from the ad, so it's not required in the body. Ads in terminal statuses (rejected, completed, cancelled) and no-op flips (already in the target state) are skipped.

Parameters:

  • ad_id (String)

    Zernio `_id` (hex), Meta `platformAdId` (numeric), or one of the creative's effective story/media IDs.

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

    the optional parameters

Returns:



1605
1606
1607
1608
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 1605

def update_ad_status(ad_id, update_ad_status_request, opts = {})
  data, _status_code, _headers = update_ad_status_with_http_info(ad_id, update_ad_status_request, opts)
  data
end

#update_ad_status_with_http_info(ad_id, update_ad_status_request, opts = {}) ⇒ Array<(UpdateAdStatus200Response, Integer, Hash)>

Pause or resume a single ad Ad-scoped pause/resume — touches ONLY this ad, never its parent ad set or campaign (so sibling ads keep running). Thin wrapper over the `status` field of PUT /v1/ads/adId, for callers that want a URL symmetric to /v1/ads/campaigns/campaignId/status and /v1/ads/ad-sets/adSetId/status. `adId` accepts the same identifier dialects as GET/PUT /v1/ads/adId (Zernio hex `_id`, Meta numeric `platformAdId`, or the creative's effective story/media IDs). `platform` is inferred from the ad, so it's not required in the body. Ads in terminal statuses (rejected, completed, cancelled) and no-op flips (already in the target state) are skipped.

Parameters:

  • ad_id (String)

    Zernio `_id` (hex), Meta `platformAdId` (numeric), or one of the creative's effective story/media IDs.

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

    the optional parameters

Returns:

  • (Array<(UpdateAdStatus200Response, Integer, Hash)>)

    UpdateAdStatus200Response data, response status code and response headers



1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 1616

def update_ad_status_with_http_info(ad_id, update_ad_status_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AdCampaignsApi.update_ad_status ...'
  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 AdCampaignsApi.update_ad_status"
  end
  # verify the required parameter 'update_ad_status_request' is set
  if @api_client.config.client_side_validation && update_ad_status_request.nil?
    fail ArgumentError, "Missing the required parameter 'update_ad_status_request' when calling AdCampaignsApi.update_ad_status"
  end
  # resource path
  local_var_path = '/v1/ads/{adId}/status'.sub('{' + 'adId' + '}', CGI.escape(ad_id.to_s))

  # 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(update_ad_status_request)

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

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

  new_options = opts.merge(
    :operation => :"AdCampaignsApi.update_ad_status",
    :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(:PUT, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: AdCampaignsApi#update_ad_status\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#update_ad_with_http_info(ad_id, update_ad_request, opts = {}) ⇒ Array<(UpdateAd200Response, Integer, Hash)>

Update ad Patch one or more fields on an ad. Status, budget, targeting, and creative changes are propagated to the platform. Per-platform support: - Meta (Facebook + Instagram): all fields supported. - TikTok: status, budget, targeting (via `/v2/adgroup/update/`), and creative (via `/v2/ad/update/` patch-style — `headline` is ignored, `body` becomes `ad_text`). - Pinterest / X / LinkedIn / Google / OpenAI Ads: status + budget only. Sending `targeting` or `creative` returns 501 with code `unsupported_platform_operation`. OpenAI Ads budget is lifetime-only (see `budget.type` below).

Parameters:

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

    the optional parameters

Returns:

  • (Array<(UpdateAd200Response, Integer, Hash)>)

    UpdateAd200Response data, response status code and response headers



1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 1246

def update_ad_with_http_info(ad_id, update_ad_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AdCampaignsApi.update_ad ...'
  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 AdCampaignsApi.update_ad"
  end
  # verify the required parameter 'update_ad_request' is set
  if @api_client.config.client_side_validation && update_ad_request.nil?
    fail ArgumentError, "Missing the required parameter 'update_ad_request' when calling AdCampaignsApi.update_ad"
  end
  # resource path
  local_var_path = '/v1/ads/{adId}'.sub('{' + 'adId' + '}', CGI.escape(ad_id.to_s))

  # 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(update_ad_request)

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

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

  new_options = opts.merge(
    :operation => :"AdCampaignsApi.update_ad",
    :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(:PUT, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: AdCampaignsApi#update_ad\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end