Class: Zernio::CreateAdCreativeRequest

Inherits:
ApiModelBase show all
Defined in:
lib/zernio-sdk/models/create_ad_creative_request.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 = {}) ⇒ CreateAdCreativeRequest

Initializes the object

Parameters:

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

    Model attributes in the form of hash



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

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `Zernio::CreateAdCreativeRequest` 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::CreateAdCreativeRequest`. 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?(:'account_id')
    self. = attributes[:'account_id']
  else
    self. = nil
  end

  if attributes.key?(:'ad_account_id')
    self. = attributes[:'ad_account_id']
  else
    self. = nil
  end

  if attributes.key?(:'headline')
    self.headline = attributes[:'headline']
  else
    self.headline = nil
  end

  if attributes.key?(:'body')
    self.body = attributes[:'body']
  else
    self.body = nil
  end

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

  if attributes.key?(:'call_to_action')
    self.call_to_action = attributes[:'call_to_action']
  else
    self.call_to_action = 'LEARN_MORE'
  end

  if attributes.key?(:'link_url')
    self.link_url = attributes[:'link_url']
  else
    self.link_url = nil
  end

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

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

  if attributes.key?(:'carousel_cards')
    if (value = attributes[:'carousel_cards']).is_a?(Array)
      self.carousel_cards = value
    end
  end

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

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

  if attributes.key?(:'creative_features')
    if (value = attributes[:'creative_features']).is_a?(Hash)
      self.creative_features = value
    end
  end

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

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

Instance Attribute Details

#account_idObject

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



19
20
21
# File 'lib/zernio-sdk/models/create_ad_creative_request.rb', line 19

def 
  @account_id
end

#ad_account_idObject

Platform ad account id (Meta act_, Google customer id, LinkedIn account id, ...).



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

def 
  
end

#ai_disclosureObject

Meta only. Meta's "Ad includes media created or edited with AI" disclosure, the checkbox in Ads Manager, stored on the creative as generative_asset_spec.transparency_metadata.self_disclosure. OPT_IN checks it, OPT_OUT explicitly declares no AI media, omitted leaves Meta's default. Applied to each new creative, including standalone, creatives and attach shapes, and preserved when a creative is rebuilt. This sets the disclosure on the ad; whether and when the viewer-facing label renders is Meta's decision.



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

def ai_disclosure
  @ai_disclosure
end

#bodyObject

Primary text



27
28
29
# File 'lib/zernio-sdk/models/create_ad_creative_request.rb', line 27

def body
  @body
end

#call_to_actionObject

CTA type (same whitelist as POST /v1/ads/create).



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

def call_to_action
  @call_to_action
end

Returns the value of attribute carousel_cards.



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

def carousel_cards
  @carousel_cards
end

#creative_featuresObject

Meta only. Applied to each new creative, including standalone and attach shapes. With creatives, these are defaults; an item replaces the whole feature map, including an empty map. auto_promotion_tag is an Advantage+ enhancement, not the Ads Manager Promotion setting.



52
53
54
# File 'lib/zernio-sdk/models/create_ad_creative_request.rb', line 52

def creative_features
  @creative_features
end

#descriptionObject

Link description below the headline; omitted = Meta scrapes the destination's OG description.



30
31
32
# File 'lib/zernio-sdk/models/create_ad_creative_request.rb', line 30

def description
  @description
end

#headlineObject

Returns the value of attribute headline.



24
25
26
# File 'lib/zernio-sdk/models/create_ad_creative_request.rb', line 24

def headline
  @headline
end

#image_hashObject

Existing library image hash (POST /v1/ads/images or GET /v1/ads/images).



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

def image_hash
  @image_hash
end

#image_urlObject

Publicly reachable image; uploaded to the account's library server-side.



38
39
40
# File 'lib/zernio-sdk/models/create_ad_creative_request.rb', line 38

def image_url
  @image_url
end

Returns the value of attribute link_url.



35
36
37
# File 'lib/zernio-sdk/models/create_ad_creative_request.rb', line 35

def link_url
  @link_url
end

#multi_advertiserObject

Meta only. Multi-advertiser ads: whether Meta may show this ad alongside other advertisers' in one unit. Meta auto-enrols since Aug 2024, so send OPT_OUT to leave. It is a top-level creative field, NOT a creativeFeatures key, and Meta rejects it there.



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

def multi_advertiser
  @multi_advertiser
end

#promotionObject

Not supported. Meta validates creative_sourcing_spec.promotion_metadata_spec on the create call and then discards it, so a Promotion set through the Marketing API never reaches the creative. Any object is rejected with 400 invalid_field_value. Send null or omit the field, and set the Promotion on the ad in Ads Manager. Verified on 2026-09-11 across Graph v19.0 to v25.0 and every write path.



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

def promotion
  @promotion
end

#url_tagsObject

Appended to every outbound URL (e.g. utm_source=fb).



46
47
48
# File 'lib/zernio-sdk/models/create_ad_creative_request.rb', line 46

def url_tags
  @url_tags
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



104
105
106
# File 'lib/zernio-sdk/models/create_ad_creative_request.rb', line 104

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



109
110
111
# File 'lib/zernio-sdk/models/create_ad_creative_request.rb', line 109

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

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



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/zernio-sdk/models/create_ad_creative_request.rb', line 83

def self.attribute_map
  {
    :'account_id' => :'accountId',
    :'ad_account_id' => :'adAccountId',
    :'headline' => :'headline',
    :'body' => :'body',
    :'description' => :'description',
    :'call_to_action' => :'callToAction',
    :'link_url' => :'linkUrl',
    :'image_url' => :'imageUrl',
    :'image_hash' => :'imageHash',
    :'carousel_cards' => :'carouselCards',
    :'url_tags' => :'urlTags',
    :'promotion' => :'promotion',
    :'creative_features' => :'creativeFeatures',
    :'multi_advertiser' => :'multiAdvertiser',
    :'ai_disclosure' => :'aiDisclosure'
  }
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



441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
# File 'lib/zernio-sdk/models/create_ad_creative_request.rb', line 441

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



135
136
137
138
139
# File 'lib/zernio-sdk/models/create_ad_creative_request.rb', line 135

def self.openapi_nullable
  Set.new([
    :'promotion',
  ])
end

.openapi_typesObject

Attribute type mapping.



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/zernio-sdk/models/create_ad_creative_request.rb', line 114

def self.openapi_types
  {
    :'account_id' => :'String',
    :'ad_account_id' => :'String',
    :'headline' => :'String',
    :'body' => :'String',
    :'description' => :'String',
    :'call_to_action' => :'String',
    :'link_url' => :'String',
    :'image_url' => :'String',
    :'image_hash' => :'String',
    :'carousel_cards' => :'Array<CreateAdCreativeRequestCarouselCardsInner>',
    :'url_tags' => :'String',
    :'promotion' => :'Object',
    :'creative_features' => :'Hash<String, String>',
    :'multi_advertiser' => :'String',
    :'ai_disclosure' => :'String'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
# File 'lib/zernio-sdk/models/create_ad_creative_request.rb', line 406

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
       == o. &&
       == o. &&
      headline == o.headline &&
      body == o.body &&
      description == o.description &&
      call_to_action == o.call_to_action &&
      link_url == o.link_url &&
      image_url == o.image_url &&
      image_hash == o.image_hash &&
      carousel_cards == o.carousel_cards &&
      url_tags == o.url_tags &&
      promotion == o.promotion &&
      creative_features == o.creative_features &&
      multi_advertiser == o.multi_advertiser &&
      ai_disclosure == o.ai_disclosure
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


428
429
430
# File 'lib/zernio-sdk/models/create_ad_creative_request.rb', line 428

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



434
435
436
# File 'lib/zernio-sdk/models/create_ad_creative_request.rb', line 434

def hash
  [, , headline, body, description, call_to_action, link_url, image_url, image_hash, carousel_cards, url_tags, promotion, creative_features, multi_advertiser, ai_disclosure].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



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

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  if @account_id.nil?
    invalid_properties.push('invalid value for "account_id", account_id cannot be nil.')
  end

  if .nil?
    invalid_properties.push('invalid value for "ad_account_id", ad_account_id cannot be nil.')
  end

  if @headline.nil?
    invalid_properties.push('invalid value for "headline", headline cannot be nil.')
  end

  if @headline.to_s.length > 255
    invalid_properties.push('invalid value for "headline", the character length must be smaller than or equal to 255.')
  end

  if @body.nil?
    invalid_properties.push('invalid value for "body", body cannot be nil.')
  end

  if !@description.nil? && @description.to_s.length > 255
    invalid_properties.push('invalid value for "description", the character length must be smaller than or equal to 255.')
  end

  if @link_url.nil?
    invalid_properties.push('invalid value for "link_url", link_url cannot be nil.')
  end

  if !@carousel_cards.nil? && @carousel_cards.length > 10
    invalid_properties.push('invalid value for "carousel_cards", number of items must be less than or equal to 10.')
  end

  if !@carousel_cards.nil? && @carousel_cards.length < 2
    invalid_properties.push('invalid value for "carousel_cards", number of items must be greater than or equal to 2.')
  end

  invalid_properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



463
464
465
466
467
468
469
470
471
472
473
474
475
# File 'lib/zernio-sdk/models/create_ad_creative_request.rb', line 463

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



280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
# File 'lib/zernio-sdk/models/create_ad_creative_request.rb', line 280

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if @account_id.nil?
  return false if .nil?
  return false if @headline.nil?
  return false if @headline.to_s.length > 255
  return false if @body.nil?
  return false if !@description.nil? && @description.to_s.length > 255
  return false if @link_url.nil?
  return false if !@carousel_cards.nil? && @carousel_cards.length > 10
  return false if !@carousel_cards.nil? && @carousel_cards.length < 2
  multi_advertiser_validator = EnumAttributeValidator.new('String', ["OPT_IN", "OPT_OUT"])
  return false unless multi_advertiser_validator.valid?(@multi_advertiser)
  ai_disclosure_validator = EnumAttributeValidator.new('String', ["OPT_IN", "OPT_OUT"])
  return false unless ai_disclosure_validator.valid?(@ai_disclosure)
  true
end