Class: Zernio::CreateStandaloneAdRequestCreativesInner

Inherits:
ApiModelBase
  • Object
show all
Defined in:
lib/zernio-sdk/models/create_standalone_ad_request_creatives_inner.rb

Overview

Each creative must supply EXACTLY ONE of imageUrl (image creative) or video (video creative).

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

Initializes the object

Parameters:

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

    Model attributes in the form of hash



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
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
# File 'lib/zernio-sdk/models/create_standalone_ad_request_creatives_inner.rb', line 106

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

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

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

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

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



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

def body
  @body
end

#call_to_actionObject

Returns the value of attribute call_to_action.



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

def call_to_action
  @call_to_action
end

#descriptionObject

Link description for this ad (link_data.description; video creatives: video_data.link_description). Falls back to the top-level description; when both are omitted Meta scrapes the destination URL's OG description.



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

def description
  @description
end

#headlineObject

Returns the value of attribute headline.



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

def headline
  @headline
end

#image_urlObject

Image creative. Mutually exclusive with video.



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

def image_url
  @image_url
end

Returns the value of attribute link_url.



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

def link_url
  @link_url
end

#nameObject

Exact name for this ad. Falls back to <name> #N (N = 1-based position).



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

def name
  @name
end

#videoObject

Returns the value of attribute video.



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

def video
  @video
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



75
76
77
# File 'lib/zernio-sdk/models/create_standalone_ad_request_creatives_inner.rb', line 75

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



80
81
82
# File 'lib/zernio-sdk/models/create_standalone_ad_request_creatives_inner.rb', line 80

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

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



61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/zernio-sdk/models/create_standalone_ad_request_creatives_inner.rb', line 61

def self.attribute_map
  {
    :'name' => :'name',
    :'headline' => :'headline',
    :'body' => :'body',
    :'description' => :'description',
    :'image_url' => :'imageUrl',
    :'video' => :'video',
    :'link_url' => :'linkUrl',
    :'call_to_action' => :'callToAction'
  }
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



315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
# File 'lib/zernio-sdk/models/create_standalone_ad_request_creatives_inner.rb', line 315

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



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

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

.openapi_typesObject

Attribute type mapping.



85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/zernio-sdk/models/create_standalone_ad_request_creatives_inner.rb', line 85

def self.openapi_types
  {
    :'name' => :'String',
    :'headline' => :'String',
    :'body' => :'String',
    :'description' => :'String',
    :'image_url' => :'String',
    :'video' => :'CreateStandaloneAdRequestCreativesInnerVideo',
    :'link_url' => :'String',
    :'call_to_action' => :'String'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



287
288
289
290
291
292
293
294
295
296
297
298
# File 'lib/zernio-sdk/models/create_standalone_ad_request_creatives_inner.rb', line 287

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      name == o.name &&
      headline == o.headline &&
      body == o.body &&
      description == o.description &&
      image_url == o.image_url &&
      video == o.video &&
      link_url == o.link_url &&
      call_to_action == o.call_to_action
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


302
303
304
# File 'lib/zernio-sdk/models/create_standalone_ad_request_creatives_inner.rb', line 302

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



308
309
310
# File 'lib/zernio-sdk/models/create_standalone_ad_request_creatives_inner.rb', line 308

def hash
  [name, headline, body, description, image_url, video, link_url, call_to_action].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



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

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  if !@name.nil? && @name.to_s.length > 255
    invalid_properties.push('invalid value for "name", the character length must be smaller than or equal to 255.')
  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 @call_to_action.nil?
    invalid_properties.push('invalid value for "call_to_action", call_to_action cannot be nil.')
  end

  invalid_properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



337
338
339
340
341
342
343
344
345
346
347
348
349
# File 'lib/zernio-sdk/models/create_standalone_ad_request_creatives_inner.rb', line 337

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



199
200
201
202
203
204
205
206
207
208
209
210
211
# File 'lib/zernio-sdk/models/create_standalone_ad_request_creatives_inner.rb', line 199

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if !@name.nil? && @name.to_s.length > 255
  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 @call_to_action.nil?
  call_to_action_validator = EnumAttributeValidator.new('String', ["LEARN_MORE", "SHOP_NOW", "SIGN_UP", "BOOK_TRAVEL", "CONTACT_US", "DOWNLOAD", "GET_OFFER", "GET_QUOTE", "SUBSCRIBE", "WATCH_MORE"])
  return false unless call_to_action_validator.valid?(@call_to_action)
  true
end