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. promotion and creativeFeatures are Meta-only. Omitted settings are preserved from the live creative, including full rebuilds. Send promotion: null to remove the explicit offer from the replacement. 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



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

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

#body ⇒ Object

Returns the value of attribute body.



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

def body
  @body
end

#business_name ⇒ Object

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



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

def business_name
  @business_name
end

#call_to_action ⇒ Object

Returns the value of attribute call_to_action.



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

def call_to_action
  @call_to_action
end

#creative_features ⇒ Object

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 enhancement; use the separate promotion field for an explicit offer. The deprecated standard_enhancements bundle is rejected by Meta.



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

def creative_features
  @creative_features
end

#description ⇒ Object

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



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

def description
  @description
end

#existing_creative_id ⇒ Object

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



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

def existing_creative_id
  @existing_creative_id
end

#headline ⇒ Object

Meta and LinkedIn (TikTok has no headline slot)



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

def headline
  @headline
end

#image_url ⇒ Object

Returns the value of attribute image_url.



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

def image_url
  @image_url
end

Returns the value of attribute link_url.



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

def link_url
  @link_url
end

#long_headline ⇒ Object

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



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

def long_headline
  @long_headline
end

#promotion ⇒ Object

Returns the value of attribute promotion.



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

def promotion
  @promotion
end

#square_image_url ⇒ Object

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



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

def square_image_url
  @square_image_url
end

#video_id ⇒ Object

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



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

def video_id
  @video_id
end

#video_url ⇒ Object

Returns the value of attribute video_url.



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

def video_url
  @video_url
end

Class Method Details

.acceptable_attribute_map ⇒ Object

Returns attribute mapping this model knows about



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

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributes ⇒ Object

Returns all the JSON keys this model knows about



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

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_map ⇒ Object

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



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

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



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

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_nullable ⇒ Object

List of attributes with nullable: true



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

def self.openapi_nullable
  Set.new([
  ])
end

.openapi_types ⇒ Object

Attribute type mapping.



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

def self.openapi_types
  {
    :'promotion' => :'MetaPromotion',
    :'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



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

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


321
322
323
# File 'lib/zernio-sdk/models/update_ad_request_creative.rb', line 321

def eql?(o)
  self == o
end

#hash ⇒ Integer

Calculates hash code according to all attributes.

Returns:

  • (Integer) —

    Hash code



327
328
329
# File 'lib/zernio-sdk/models/update_ad_request_creative.rb', line 327

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_properties ⇒ Object

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

Returns:

  • Array for valid properties with the reasons



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

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_hash ⇒ Hash

Returns the object in the form of hash

Returns:

  • (Hash) —

    Returns the object in the form of hash



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

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



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

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