Class: Zernio::Ad

Inherits:
ApiModelBase show all
Defined in:
lib/zernio-sdk/models/ad.rb

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApiModelBase

_deserialize, #_to_hash, #to_body, #to_s

Constructor Details

#initialize(attributes = {}) ⇒ Ad

Initializes the object

Parameters:

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

    Model attributes in the form of hash



215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
# File 'lib/zernio-sdk/models/ad.rb', line 215

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `Zernio::Ad` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  acceptable_attribute_map = self.class.acceptable_attribute_map
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!acceptable_attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `Zernio::Ad`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

  if attributes.key?(:'_id')
    self._id = attributes[:'_id']
  end

  if attributes.key?(:'name')
    self.name = attributes[:'name']
  end

  if attributes.key?(:'platform')
    self.platform = attributes[:'platform']
  end

  if attributes.key?(:'status')
    self.status = attributes[:'status']
  end

  if attributes.key?(:'configured_status')
    self.configured_status = attributes[:'configured_status']
  end

  if attributes.key?(:'review_status')
    self.review_status = attributes[:'review_status']
  end

  if attributes.key?(:'ad_type')
    self.ad_type = attributes[:'ad_type']
  end

  if attributes.key?(:'goal')
    self.goal = attributes[:'goal']
  end

  if attributes.key?(:'is_external')
    self.is_external = attributes[:'is_external']
  end

  if attributes.key?(:'budget')
    self.budget = attributes[:'budget']
  end

  if attributes.key?(:'metrics')
    self.metrics = attributes[:'metrics']
  end

  if attributes.key?(:'platform_ad_id')
    self.platform_ad_id = attributes[:'platform_ad_id']
  end

  if attributes.key?(:'platform_ad_account_id')
    self. = attributes[:'platform_ad_account_id']
  end

  if attributes.key?(:'platform_campaign_id')
    self.platform_campaign_id = attributes[:'platform_campaign_id']
  end

  if attributes.key?(:'platform_ad_set_id')
    self.platform_ad_set_id = attributes[:'platform_ad_set_id']
  end

  if attributes.key?(:'campaign_name')
    self.campaign_name = attributes[:'campaign_name']
  end

  if attributes.key?(:'ad_set_name')
    self.ad_set_name = attributes[:'ad_set_name']
  end

  if attributes.key?(:'platform_objective')
    self.platform_objective = attributes[:'platform_objective']
  end

  if attributes.key?(:'optimization_goal')
    self.optimization_goal = attributes[:'optimization_goal']
  end

  if attributes.key?(:'platform_ad_account_name')
    self. = attributes[:'platform_ad_account_name']
  end

  if attributes.key?(:'platform_created_at')
    self.platform_created_at = attributes[:'platform_created_at']
  end

  if attributes.key?(:'bid_strategy')
    self.bid_strategy = attributes[:'bid_strategy']
  end

  if attributes.key?(:'bid_amount')
    self.bid_amount = attributes[:'bid_amount']
  end

  if attributes.key?(:'roas_average_floor')
    self.roas_average_floor = attributes[:'roas_average_floor']
  end

  if attributes.key?(:'promoted_object')
    self.promoted_object = attributes[:'promoted_object']
  end

  if attributes.key?(:'creative')
    self.creative = attributes[:'creative']
  end

  if attributes.key?(:'targeting')
    self.targeting = attributes[:'targeting']
  end

  if attributes.key?(:'schedule')
    self.schedule = attributes[:'schedule']
  end

  if attributes.key?(:'rejection_reason')
    self.rejection_reason = attributes[:'rejection_reason']
  end

  if attributes.key?(:'created_at')
    self.created_at = attributes[:'created_at']
  end

  if attributes.key?(:'updated_at')
    self.updated_at = attributes[:'updated_at']
  end
end

Instance Attribute Details

#_idObject

Returns the value of attribute _id.



18
19
20
# File 'lib/zernio-sdk/models/ad.rb', line 18

def _id
  @_id
end

#ad_set_nameObject

Returns the value of attribute ad_set_name.



55
56
57
# File 'lib/zernio-sdk/models/ad.rb', line 55

def ad_set_name
  @ad_set_name
end

#ad_typeObject

Returns the value of attribute ad_type.



33
34
35
# File 'lib/zernio-sdk/models/ad.rb', line 33

def ad_type
  @ad_type
end

#bid_amountObject

Bid cap in WHOLE currency units of the ad account (USD: 5 = $5.00; JPY: 100 = ¥100). Populated when bidStrategy is LOWEST_COST_WITH_BID_CAP or COST_CAP. null for auto-bid (LOWEST_COST_WITHOUT_CAP). - Meta source: bid_amount on the ad set (smallest-denomination int, decoded here). - TikTok source: priority order bid_price -> conversion_bid_price -> deep_cpa_bid (whichever is set on the ad group). TikTok stores all three in whole currency units. Source: facebook-business-sdk-codegen api_specs/specs/AdSet.json (bid_amount).



72
73
74
# File 'lib/zernio-sdk/models/ad.rb', line 72

def bid_amount
  @bid_amount
end

#bid_strategyObject

Returns the value of attribute bid_strategy.



69
70
71
# File 'lib/zernio-sdk/models/ad.rb', line 69

def bid_strategy
  @bid_strategy
end

#budgetObject

Returns the value of attribute budget.



41
42
43
# File 'lib/zernio-sdk/models/ad.rb', line 41

def budget
  @budget
end

#campaign_nameObject

Returns the value of attribute campaign_name.



53
54
55
# File 'lib/zernio-sdk/models/ad.rb', line 53

def campaign_name
  @campaign_name
end

#configured_statusObject

The ad's own on/off toggle as configured on the platform (Meta configured_status: ACTIVE / PAUSED), unaffected by ancestor (ad set / campaign) pauses. Distinct from status, which is the ancestor-cascaded delivery status. Only present for Meta ads synced after this field was added.



28
29
30
# File 'lib/zernio-sdk/models/ad.rb', line 28

def configured_status
  @configured_status
end

#created_atObject

Returns the value of attribute created_at.



88
89
90
# File 'lib/zernio-sdk/models/ad.rb', line 88

def created_at
  @created_at
end

#creativeObject

Returns the value of attribute creative.



79
80
81
# File 'lib/zernio-sdk/models/ad.rb', line 79

def creative
  @creative
end

#goalObject

Available goals vary by platform. Meta (Facebook/Instagram) supports all 9 (incl. lead_conversion = website pixel lead optimization and catalog_sales = Advantage+ catalog ads). TikTok supports the 7 non-lead_conversion goals. LinkedIn supports all except app_promotion / lead_conversion. Twitter/X supports engagement, traffic, awareness, video_views, app_promotion. Pinterest and Google Ads support only engagement, traffic, awareness, video_views.



36
37
38
# File 'lib/zernio-sdk/models/ad.rb', line 36

def goal
  @goal
end

#is_externalObject

True for ads synced from platform ad managers



39
40
41
# File 'lib/zernio-sdk/models/ad.rb', line 39

def is_external
  @is_external
end

#metricsObject

Returns the value of attribute metrics.



43
44
45
# File 'lib/zernio-sdk/models/ad.rb', line 43

def metrics
  @metrics
end

#nameObject

Returns the value of attribute name.



20
21
22
# File 'lib/zernio-sdk/models/ad.rb', line 20

def name
  @name
end

#optimization_goalObject

Meta ad set optimization goal (e.g. OFFSITE_CONVERSIONS, VALUE, LEAD_GENERATION, LINK_CLICKS). Only present for Meta ads.



61
62
63
# File 'lib/zernio-sdk/models/ad.rb', line 61

def optimization_goal
  @optimization_goal
end

#platformObject

Returns the value of attribute platform.



22
23
24
# File 'lib/zernio-sdk/models/ad.rb', line 22

def platform
  @platform
end

#platform_ad_account_idObject

Returns the value of attribute platform_ad_account_id.



47
48
49
# File 'lib/zernio-sdk/models/ad.rb', line 47

def 
  @platform_ad_account_id
end

#platform_ad_account_nameObject

Human-readable advertiser/account name (Meta AdAccount.name, TikTok advertiser_name, LinkedIn / X / Pinterest equivalents). Refreshed every sync so platform-side renames propagate within one cycle. null when the platform doesn't return a name or the sync hasn't run yet.



64
65
66
# File 'lib/zernio-sdk/models/ad.rb', line 64

def 
  @platform_ad_account_name
end

#platform_ad_idObject

Returns the value of attribute platform_ad_id.



45
46
47
# File 'lib/zernio-sdk/models/ad.rb', line 45

def platform_ad_id
  @platform_ad_id
end

#platform_ad_set_idObject

Returns the value of attribute platform_ad_set_id.



51
52
53
# File 'lib/zernio-sdk/models/ad.rb', line 51

def platform_ad_set_id
  @platform_ad_set_id
end

#platform_campaign_idObject

Returns the value of attribute platform_campaign_id.



49
50
51
# File 'lib/zernio-sdk/models/ad.rb', line 49

def platform_campaign_id
  @platform_campaign_id
end

#platform_created_atObject

Platform-reported creation timestamp (Meta created_time, TikTok create_time). Distinct from createdAt which reflects when Zernio first synced the doc — for sort/filter by "when the ad was actually created on the platform", read this field. null for legacy ads synced before this field was added; aggregations fall back to createdAt in that case.



67
68
69
# File 'lib/zernio-sdk/models/ad.rb', line 67

def platform_created_at
  @platform_created_at
end

#platform_objectiveObject

Raw Meta campaign objective (e.g. OUTCOME_SALES, OUTCOME_LEADS, OUTCOME_TRAFFIC). Only present for Meta ads.



58
59
60
# File 'lib/zernio-sdk/models/ad.rb', line 58

def platform_objective
  @platform_objective
end

Returns the value of attribute promoted_object.



77
78
79
# File 'lib/zernio-sdk/models/ad.rb', line 77

def promoted_object
  @promoted_object
end

#rejection_reasonObject

Returns the value of attribute rejection_reason.



86
87
88
# File 'lib/zernio-sdk/models/ad.rb', line 86

def rejection_reason
  @rejection_reason
end

#review_statusObject

Platform review state of this ad, independent of delivery status / configuredStatus. Absent when the platform reports no review signal.



31
32
33
# File 'lib/zernio-sdk/models/ad.rb', line 31

def review_status
  @review_status
end

#roas_average_floorObject

Minimum ROAS as a decimal multiplier (2.0 = 2.0x ROAS). Populated when bidStrategy is LOWEST_COST_WITH_MIN_ROAS. - Meta source: decoded from bid_constraints.roas_average_floor (Meta stores as fixed-point int × 10000; we return the decimal). - TikTok source: roas_bid on the ad group (already a decimal). Source: facebook-business-sdk-codegen api_specs/specs/AdCampaignBidConstraint.json.



75
76
77
# File 'lib/zernio-sdk/models/ad.rb', line 75

def roas_average_floor
  @roas_average_floor
end

#scheduleObject

Returns the value of attribute schedule.



84
85
86
# File 'lib/zernio-sdk/models/ad.rb', line 84

def schedule
  @schedule
end

#statusObject

Delivery status. Derived from the platform effective_status, so it inherits ancestor pauses (an ACTIVE ad under a PAUSED campaign reads paused). For the ad's own on/off toggle use configuredStatus; for the review state use reviewStatus.



25
26
27
# File 'lib/zernio-sdk/models/ad.rb', line 25

def status
  @status
end

#targetingObject

The ad set's targeting (age, gender, geo, interests, placements, audience inclusions/exclusions). For ads created through Zernio this is the spec you supplied. For external ads (synced from Meta Ads Manager, isExternal: true) targeting lives at the ad set and isn't stored at ingest, so on the first GET /v1/ads/{adId} Zernio resolves it live from Meta and caches it on the ad; the value is then Meta's raw targeting shape (snake_case, e.g. geo_locations, age_min), the same object Ads Manager shows. May be absent if the ad set exposes no targeting or the lookup fails.



82
83
84
# File 'lib/zernio-sdk/models/ad.rb', line 82

def targeting
  @targeting
end

#updated_atObject

Returns the value of attribute updated_at.



90
91
92
# File 'lib/zernio-sdk/models/ad.rb', line 90

def updated_at
  @updated_at
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



152
153
154
# File 'lib/zernio-sdk/models/ad.rb', line 152

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



157
158
159
# File 'lib/zernio-sdk/models/ad.rb', line 157

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



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
# File 'lib/zernio-sdk/models/ad.rb', line 115

def self.attribute_map
  {
    :'_id' => :'_id',
    :'name' => :'name',
    :'platform' => :'platform',
    :'status' => :'status',
    :'configured_status' => :'configuredStatus',
    :'review_status' => :'reviewStatus',
    :'ad_type' => :'adType',
    :'goal' => :'goal',
    :'is_external' => :'isExternal',
    :'budget' => :'budget',
    :'metrics' => :'metrics',
    :'platform_ad_id' => :'platformAdId',
    :'platform_ad_account_id' => :'platformAdAccountId',
    :'platform_campaign_id' => :'platformCampaignId',
    :'platform_ad_set_id' => :'platformAdSetId',
    :'campaign_name' => :'campaignName',
    :'ad_set_name' => :'adSetName',
    :'platform_objective' => :'platformObjective',
    :'optimization_goal' => :'optimizationGoal',
    :'platform_ad_account_name' => :'platformAdAccountName',
    :'platform_created_at' => :'platformCreatedAt',
    :'bid_strategy' => :'bidStrategy',
    :'bid_amount' => :'bidAmount',
    :'roas_average_floor' => :'roasAverageFloor',
    :'promoted_object' => :'promotedObject',
    :'creative' => :'creative',
    :'targeting' => :'targeting',
    :'schedule' => :'schedule',
    :'rejection_reason' => :'rejectionReason',
    :'created_at' => :'createdAt',
    :'updated_at' => :'updatedAt'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
# File 'lib/zernio-sdk/models/ad.rb', line 458

def self.build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  attributes = attributes.transform_keys(&:to_sym)
  transformed_hash = {}
  openapi_types.each_pair do |key, type|
    if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = nil
    elsif type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[attribute_map[key]].is_a?(Array)
        transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
      end
    elsif !attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
    end
  end
  new(transformed_hash)
end

.openapi_nullableObject

List of attributes with nullable: true



199
200
201
202
203
204
205
206
207
208
209
210
211
# File 'lib/zernio-sdk/models/ad.rb', line 199

def self.openapi_nullable
  Set.new([
    :'configured_status',
    :'metrics',
    :'platform_objective',
    :'optimization_goal',
    :'platform_ad_account_name',
    :'platform_created_at',
    :'bid_strategy',
    :'bid_amount',
    :'roas_average_floor',
  ])
end

.openapi_typesObject

Attribute type mapping.



162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# File 'lib/zernio-sdk/models/ad.rb', line 162

def self.openapi_types
  {
    :'_id' => :'String',
    :'name' => :'String',
    :'platform' => :'String',
    :'status' => :'AdStatus',
    :'configured_status' => :'String',
    :'review_status' => :'AdReviewStatus',
    :'ad_type' => :'String',
    :'goal' => :'String',
    :'is_external' => :'Boolean',
    :'budget' => :'AdBudget',
    :'metrics' => :'AdMetrics',
    :'platform_ad_id' => :'String',
    :'platform_ad_account_id' => :'String',
    :'platform_campaign_id' => :'String',
    :'platform_ad_set_id' => :'String',
    :'campaign_name' => :'String',
    :'ad_set_name' => :'String',
    :'platform_objective' => :'String',
    :'optimization_goal' => :'String',
    :'platform_ad_account_name' => :'String',
    :'platform_created_at' => :'Time',
    :'bid_strategy' => :'BidStrategy',
    :'bid_amount' => :'Float',
    :'roas_average_floor' => :'Float',
    :'promoted_object' => :'AdPromotedObject',
    :'creative' => :'AdCreative',
    :'targeting' => :'Object',
    :'schedule' => :'AdSchedule',
    :'rejection_reason' => :'String',
    :'created_at' => :'Time',
    :'updated_at' => :'Time'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



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
# File 'lib/zernio-sdk/models/ad.rb', line 407

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      _id == o._id &&
      name == o.name &&
      platform == o.platform &&
      status == o.status &&
      configured_status == o.configured_status &&
      review_status == o.review_status &&
      ad_type == o.ad_type &&
      goal == o.goal &&
      is_external == o.is_external &&
      budget == o.budget &&
      metrics == o.metrics &&
      platform_ad_id == o.platform_ad_id &&
       == o. &&
      platform_campaign_id == o.platform_campaign_id &&
      platform_ad_set_id == o.platform_ad_set_id &&
      campaign_name == o.campaign_name &&
      ad_set_name == o.ad_set_name &&
      platform_objective == o.platform_objective &&
      optimization_goal == o.optimization_goal &&
       == o. &&
      platform_created_at == o.platform_created_at &&
      bid_strategy == o.bid_strategy &&
      bid_amount == o.bid_amount &&
      roas_average_floor == o.roas_average_floor &&
      promoted_object == o.promoted_object &&
      creative == o.creative &&
      targeting == o.targeting &&
      schedule == o.schedule &&
      rejection_reason == o.rejection_reason &&
      created_at == o.created_at &&
      updated_at == o.updated_at
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


445
446
447
# File 'lib/zernio-sdk/models/ad.rb', line 445

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



451
452
453
# File 'lib/zernio-sdk/models/ad.rb', line 451

def hash
  [_id, name, platform, status, configured_status, review_status, ad_type, goal, is_external, budget, metrics, platform_ad_id, , platform_campaign_id, platform_ad_set_id, campaign_name, ad_set_name, platform_objective, optimization_goal, , platform_created_at, bid_strategy, bid_amount, roas_average_floor, promoted_object, creative, targeting, schedule, rejection_reason, created_at, updated_at].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



356
357
358
359
360
# File 'lib/zernio-sdk/models/ad.rb', line 356

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  invalid_properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



480
481
482
483
484
485
486
487
488
489
490
491
492
# File 'lib/zernio-sdk/models/ad.rb', line 480

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    if value.nil?
      is_nullable = self.class.openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end

    hash[param] = _to_hash(value)
  end
  hash
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



364
365
366
367
368
369
370
371
372
373
# File 'lib/zernio-sdk/models/ad.rb', line 364

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  platform_validator = EnumAttributeValidator.new('String', ["facebook", "instagram", "tiktok", "linkedin", "pinterest", "google", "twitter", "openai"])
  return false unless platform_validator.valid?(@platform)
  ad_type_validator = EnumAttributeValidator.new('String', ["boost", "standalone"])
  return false unless ad_type_validator.valid?(@ad_type)
  goal_validator = EnumAttributeValidator.new('String', ["engagement", "traffic", "awareness", "video_views", "lead_generation", "lead_conversion", "conversions", "app_promotion", "catalog_sales", "job_applicants"])
  return false unless goal_validator.valid?(@goal)
  true
end