Class: Zernio::UpdateAdRequestCreative

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

Overview

Replace or patch the ad's creative. Meta, TikTok, and LinkedIn. - Meta: patch-style. Pass any subset: fields you omit are preserved from the live creative, including media (image_hash/video_id are reused, no re-upload) and url_tags. Sending the full set (headline, body, callToAction, linkUrl, imageUrl) rebuilds the creative from scratch instead. Partial patching reads the live object_story_spec, which Meta strips on SHARE / page-post / dark / asset_feed creatives. Those return 422 asking for the full set. A videoUrl/videoId on an image creative is a type change and also needs the full set. existingCreativeId repoints the ad at a creative from GET /v1/ads/creatives and ignores every other field. Meta creatives are immutable, so any change creates a new creative and repoints the ad; the old creative is retained on the ad account for historical reporting. creativeFeatures is Meta-only. Omitted settings are preserved from the live creative, including full rebuilds. A supplied creativeFeatures map overrides individual existing keys. - TikTok: patch-style. Pass any subset; headline is ignored (TikTok creatives have no headline slot). body becomes the in-feed ad_text; linkUrl becomes landing_page_url; videoUrl triggers a fresh upload. description, videoId and existingCreativeId are Meta-only and return 400. - LinkedIn: requires new media (image via imageUrl or video via videoUrl); a text-only creative update returns 400. Uploads the media, creates a new inline media creative on the same campaign, and pauses the old creative (best-effort). The old creative is retained for historical reporting. videoId and existingCreativeId are Meta-only and return 400.

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

Initializes the object

Parameters:

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

    Model attributes in the form of hash



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

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

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

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

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

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

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

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

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

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

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

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

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

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



37
38
39
# File 'lib/zernio-sdk/models/update_ad_request_creative.rb', line 37

def body
  @body
end

#business_nameObject

Google Display only. Replaces the responsive display ad's business name.



32
33
34
# File 'lib/zernio-sdk/models/update_ad_request_creative.rb', line 32

def business_name
  @business_name
end

#call_to_actionObject

Returns the value of attribute call_to_action.



42
43
44
# File 'lib/zernio-sdk/models/update_ad_request_creative.rb', line 42

def call_to_action
  @call_to_action
end

#creative_featuresObject

Meta Advantage+ creative enhancements. Map snake_case feature names to OPT_IN or OPT_OUT; Meta validates supported keys and unspecified features default to OPT_OUT. auto_promotion_tag is an Advantage+ enhancement, not the Ads Manager Promotion setting. The deprecated standard_enhancements bundle is rejected by Meta.



23
24
25
# File 'lib/zernio-sdk/models/update_ad_request_creative.rb', line 23

def creative_features
  @creative_features
end

#descriptionObject

Link description slot (Meta link_data.description / video_data.link_description, LinkedIn creative description).



40
41
42
# File 'lib/zernio-sdk/models/update_ad_request_creative.rb', line 40

def description
  @description
end

#existing_creative_idObject

Meta only. Repoint the ad at an existing library creative (from GET /v1/ads/creatives); all other creative fields are ignored.



54
55
56
# File 'lib/zernio-sdk/models/update_ad_request_creative.rb', line 54

def existing_creative_id
  @existing_creative_id
end

#headlineObject

Meta and LinkedIn (TikTok has no headline slot)



26
27
28
# File 'lib/zernio-sdk/models/update_ad_request_creative.rb', line 26

def headline
  @headline
end

#image_urlObject

Returns the value of attribute image_url.



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

def image_url
  @image_url
end

Returns the value of attribute link_url.



44
45
46
# File 'lib/zernio-sdk/models/update_ad_request_creative.rb', line 44

def link_url
  @link_url
end

#long_headlineObject

Google Display only. Replaces the responsive display ad's long headline.



29
30
31
# File 'lib/zernio-sdk/models/update_ad_request_creative.rb', line 29

def long_headline
  @long_headline
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.



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

def promotion
  @promotion
end

#square_image_urlObject

Google Display only. Uploaded as a new square (1:1) marketing image asset that replaces the current one.



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

def square_image_url
  @square_image_url
end

#video_idObject

Meta only. Reuse an already-uploaded ad video (from POST /v1/ads/videos or GET /v1/ads/videos) instead of re-uploading via videoUrl.



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

def video_id
  @video_id
end

#video_urlObject

Returns the value of attribute video_url.



48
49
50
# File 'lib/zernio-sdk/models/update_ad_request_creative.rb', line 48

def video_url
  @video_url
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



99
100
101
# File 'lib/zernio-sdk/models/update_ad_request_creative.rb', line 99

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



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

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

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



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/zernio-sdk/models/update_ad_request_creative.rb', line 79

def self.attribute_map
  {
    :'promotion' => :'promotion',
    :'creative_features' => :'creativeFeatures',
    :'headline' => :'headline',
    :'long_headline' => :'longHeadline',
    :'business_name' => :'businessName',
    :'square_image_url' => :'squareImageUrl',
    :'body' => :'body',
    :'description' => :'description',
    :'call_to_action' => :'callToAction',
    :'link_url' => :'linkUrl',
    :'image_url' => :'imageUrl',
    :'video_url' => :'videoUrl',
    :'video_id' => :'videoId',
    :'existing_creative_id' => :'existingCreativeId'
  }
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



336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
# File 'lib/zernio-sdk/models/update_ad_request_creative.rb', line 336

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



129
130
131
132
133
# File 'lib/zernio-sdk/models/update_ad_request_creative.rb', line 129

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

.openapi_typesObject

Attribute type mapping.



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/zernio-sdk/models/update_ad_request_creative.rb', line 109

def self.openapi_types
  {
    :'promotion' => :'Object',
    :'creative_features' => :'Hash<String, String>',
    :'headline' => :'String',
    :'long_headline' => :'String',
    :'business_name' => :'String',
    :'square_image_url' => :'String',
    :'body' => :'String',
    :'description' => :'String',
    :'call_to_action' => :'String',
    :'link_url' => :'String',
    :'image_url' => :'String',
    :'video_url' => :'String',
    :'video_id' => :'String',
    :'existing_creative_id' => :'String'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
# File 'lib/zernio-sdk/models/update_ad_request_creative.rb', line 302

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      promotion == o.promotion &&
      creative_features == o.creative_features &&
      headline == o.headline &&
      long_headline == o.long_headline &&
      business_name == o.business_name &&
      square_image_url == o.square_image_url &&
      body == o.body &&
      description == o.description &&
      call_to_action == o.call_to_action &&
      link_url == o.link_url &&
      image_url == o.image_url &&
      video_url == o.video_url &&
      video_id == o.video_id &&
      existing_creative_id == o.existing_creative_id
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


323
324
325
# File 'lib/zernio-sdk/models/update_ad_request_creative.rb', line 323

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



329
330
331
# File 'lib/zernio-sdk/models/update_ad_request_creative.rb', line 329

def hash
  [promotion, creative_features, headline, long_headline, business_name, square_image_url, body, description, call_to_action, link_url, image_url, video_url, video_id, existing_creative_id].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



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

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  if !@long_headline.nil? && @long_headline.to_s.length > 90
    invalid_properties.push('invalid value for "long_headline", the character length must be smaller than or equal to 90.')
  end

  if !@long_headline.nil? && @long_headline.to_s.length < 1
    invalid_properties.push('invalid value for "long_headline", the character length must be greater than or equal to 1.')
  end

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

  if !@business_name.nil? && @business_name.to_s.length < 1
    invalid_properties.push('invalid value for "business_name", the character length must be greater than or equal to 1.')
  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

  invalid_properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



358
359
360
361
362
363
364
365
366
367
368
369
370
# File 'lib/zernio-sdk/models/update_ad_request_creative.rb', line 358

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



240
241
242
243
244
245
246
247
248
# File 'lib/zernio-sdk/models/update_ad_request_creative.rb', line 240

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if !@long_headline.nil? && @long_headline.to_s.length > 90
  return false if !@long_headline.nil? && @long_headline.to_s.length < 1
  return false if !@business_name.nil? && @business_name.to_s.length > 25
  return false if !@business_name.nil? && @business_name.to_s.length < 1
  return false if !@description.nil? && @description.to_s.length > 255
  true
end