Class: Zernio::AdCreative

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

Overview

Platform-specific creative data. Fields vary by platform.

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

Initializes the object

Parameters:

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

    Model attributes in the form of hash



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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
# File 'lib/zernio-sdk/models/ad_creative.rb', line 149

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

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

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

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

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

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

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

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

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

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

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

  if attributes.key?(:'media_urls')
    if (value = attributes[:'media_urls']).is_a?(Array)
      self.media_urls = value
    end
  end

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

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

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

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

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

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

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

Instance Attribute Details

#bodyObject

Ad copy/text



56
57
58
# File 'lib/zernio-sdk/models/ad_creative.rb', line 56

def body
  @body
end

#effective_instagram_media_idObject

Meta effective_instagram_media_id — the Instagram media ID of the boosted post the ad's engagement lives on. Pass to GET /v1/ads?effectiveInstagramMediaId= to map a Business-Manager-visible IG post back to this ad.



44
45
46
# File 'lib/zernio-sdk/models/ad_creative.rb', line 44

def effective_instagram_media_id
  @effective_instagram_media_id
end

#effective_object_story_idObject

Meta effective_object_story_id{pageId}_{postId} of the Facebook post the ad's engagement (comments) lives on. Pass to GET /v1/ads?effectiveObjectStoryId= to map a Business-Manager-visible post back to this ad; GET /v1/ads/adId/comments resolves comments against it.



38
39
40
# File 'lib/zernio-sdk/models/ad_creative.rb', line 38

def effective_object_story_id
  @effective_object_story_id
end

#google_descriptionObject

Google Ads description



62
63
64
# File 'lib/zernio-sdk/models/ad_creative.rb', line 62

def google_description
  @google_description
end

#google_headlineObject

Google Ads headline



59
60
61
# File 'lib/zernio-sdk/models/ad_creative.rb', line 59

def google_headline
  @google_headline
end

#image_urlObject

Alternative image URL



23
24
25
# File 'lib/zernio-sdk/models/ad_creative.rb', line 23

def image_url
  @image_url
end

Meta instagram_permalink_url — public Instagram post URL of the boosted media.



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

def instagram_permalink_url
  @instagram_permalink_url
end

#instagram_user_idObject

Meta instagram_user_id — the Instagram-scoped business ID that owns the boosted media.



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

def instagram_user_id
  @instagram_user_id
end

Destination URL



65
66
67
# File 'lib/zernio-sdk/models/ad_creative.rb', line 65

def link_url
  @link_url
end

#media_urlsObject

All media URLs for this ad (carousel images, multiple assets). Populated for Meta (carousel child_attachments), Google Ads (responsive display marketing_images), and LinkedIn (multi-image posts).



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

def media_urls
  @media_urls
end

#object_story_idObject

Meta creative object_story_id (the SHARE reference). Frequently absent — Meta omits it for SHARE creatives. Use effectiveObjectStoryId instead.



35
36
37
# File 'lib/zernio-sdk/models/ad_creative.rb', line 35

def object_story_id
  @object_story_id
end

#object_typeObject

Meta creative object_type (e.g. SHARE, VIDEO, PRIVACY_CHECK_FAIL, POST_DELETED). Use this to render state-aware previews — when Meta moderation strips image/video fields, only thumbnailUrl at 64x64 is available.



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

def object_type
  @object_type
end

#page_idObject

Facebook Page backing the creative (Meta only). What the pageId filter on /v1/ads, /v1/ads/campaigns and /v1/ads/tree matches against. Absent for non-Meta ads and rare Meta creatives with no page signal.



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

def page_id
  @page_id
end

#pinterest_descriptionObject

Returns the value of attribute pinterest_description.



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

def pinterest_description
  @pinterest_description
end

#pinterest_image_urlObject

Returns the value of attribute pinterest_image_url.



67
68
69
# File 'lib/zernio-sdk/models/ad_creative.rb', line 67

def pinterest_image_url
  @pinterest_image_url
end

#pinterest_titleObject

Returns the value of attribute pinterest_title.



69
70
71
# File 'lib/zernio-sdk/models/ad_creative.rb', line 69

def pinterest_title
  @pinterest_title
end

#thumbnail_urlObject

Primary thumbnail/image URL



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

def thumbnail_url
  @thumbnail_url
end

#video_idObject

Meta video ID for VIDEO-type ads. Null for non-video ads. Callers that need an embeddable MP4 can call GET /videoId?fields=source with the page access token.



26
27
28
# File 'lib/zernio-sdk/models/ad_creative.rb', line 26

def video_id
  @video_id
end

#video_urlObject

Public Facebook watch URL for VIDEO-type ads (https://www.facebook.com/watch/?v=videoId). Null for non-video ads.



29
30
31
# File 'lib/zernio-sdk/models/ad_creative.rb', line 29

def video_url
  @video_url
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



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

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



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

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
90
91
92
93
94
95
96
# File 'lib/zernio-sdk/models/ad_creative.rb', line 74

def self.attribute_map
  {
    :'thumbnail_url' => :'thumbnailUrl',
    :'image_url' => :'imageUrl',
    :'video_id' => :'videoId',
    :'video_url' => :'videoUrl',
    :'object_type' => :'objectType',
    :'object_story_id' => :'objectStoryId',
    :'effective_object_story_id' => :'effectiveObjectStoryId',
    :'page_id' => :'pageId',
    :'effective_instagram_media_id' => :'effectiveInstagramMediaId',
    :'instagram_user_id' => :'instagramUserId',
    :'instagram_permalink_url' => :'instagramPermalinkUrl',
    :'media_urls' => :'mediaUrls',
    :'body' => :'body',
    :'google_headline' => :'googleHeadline',
    :'google_description' => :'googleDescription',
    :'link_url' => :'linkUrl',
    :'pinterest_image_url' => :'pinterestImageUrl',
    :'pinterest_title' => :'pinterestTitle',
    :'pinterest_description' => :'pinterestDescription'
  }
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



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

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



134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/zernio-sdk/models/ad_creative.rb', line 134

def self.openapi_nullable
  Set.new([
    :'video_id',
    :'video_url',
    :'object_story_id',
    :'effective_object_story_id',
    :'page_id',
    :'effective_instagram_media_id',
    :'instagram_user_id',
    :'instagram_permalink_url',
  ])
end

.openapi_typesObject

Attribute type mapping.



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/zernio-sdk/models/ad_creative.rb', line 109

def self.openapi_types
  {
    :'thumbnail_url' => :'String',
    :'image_url' => :'String',
    :'video_id' => :'String',
    :'video_url' => :'String',
    :'object_type' => :'String',
    :'object_story_id' => :'String',
    :'effective_object_story_id' => :'String',
    :'page_id' => :'String',
    :'effective_instagram_media_id' => :'String',
    :'instagram_user_id' => :'String',
    :'instagram_permalink_url' => :'String',
    :'media_urls' => :'Array<String>',
    :'body' => :'String',
    :'google_headline' => :'String',
    :'google_description' => :'String',
    :'link_url' => :'String',
    :'pinterest_image_url' => :'String',
    :'pinterest_title' => :'String',
    :'pinterest_description' => :'String'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
# File 'lib/zernio-sdk/models/ad_creative.rb', line 259

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      thumbnail_url == o.thumbnail_url &&
      image_url == o.image_url &&
      video_id == o.video_id &&
      video_url == o.video_url &&
      object_type == o.object_type &&
      object_story_id == o.object_story_id &&
      effective_object_story_id == o.effective_object_story_id &&
      page_id == o.page_id &&
      effective_instagram_media_id == o.effective_instagram_media_id &&
      instagram_user_id == o.instagram_user_id &&
      instagram_permalink_url == o.instagram_permalink_url &&
      media_urls == o.media_urls &&
      body == o.body &&
      google_headline == o.google_headline &&
      google_description == o.google_description &&
      link_url == o.link_url &&
      pinterest_image_url == o.pinterest_image_url &&
      pinterest_title == o.pinterest_title &&
      pinterest_description == o.pinterest_description
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


285
286
287
# File 'lib/zernio-sdk/models/ad_creative.rb', line 285

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



291
292
293
# File 'lib/zernio-sdk/models/ad_creative.rb', line 291

def hash
  [thumbnail_url, image_url, video_id, video_url, object_type, object_story_id, effective_object_story_id, page_id, effective_instagram_media_id, instagram_user_id, instagram_permalink_url, media_urls, body, google_headline, google_description, link_url, pinterest_image_url, pinterest_title, pinterest_description].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



244
245
246
247
248
# File 'lib/zernio-sdk/models/ad_creative.rb', line 244

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  invalid_properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



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

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

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  true
end