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



127
128
129
130
131
132
133
134
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
# File 'lib/zernio-sdk/models/create_ad_creative_request.rb', line 127

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?(:'creative_features')
    if (value = attributes[:'creative_features']).is_a?(Hash)
      self.creative_features = value
    end
  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

Meta ad account id (act_).



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

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

Advantage+ creative enhancements: partial map of Meta creative feature keys (snake_case) to enroll status, forwarded as degrees_of_freedom_spec.creative_features_spec. Unspecified features default to OPT_OUT.



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

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

#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



92
93
94
# File 'lib/zernio-sdk/models/create_ad_creative_request.rb', line 92

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



97
98
99
# File 'lib/zernio-sdk/models/create_ad_creative_request.rb', line 97

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

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



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/zernio-sdk/models/create_ad_creative_request.rb', line 74

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',
    :'creative_features' => :'creativeFeatures'
  }
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



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

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



120
121
122
123
# File 'lib/zernio-sdk/models/create_ad_creative_request.rb', line 120

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

.openapi_typesObject

Attribute type mapping.



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/zernio-sdk/models/create_ad_creative_request.rb', line 102

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

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



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

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 &&
      creative_features == o.creative_features
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


373
374
375
# File 'lib/zernio-sdk/models/create_ad_creative_request.rb', line 373

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



379
380
381
# File 'lib/zernio-sdk/models/create_ad_creative_request.rb', line 379

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

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
# File 'lib/zernio-sdk/models/create_ad_creative_request.rb', line 208

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_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



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

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



252
253
254
255
256
257
258
259
260
261
262
263
264
# File 'lib/zernio-sdk/models/create_ad_creative_request.rb', line 252

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
  true
end