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



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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
# File 'lib/zernio-sdk/models/create_ad_creative_request.rb', line 136

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
end

Instance Attribute Details

#account_id ⇒ Object

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

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 
  @ad_account_id
end

#body ⇒ Object

Primary text



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

def body
  @body
end

#call_to_action ⇒ Object

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

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 enhancement; an explicit offer uses promotion.



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

def creative_features
  @creative_features
end

#description ⇒ Object

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

#headline ⇒ Object

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

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

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

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.



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

def multi_advertiser
  @multi_advertiser
end

#promotion ⇒ Object

Returns the value of attribute promotion.



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

def promotion
  @promotion
end

#url_tags ⇒ Object

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

Returns attribute mapping this model knows about



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

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributes ⇒ Object

Returns all the JSON keys this model knows about



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

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_map ⇒ Object

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/create_ad_creative_request.rb', line 79

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'
  }
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



417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
# File 'lib/zernio-sdk/models/create_ad_creative_request.rb', line 417

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



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

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

.openapi_types ⇒ Object

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/create_ad_creative_request.rb', line 109

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' => :'MetaPromotion',
    :'creative_features' => :'Hash<String, String>',
    :'multi_advertiser' => :'String'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object) —

    to be compared



383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
# File 'lib/zernio-sdk/models/create_ad_creative_request.rb', line 383

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
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object) —

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


404
405
406
# File 'lib/zernio-sdk/models/create_ad_creative_request.rb', line 404

def eql?(o)
  self == o
end

#hash ⇒ Integer

Calculates hash code according to all attributes.

Returns:

  • (Integer) —

    Hash code



410
411
412
# File 'lib/zernio-sdk/models/create_ad_creative_request.rb', line 410

def hash
  [, , headline, body, description, call_to_action, link_url, image_url, image_hash, carousel_cards, url_tags, promotion, creative_features, multi_advertiser].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



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

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 @ad_account_id.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_hash ⇒ Hash

Returns the object in the form of hash

Returns:

  • (Hash) —

    Returns the object in the form of hash



439
440
441
442
443
444
445
446
447
448
449
450
451
# File 'lib/zernio-sdk/models/create_ad_creative_request.rb', line 439

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



269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
# File 'lib/zernio-sdk/models/create_ad_creative_request.rb', line 269

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if @account_id.nil?
  return false if @ad_account_id.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)
  true
end