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

#attach_campaign_assets(campaign_id, attach_campaign_assets_request, opts = {}) ⇒ AttachCampaignAssets201Response

Attach extension assets to a Google Search campaign Attach sitelinks, callouts and/or structured snippets to an already-existing Google Search campaign — the same builders POST /v1/ads/create uses, but without rebuilding the hierarchy. At least one of sitelinks, callouts or structuredSnippets is required. Google-only. Other platforms have no equivalent extension surface and return 501. Approval status is Google-async; poll asset.policy_summary after review. Assets stay in the account library even if the campaign is later deleted.

Parameters:

  • campaign_id (String)

    Numeric Google platform campaign id.

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

    the optional parameters

Returns:



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

def attach_campaign_assets(campaign_id, attach_campaign_assets_request, opts = {})
  data, _status_code, _headers = attach_campaign_assets_with_http_info(campaign_id, attach_campaign_assets_request, opts)
  data
end

#attach_campaign_assets_with_http_info(campaign_id, attach_campaign_assets_request, opts = {}) ⇒ Array<(AttachCampaignAssets201Response, Integer, Hash)>

Attach extension assets to a Google Search campaign Attach sitelinks, callouts and/or structured snippets to an already-existing Google Search campaign — the same builders POST /v1/ads/create uses, but without rebuilding the hierarchy. At least one of sitelinks, callouts or structuredSnippets is required. Google-only. Other platforms have no equivalent extension surface and return 501. Approval status is Google-async; poll `asset.policy_summary` after review. Assets stay in the account library even if the campaign is later deleted.

Parameters:

  • campaign_id (String)

    Numeric Google platform campaign id.

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

    the optional parameters

Returns:



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
89
90
91
92
93
94
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 39

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

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

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

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

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

Boost post as ad Creates a paid ad from an existing published post, keeping the post's engagement. By default it provisions the whole hierarchy (campaign, ad set, ad). Attach shape (Meta). Send adSetId to put the ad under an EXISTING ad set instead, so that ad set keeps its learning phase. It then owns budget, schedule and targeting, and sending any of those alongside adSetId is a 400 rather than a silent drop. budget is required only without adSetId. instagramAccountId, destinationType and adSetId are Meta-only and return 400 on other platforms. Retries. Boosts are NOT idempotent and can take minutes when Meta requires re-hosting an Instagram video, so do not retry on client timeout. Send an Idempotency-Key header to make retries safe: same key and body replays the original 201, and distinct keys always create distinct ads. Without the header, an identical request is treated as a retry: while one is in flight it returns 409, and within 10 minutes of a completed boost it returns the already-created ad instead of creating another. To intentionally duplicate an ad, send distinct Idempotency-Keys (or vary the body, e.g. the name).

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :idempotency_key (String)

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

Returns:



102
103
104
105
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 102

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 from an existing published post, keeping the post's engagement. By default it provisions the whole hierarchy (campaign, ad set, ad). Attach shape (Meta). Send `adSetId` to put the ad under an EXISTING ad set instead, so that ad set keeps its learning phase. It then owns `budget`, `schedule` and `targeting`, and sending any of those alongside `adSetId` is a 400 rather than a silent drop. `budget` is required only without `adSetId`. `instagramAccountId`, `destinationType` and `adSetId` are Meta-only and return 400 on other platforms. Retries. Boosts are NOT idempotent and can take minutes when Meta requires re-hosting an Instagram video, so do not retry on client timeout. Send an Idempotency-Key header to make retries safe: same key and body replays the original 201, and distinct keys always create distinct ads. Without the header, an identical request is treated as a retry: while one is in flight it returns 409, and within 10 minutes of a completed boost it returns the already-created ad instead of creating another. To intentionally duplicate an ad, send distinct Idempotency-Keys (or vary the body, e.g. the name).

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :idempotency_key (String)

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

Returns:

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

    UpdateAd200Response data, response status code and response headers



113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 113

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
  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.boost_post, the character length must be smaller than or equal to 255.'
  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
  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(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:



176
177
178
179
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 176

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:



186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 186

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. Idempotency: send an Idempotency-Key header to make retries safe.

Parameters:

Options Hash (opts):

  • :idempotency_key (String)

    Optional client-generated unique key (e.g. a UUID) that makes retries safe. Same key + same body replays the original response; same key + different body → 422; key still processing → 409. Only 2xx responses are stored, so a request that failed with a 4xx can be retried with a corrected body under the SAME key.

Returns:



245
246
247
248
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 245

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. Idempotency: send an `Idempotency-Key` header to make retries safe.

Parameters:

Options Hash (opts):

  • :idempotency_key (String)

    Optional client-generated unique key (e.g. a UUID) that makes retries safe. Same key + same body replays the original response; same key + different body → 422; key still processing → 409. Only 2xx responses are stored, so a request that failed with a 4xx can be retried with a corrected body under the SAME key.

Returns:

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

    CreateAdCampaign201Response data, response status code and response headers



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
300
301
302
303
304
305
306
307
308
309
310
311
312
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 256

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
  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_ad_campaign, the character length must be smaller than or equal to 255.'
  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
  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_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 an attach shape via adSetId that adds one new ad to an existing ad set, inheriting its budget, targeting, and schedule (Meta, TikTok, and LinkedIn; on LinkedIn adSetId is the existing Campaign id, and the budget, schedule, targeting and bidding fields must be omitted). 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 retries safe. Same key + same body replays the original response; same key + different body → 422; key still processing → 409.

Returns:



320
321
322
323
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 320

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 an attach shape via adSetId that adds one new ad to an existing ad set, inheriting its budget, targeting, and schedule (Meta, TikTok, and LinkedIn; on LinkedIn adSetId is the existing Campaign id, and the budget, schedule, targeting and bidding fields must be omitted). 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 retries safe. Same key + same body replays the original response; same key + different body → 422; key still processing → 409.

Returns:



331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 331

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:



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

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. Empty campaigns. A campaign with zero ads has no local Ad documents to resolve, so it is invisible to /v1/ads/tree and this endpoint would 404. That state is produced by the two-step create flow (campaign, then ads via existingCampaignId) whenever Meta rejects the ad step. To delete such a shell, send accountId in the body: we skip the local lookup entirely and forward the delete to Meta. accountId is ignored when the campaign does have ads.

Parameters:

  • campaign_id (String)

    Platform campaign ID

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

    the optional parameters

Returns:



458
459
460
461
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 458

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`. Empty campaigns. A campaign with zero ads has no local Ad documents to resolve, so it is invisible to `/v1/ads/tree` and this endpoint would 404. That state is produced by the two-step create flow (campaign, then ads via `existingCampaignId`) whenever Meta rejects the ad step. To delete such a shell, send `accountId` in the body: we skip the local lookup entirely and forward the delete to Meta. `accountId` is ignored when the campaign does have ads.

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



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
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 469

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_set(ad_set_id, opts = {}) ⇒ DeleteAdSet200Response

Delete an ad set Deletes the ad set on the platform, cascading to its ads only (never the campaign). Locally, every Ad document under the ad set is marked status: cancelled. Delete is soft on platforms that have no hard delete: LinkedIn moves the campaign to PENDING_DELETION, Pinterest archives the ad group, and X soft-flags the line item. Google removes the ad group. All remain readable for reporting.

Parameters:

  • ad_set_id (String)

    Platform ad set ID

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

    the optional parameters

Returns:



531
532
533
534
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 531

def delete_ad_set(ad_set_id, opts = {})
  data, _status_code, _headers = delete_ad_set_with_http_info(ad_set_id, opts)
  data
end

#delete_ad_set_with_http_info(ad_set_id, opts = {}) ⇒ Array<(DeleteAdSet200Response, Integer, Hash)>

Delete an ad set Deletes the ad set on the platform, cascading to its ads only (never the campaign). Locally, every Ad document under the ad set is marked `status: cancelled`. Delete is soft on platforms that have no hard delete: LinkedIn moves the campaign to `PENDING_DELETION`, Pinterest archives the ad group, and X soft-flags the line item. Google removes the ad group. All remain readable for reporting.

Parameters:

  • ad_set_id (String)

    Platform ad set ID

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

    the optional parameters

Returns:

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

    DeleteAdSet200Response data, response status code and response headers



541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 541

def delete_ad_set_with_http_info(ad_set_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AdCampaignsApi.delete_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.delete_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']

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

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

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

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

  new_options = opts.merge(
    :operation => :"AdCampaignsApi.delete_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(:DELETE, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: AdCampaignsApi#delete_ad_set\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:



404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 404

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

  • :idempotency_key (String)

    Optional client-generated unique key (e.g. a UUID) that makes retries safe. Same key + same body replays the original response; same key + different body → 422; key still processing → 409. Only 2xx responses are stored, so a request that failed with a 4xx can be retried with a corrected body under the SAME key.

  • :duplicate_ad_request (DuplicateAdRequest)

Returns:



596
597
598
599
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 596

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

Options Hash (opts):

  • :idempotency_key (String)

    Optional client-generated unique key (e.g. a UUID) that makes retries safe. Same key + same body replays the original response; same key + different body → 422; key still processing → 409. Only 2xx responses are stored, so a request that failed with a 4xx can be retried with a corrected body under the SAME key.

Returns:



673
674
675
676
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 673

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

Options Hash (opts):

  • :idempotency_key (String)

    Optional client-generated unique key (e.g. a UUID) that makes retries safe. Same key + same body replays the original response; same key + different body → 422; key still processing → 409. Only 2xx responses are stored, so a request that failed with a 4xx can be retried with a corrected body under the SAME key.

Returns:



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

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
  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.duplicate_ad_campaign, the character length must be smaller than or equal to 255.'
  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
  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(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

Options Hash (opts):

  • :idempotency_key (String)

    Optional client-generated unique key (e.g. a UUID) that makes retries safe. Same key + same body replays the original response; same key + different body → 422; key still processing → 409. Only 2xx responses are stored, so a request that failed with a 4xx can be retried with a corrected body under the SAME key.

Returns:



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

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

Options Hash (opts):

  • :idempotency_key (String)

    Optional client-generated unique key (e.g. a UUID) that makes retries safe. Same key + same body replays the original response; same key + different body → 422; key still processing → 409. Only 2xx responses are stored, so a request that failed with a 4xx can be retried with a corrected body under the SAME key.

Returns:

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

    DuplicateAdSet200Response data, response status code and response headers



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
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 766

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
  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.duplicate_ad_set, the character length must be smaller than or equal to 255.'
  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
  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(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):

  • :idempotency_key (String)

    Optional client-generated unique key (e.g. a UUID) that makes retries safe. Same key + same body replays the original response; same key + different body → 422; key still processing → 409. Only 2xx responses are stored, so a request that failed with a 4xx can be retried with a corrected body under the SAME key.

  • :duplicate_ad_request (DuplicateAdRequest)

Returns:

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

    DuplicateAd200Response data, response status code and response headers



608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 608

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
  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.duplicate_ad, the character length must be smaller than or equal to 255.'
  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
  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(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:



833
834
835
836
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 833

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:



898
899
900
901
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 898

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



910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 910

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 = {}) ⇒ AdTreeResponse

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. Deleted objects stay in the tree. Deleting an ad or a campaign is a soft delete: the Ad documents move to status: cancelled and are kept indefinitely, so their historical spend still counts toward the metrics of any date range they fall in. There is no pruning job and no retention window. Filter on status if your view should hide them, but do that after reading the totals, not before.

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)

    One or more platform ad account IDs to scope the tree to (agency profiles connect a whole Business Manager but a workspace usually cares about a subset). Comma-separate for multiple (`?adAccountId=act_1,act_2,act_3`); single value keeps its old shape. Max 50 accounts per request; the plural aliases `adAccountIds` and `platformAdAccountIds` are rejected with a 400 to stop them from silently returning the unfiltered fleet.

  • :page_id (String)

    Meta only: Facebook Page ID. Prunes the tree to ads whose creative is backed by this Page — campaigns and ad sets with no ad on the Page drop out, and rolled-up metrics cover only the Page's ads. Mirrors the same filter on /v1/ads and /v1/ads/campaigns.

  • :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). On its own it affects only the spend/impression numbers overlaid on each node, not which campaigns are returned — pass `hasDelivery` or `minSpend` to also filter the campaign set to this window. Defaults to 90 days ago.

  • :to_date (Date)

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

  • :has_delivery (Boolean)

    Return only campaigns that delivered between `fromDate` and `toDate` — spend above zero, or impressions served at zero spend. Unlike `status`, which reads a campaign's CURRENT state, this filters on what happened inside the window, so a campaign that spent then and is paused today is still returned. Filters the campaign set itself, so `pagination.total` counts only matching campaigns.

  • :min_spend (Float)

    Return only campaigns whose spend between `fromDate` and `toDate` reaches this amount. Expressed in each campaign's OWN currency (the `currency` field on the campaign node): spend is stored per ad account in its native currency and one response can span several. Implies `hasDelivery`; `minSpend=0` applies no filter.

  • :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`, except `reach` on Meta and TikTok: the range total is the platform's de-duplicated value, so daily reach does not sum to it. 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:



985
986
987
988
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 985

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<(AdTreeResponse, 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. Deleted objects stay in the tree. Deleting an ad or a campaign is a soft delete: the Ad documents move to `status: cancelled` and are kept indefinitely, so their historical spend still counts toward the metrics of any date range they fall in. There is no pruning job and no retention window. Filter on `status` if your view should hide them, but do that after reading the totals, not before.

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)

    One or more platform ad account IDs to scope the tree to (agency profiles connect a whole Business Manager but a workspace usually cares about a subset). Comma-separate for multiple (`?adAccountId=act_1,act_2,act_3`); single value keeps its old shape. Max 50 accounts per request; the plural aliases `adAccountIds` and `platformAdAccountIds` are rejected with a 400 to stop them from silently returning the unfiltered fleet.

  • :page_id (String)

    Meta only: Facebook Page ID. Prunes the tree to ads whose creative is backed by this Page — campaigns and ad sets with no ad on the Page drop out, and rolled-up metrics cover only the Page's ads. Mirrors the same filter on /v1/ads and /v1/ads/campaigns.

  • :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). On its own it affects only the spend/impression numbers overlaid on each node, not which campaigns are returned — pass `hasDelivery` or `minSpend` to also filter the campaign set to this window. Defaults to 90 days ago.

  • :to_date (Date)

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

  • :has_delivery (Boolean)

    Return only campaigns that delivered between `fromDate` and `toDate` — spend above zero, or impressions served at zero spend. Unlike `status`, which reads a campaign's CURRENT state, this filters on what happened inside the window, so a campaign that spent then and is paused today is still returned. Filters the campaign set itself, so `pagination.total` counts only matching campaigns.

  • :min_spend (Float)

    Return only campaigns whose spend between `fromDate` and `toDate` reaches this amount. Expressed in each campaign's OWN currency (the `currency` field on the campaign node): spend is stored per ad account in its native currency and one response can span several. Implies `hasDelivery`; `minSpend=0` applies no filter.

  • :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`, except `reach` on Meta and TikTok: the range total is the platform's de-duplicated value, so daily reach does not sum to it. 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<(AdTreeResponse, Integer, Hash)>)

    AdTreeResponse data, response status code and response headers



1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
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
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 1011

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
  if @api_client.config.client_side_validation && !opts[:'min_spend'].nil? && opts[:'min_spend'] < 0
    fail ArgumentError, 'invalid value for "opts[:"min_spend"]" when calling AdCampaignsApi.get_ad_tree, must be greater than or equal to 0.'
  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[:'pageId'] = opts[:'page_id'] if !opts[:'page_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[:'hasDelivery'] = opts[:'has_delivery'] if !opts[:'has_delivery'].nil?
  query_params[:'minSpend'] = opts[:'min_spend'] if !opts[:'min_spend'].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] || 'AdTreeResponse'

  # 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



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

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 = {}) ⇒ AdsTimelineResponse

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:



1117
1118
1119
1120
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 1117

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

    AdsTimelineResponse data, response status code and response headers



1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
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
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 1131

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

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

  • :include_empty (Boolean)

    Meta only. Campaign reads aggregate over ad documents, so a campaign with ZERO ads is normally invisible here — the state the two-step create (campaign, then ads via `existingCampaignId`) leaves behind whenever Meta rejects the ad step. Set true to list those too, with `adCount: 0` and zeroed metrics. Requires `accountId` and `adAccountId`, since an empty campaign has no ad row to resolve a token or ad account from.

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

  • :page_id (String)

    Meta only: Facebook Page ID. Campaigns have no Page of their own, so this keeps campaigns having at least one ad backed by this Page, with adCount and metrics computed over those ads only. Mirrors the same filter on /v1/ads and /v1/ads/tree.

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

  • :has_delivery (Boolean)

    Return only campaigns that delivered between `fromDate` and `toDate` — spend above zero, or impressions served at zero spend. Unlike `status`, which reads a campaign's CURRENT state, this filters on what happened inside the window. Filters the campaign set itself, so `pagination.total` counts only matching campaigns. Mirrors the same filter on /v1/ads/tree.

  • :min_spend (Float)

    Return only campaigns whose spend between `fromDate` and `toDate` reaches this amount, in each campaign's OWN currency (the `currency` field on the campaign). Implies `hasDelivery`; `minSpend=0` applies no filter. Mirrors the same filter on /v1/ads/tree.

Returns:



1206
1207
1208
1209
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 1206

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

  • :include_empty (Boolean)

    Meta only. Campaign reads aggregate over ad documents, so a campaign with ZERO ads is normally invisible here — the state the two-step create (campaign, then ads via `existingCampaignId`) leaves behind whenever Meta rejects the ad step. Set true to list those too, with `adCount: 0` and zeroed metrics. Requires `accountId` and `adAccountId`, since an empty campaign has no ad row to resolve a token or ad account from.

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

  • :page_id (String)

    Meta only: Facebook Page ID. Campaigns have no Page of their own, so this keeps campaigns having at least one ad backed by this Page, with adCount and metrics computed over those ads only. Mirrors the same filter on /v1/ads and /v1/ads/tree.

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

  • :has_delivery (Boolean)

    Return only campaigns that delivered between `fromDate` and `toDate` — spend above zero, or impressions served at zero spend. Unlike `status`, which reads a campaign's CURRENT state, this filters on what happened inside the window. Filters the campaign set itself, so `pagination.total` counts only matching campaigns. Mirrors the same filter on /v1/ads/tree.

  • :min_spend (Float)

    Return only campaigns whose spend between `fromDate` and `toDate` reaches this amount, in each campaign's OWN currency (the `currency` field on the campaign). Implies `hasDelivery`; `minSpend=0` applies no filter. Mirrors the same filter on /v1/ads/tree.

Returns:

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

    ListAdCampaigns200Response data, response status code and response headers



1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
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
1302
1303
1304
1305
1306
1307
1308
1309
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 1229

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

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

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'includeEmpty'] = opts[:'include_empty'] if !opts[:'include_empty'].nil?
  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[:'pageId'] = opts[:'page_id'] if !opts[:'page_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?
  query_params[:'hasDelivery'] = opts[:'has_delivery'] if !opts[:'has_delivery'].nil?
  query_params[:'minSpend'] = opts[:'min_spend'] if !opts[:'min_spend'].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_ad_keywords(opts = {}) ⇒ ListAdKeywords200Response

List Search keywords Returns the Google Search keyword criteria (positive and negative) synced from connected Google Ads accounts, one row per ad-group keyword. Refreshed about once a week per Google Ads customer (the keyword sweep rides the ads discovery pass on a slower slot, to stay inside Google's shared daily API quota), so keywords added on Google can take several days to appear. A customer synced for the first time is populated on the next discovery pass rather than waiting for its weekly slot, and connecting an account or triggering a manual sync refreshes it immediately. Campaign-level negative keywords are not included; only ad-group-level criteria are.

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
  • :account_id (String)

    Social account ID

  • :ad_account_id (String)

    Platform ad account ID (Google customer ID). Mirrors the same filter on /v1/ads.

  • :profile_id (String)

    Profile ID

  • :campaign_id (String)

    Platform campaign ID

  • :ad_set_id (String)

    Platform ad group ID (Google ad group)

  • :status (String)

    Keyword criterion status

  • :match_type (String)
  • :negative (Boolean)

    true = negative keywords only, false = positive only. Omit for both.

  • :search (String)

    Case-insensitive substring match on the keyword text

Returns:



1326
1327
1328
1329
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 1326

def list_ad_keywords(opts = {})
  data, _status_code, _headers = list_ad_keywords_with_http_info(opts)
  data
end

#list_ad_keywords_with_http_info(opts = {}) ⇒ Array<(ListAdKeywords200Response, Integer, Hash)>

List Search keywords Returns the Google Search keyword criteria (positive and negative) synced from connected Google Ads accounts, one row per ad-group keyword. Refreshed about once a week per Google Ads customer (the keyword sweep rides the ads discovery pass on a slower slot, to stay inside Google's shared daily API quota), so keywords added on Google can take several days to appear. A customer synced for the first time is populated on the next discovery pass rather than waiting for its weekly slot, and connecting an account or triggering a manual sync refreshes it immediately. Campaign-level negative keywords are not included; only ad-group-level criteria are.

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
  • :account_id (String)

    Social account ID

  • :ad_account_id (String)

    Platform ad account ID (Google customer ID). Mirrors the same filter on /v1/ads.

  • :profile_id (String)

    Profile ID

  • :campaign_id (String)

    Platform campaign ID

  • :ad_set_id (String)

    Platform ad group ID (Google ad group)

  • :status (String)

    Keyword criterion status

  • :match_type (String)
  • :negative (Boolean)

    true = negative keywords only, false = positive only. Omit for both.

  • :search (String)

    Case-insensitive substring match on the keyword text

Returns:

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

    ListAdKeywords200Response data, response status code and response headers



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
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
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
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 1346

def list_ad_keywords_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AdCampaignsApi.list_ad_keywords ...'
  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_keywords, 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_ad_keywords, 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_ad_keywords, must be greater than or equal to 1.'
  end

  allowable_values = ["active", "paused"]
  if @api_client.config.client_side_validation && opts[:'status'] && !allowable_values.include?(opts[:'status'])
    fail ArgumentError, "invalid value for \"status\", must be one of #{allowable_values}"
  end
  allowable_values = ["exact", "phrase", "broad", "unknown"]
  if @api_client.config.client_side_validation && opts[:'match_type'] && !allowable_values.include?(opts[:'match_type'])
    fail ArgumentError, "invalid value for \"match_type\", must be one of #{allowable_values}"
  end
  if @api_client.config.client_side_validation && !opts[:'search'].nil? && opts[:'search'].to_s.length > 200
    fail ArgumentError, 'invalid value for "opts[:"search"]" when calling AdCampaignsApi.list_ad_keywords, the character length must be smaller than or equal to 200.'
  end

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

  # 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[:'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[:'adSetId'] = opts[:'ad_set_id'] if !opts[:'ad_set_id'].nil?
  query_params[:'status'] = opts[:'status'] if !opts[:'status'].nil?
  query_params[:'matchType'] = opts[:'match_type'] if !opts[:'match_type'].nil?
  query_params[:'negative'] = opts[:'negative'] if !opts[:'negative'].nil?
  query_params[:'search'] = opts[:'search'] if !opts[:'search'].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] || 'ListAdKeywords200Response'

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

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

#list_ads(opts = {}) ⇒ AdsListResponse

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.

  • :page_id (String)

    Meta only: Facebook Page ID. Returns only ads whose creative is backed by this Page (a Meta ad account serves ads for every Page in the Business Manager). Matches each ad's `creative.pageId`; ads with no page signal (rare IG-only creatives) never match. 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:



1444
1445
1446
1447
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 1444

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

#list_ads_with_http_info(opts = {}) ⇒ Array<(AdsListResponse, 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.

  • :page_id (String)

    Meta only: Facebook Page ID. Returns only ads whose creative is backed by this Page (a Meta ad account serves ads for every Page in the Business Manager). Matches each ad's `creative.pageId`; ads with no page signal (rare IG-only creatives) never match. 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<(AdsListResponse, Integer, Hash)>)

    AdsListResponse 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
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 1468

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[:'pageId'] = opts[:'page_id'] if !opts[:'page_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] || 'AdsListResponse'

  # 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). - Google: status, budget, and KEYWORD edits via targeting.keywords / targeting.negativeKeywords — each list you send becomes the FULL new set of its kind on the ad group (criteria not in the list are removed); a kind left out is untouched. Any other targeting field returns 400: Google cannot mutate broad targeting post-create without recreating the campaign. creative returns 501. - Pinterest / X / LinkedIn / 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:



1553
1554
1555
1556
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 1553

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. Send at least one of budget, bidStrategy, name or platformSpecificData. An unsupported field is always an error, never a silent drop. | Body field | Meta | Google | Others | |---|---|---|---| | bidStrategy | Yes | Yes | 501 | | bidAmount, roasAverageFloor | 400 — ad-set level | Yes | 400 | | budget (CBO; ABO returns 409) | Yes | 501 | 501 | | name | Yes | 501 | 501 | | platformSpecificData.spendCap | Yes | 400 | 400 | | accountId (empty campaigns) | Yes | - | - | Google maps the shared enum onto its own strategies: LOWEST_COST_WITHOUT_CAP to Maximize Clicks, LOWEST_COST_WITH_BID_CAP to Maximize Clicks with a max CPC (bidAmount), COST_CAP to Target CPA (bidAmount), LOWEST_COST_WITH_MIN_ROAS to Target ROAS (roasAverageFloor). A campaign on a PORTFOLIO bidding strategy is rejected: detach it in Google Ads first, since it is shared across campaigns. accountId forwards the update straight to Meta for a campaign with zero ads, which would otherwise 404; the response then carries updated: 0.

Parameters:

  • campaign_id (String)

    Platform campaign ID

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

    the optional parameters

Returns:



1627
1628
1629
1630
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 1627

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 Writes the campaign's own on/off switch, then lets the platform cascade delivery to its ad sets and ads. Makes one platform API call, not one per ad. The switch is always written, whatever delivery status the ads underneath report: an ad still in review does not block resuming its campaign. The echoed status is the confirmation that it landed. updated / skipped describe only the ads whose own stored status CHANGED alongside it, so updated: 0 is a normal successful response, not a no-op. Ads are skipped when they are in a terminal status (rejected, completed, cancelled), already in the target state, or switched on but not yet delivering — the last group keeps its pending_review / error status until the platform reports what it became. skippedReasons names which case applies. On Meta this flips the campaign only. An ad set paused in its own right stays paused, so pair this with PUT /v1/ads/ad-sets/adSetId/status when you also need the ad set switched back on.

Parameters:

  • campaign_id (String)

    Platform campaign ID

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

    the optional parameters

Returns:



1701
1702
1703
1704
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 1701

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 Writes the campaign's own on/off switch, then lets the platform cascade delivery to its ad sets and ads. Makes one platform API call, not one per ad. The switch is always written, whatever delivery status the ads underneath report: an ad still in review does not block resuming its campaign. The echoed `status` is the confirmation that it landed. `updated` / `skipped` describe only the ads whose own stored status CHANGED alongside it, so `updated: 0` is a normal successful response, not a no-op. Ads are skipped when they are in a terminal status (rejected, completed, cancelled), already in the target state, or switched on but not yet delivering — the last group keeps its `pending_review` / `error` status until the platform reports what it became. `skippedReasons` names which case applies. On Meta this flips the campaign only. An ad set paused in its own right stays paused, so pair this with PUT /v1/ads/ad-sets/adSetId/status when you also need the ad set switched back on.

Parameters:

  • campaign_id (String)

    Platform campaign ID

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

    the optional parameters

Returns:



1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 1712

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. Send at least one of `budget`, `bidStrategy`, `name` or `platformSpecificData`. An unsupported field is always an error, never a silent drop. | Body field | Meta | Google | Others | |---|---|---|---| | `bidStrategy` | Yes | Yes | 501 | | `bidAmount`, `roasAverageFloor` | 400 — ad-set level | Yes | 400 | | `budget` (CBO; ABO returns 409) | Yes | 501 | 501 | | `name` | Yes | 501 | 501 | | `platformSpecificData.spendCap` | Yes | 400 | 400 | | `accountId` (empty campaigns) | Yes | - | - | Google maps the shared enum onto its own strategies: `LOWEST_COST_WITHOUT_CAP` to Maximize Clicks, `LOWEST_COST_WITH_BID_CAP` to Maximize Clicks with a max CPC (`bidAmount`), `COST_CAP` to Target CPA (`bidAmount`), `LOWEST_COST_WITH_MIN_ROAS` to Target ROAS (`roasAverageFloor`). A campaign on a PORTFOLIO bidding strategy is rejected: detach it in Google Ads first, since it is shared across campaigns. `accountId` forwards the update straight to Meta for a campaign with zero ads, which would otherwise 404; the response then carries `updated: 0`.

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



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
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 1638

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, Meta value-rule-set attach/detach, and Meta-only post-launch delivery settings via platformSpecificData. At least one updatable field is required. Value rule sets (Meta only, see /v1/ads/value-rule-sets): - ATTACH or REPLACE: send valueRuleSetId. Attachment is driven by the id's presence, so valueRulesApplied: true is optional. Sending a different id replaces the previous association; there is no separate replace call. - DETACH: send valueRulesApplied: false and OMIT valueRuleSetId. - Sending valueRulesApplied: false TOGETHER with valueRuleSetId returns 400 mutually_exclusive_fields. This is deliberate: Meta attaches the rule set whenever value_rule_set_id is present, even with value_rules_applied false, so echoing stored state while asking to detach would silently keep the bid adjustments live. - Eligibility: only ad sets on LOWEST_COST_WITHOUT_CAP or COST_CAP. Meta rejects the rest server-side. - Read back with GET /v1/ads/ad-sets/{adSetId}?fields=value_rule_set_id. Meta does not document value_rules_applied as a readable ad-set field, so the boolean cannot be read back. 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). - Meta only: send bidAmount WITHOUT bidStrategy to change the cap amount on an ad set under a COST_CAP / LOWEST_COST_WITH_BID_CAP parent campaign, leaving the strategy itself (inherited from the campaign) untouched. roasAverageFloor without bidStrategy is rejected (it has no meaning outside LOWEST_COST_WITH_MIN_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:



1775
1776
1777
1778
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 1775

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. On Meta and LinkedIn this writes the ad set's own on/off switch (Meta: configured_status), whatever delivery status its ads report — an ad still in review does not block resuming its ad set. The echoed status is the confirmation that it landed. Where the platform has no ad-set switch (TikTok and others) the toggle is emulated by flipping the child ads; a call with no actionable ad then writes nothing and returns a message with no status. updated / skipped describe only the ads whose own stored status CHANGED alongside the switch, so updated: 0 is a normal successful response. See skippedReasons for which of the three cases applies (terminal, already in the target state, or switched on but not yet delivering). A campaign created paused needs its campaign resumed as well: pair this with PUT /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:



1849
1850
1851
1852
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 1849

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. On Meta and LinkedIn this writes the ad set's own on/off switch (Meta: `configured_status`), whatever delivery status its ads report — an ad still in review does not block resuming its ad set. The echoed `status` is the confirmation that it landed. Where the platform has no ad-set switch (TikTok and others) the toggle is emulated by flipping the child ads; a call with no actionable ad then writes nothing and returns a `message` with no `status`. `updated` / `skipped` describe only the ads whose own stored status CHANGED alongside the switch, so `updated: 0` is a normal successful response. See `skippedReasons` for which of the three cases applies (terminal, already in the target state, or switched on but not yet delivering). A campaign created paused needs its campaign resumed as well: pair this with PUT /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:



1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 1860

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, Meta value-rule-set attach/detach, and Meta-only post-launch delivery settings via `platformSpecificData`. At least one updatable field is required. Value rule sets (Meta only, see `/v1/ads/value-rule-sets`): - ATTACH or REPLACE: send `valueRuleSetId`. Attachment is driven by the id's presence, so `valueRulesApplied: true` is optional. Sending a different id replaces the previous association; there is no separate replace call. - DETACH: send `valueRulesApplied: false` and OMIT `valueRuleSetId`. - Sending `valueRulesApplied: false` TOGETHER with `valueRuleSetId` returns 400 `mutually_exclusive_fields`. This is deliberate: Meta attaches the rule set whenever `value_rule_set_id` is present, even with `value_rules_applied` false, so echoing stored state while asking to detach would silently keep the bid adjustments live. - Eligibility: only ad sets on `LOWEST_COST_WITHOUT_CAP` or `COST_CAP`. Meta rejects the rest server-side. - Read back with `GET /v1/ads/ad-sets/adSetId?fields=value_rule_set_id`. Meta does not document `value_rules_applied` as a readable ad-set field, so the boolean cannot be read back. 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). - Meta only: send `bidAmount` WITHOUT `bidStrategy` to change the cap amount on an ad set under a COST_CAP / LOWEST_COST_WITH_BID_CAP parent campaign, leaving the strategy itself (inherited from the campaign) untouched. `roasAverageFloor` without `bidStrategy` is rejected (it has no meaning outside LOWEST_COST_WITH_MIN_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



1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 1786

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:



1923
1924
1925
1926
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 1923

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



1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 1934

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`). - Google: status, budget, and KEYWORD edits via `targeting.keywords` / `targeting.negativeKeywords` — each list you send becomes the FULL new set of its kind on the ad group (criteria not in the list are removed); a kind left out is untouched. Any other `targeting` field returns 400: Google cannot mutate broad targeting post-create without recreating the campaign. `creative` returns 501. - Pinterest / X / LinkedIn / 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



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
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
# File 'lib/zernio-sdk/api/ad_campaigns_api.rb', line 1564

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