Class: Zernio::CreateAdCreativeRequest

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

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



100
101
102
103
104
105
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
160
161
162
163
164
165
166
167
168
169
170
171
# File 'lib/zernio-sdk/models/create_ad_creative_request.rb', line 100

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

#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



66
67
68
# File 'lib/zernio-sdk/models/create_ad_creative_request.rb', line 66

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



71
72
73
# File 'lib/zernio-sdk/models/create_ad_creative_request.rb', line 71

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

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



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/zernio-sdk/models/create_ad_creative_request.rb', line 49

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



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

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



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

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

.openapi_typesObject

Attribute type mapping.



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

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

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
# File 'lib/zernio-sdk/models/create_ad_creative_request.rb', line 321

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
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


339
340
341
# File 'lib/zernio-sdk/models/create_ad_creative_request.rb', line 339

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



345
346
347
# File 'lib/zernio-sdk/models/create_ad_creative_request.rb', line 345

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

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



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

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



374
375
376
377
378
379
380
381
382
383
384
385
386
# File 'lib/zernio-sdk/models/create_ad_creative_request.rb', line 374

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



219
220
221
222
223
224
225
226
227
228
229
230
231
# File 'lib/zernio-sdk/models/create_ad_creative_request.rb', line 219

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