Class: PinterestSdkClient::AdPreviewShopping

Inherits:
ApiModelBase show all
Defined in:
lib/pinterest_sdk/models/ad_preview_shopping.rb

Overview

Ad preview from a catalog product group (shopping).

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

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
# File 'lib/pinterest_sdk/models/ad_preview_shopping.rb', line 127

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

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

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

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

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

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

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

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

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

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

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

Instance Attribute Details

#catalog_product_group_idObject

Catalog Product Group Id.



20
21
22
# File 'lib/pinterest_sdk/models/ad_preview_shopping.rb', line 20

def catalog_product_group_id
  @catalog_product_group_id
end

#creative_typeObject

Ad format of the shopping ad preview.



23
24
25
# File 'lib/pinterest_sdk/models/ad_preview_shopping.rb', line 23

def creative_type
  @creative_type
end

#customizable_cta_typeObject

Select a call to action (CTA) to display below your ad. CTA options for catalog sales campaigns are SHOP_NOW, BOOK_NOW, ON_SALE, GET_DEAL, BUY_ONLINE_PICKUP_IN_STORE



26
27
28
# File 'lib/pinterest_sdk/models/ad_preview_shopping.rb', line 26

def customizable_cta_type
  @customizable_cta_type
end

#hero_image_titleObject

Title displayed below ad.



29
30
31
# File 'lib/pinterest_sdk/models/ad_preview_shopping.rb', line 29

def hero_image_title
  @hero_image_title
end

#hero_image_urlObject

Hero image URL.



32
33
34
# File 'lib/pinterest_sdk/models/ad_preview_shopping.rb', line 32

def hero_image_url
  @hero_image_url
end

#hero_pin_idObject

Pin id for the hero image. When creative type is COLLECTION, either hero_pin_id or (hero_image_url, hero_image_title) is required.



35
36
37
# File 'lib/pinterest_sdk/models/ad_preview_shopping.rb', line 35

def hero_pin_id
  @hero_pin_id
end

#image_tagObject

Multi image template tag.



38
39
40
# File 'lib/pinterest_sdk/models/ad_preview_shopping.rb', line 38

def image_tag
  @image_tag
end

#item_idObject

Item id for product to preview standard shopping ads, optional and only applicable when creative type is SHOPPING.



41
42
43
# File 'lib/pinterest_sdk/models/ad_preview_shopping.rb', line 41

def item_id
  @item_id
end

#preferred_media_typeObject

Preferred media type.



44
45
46
# File 'lib/pinterest_sdk/models/ad_preview_shopping.rb', line 44

def preferred_media_type
  @preferred_media_type
end

#show_promotionObject

Include promotion data in preview when available on catalog item. Defaults to false.



47
48
49
# File 'lib/pinterest_sdk/models/ad_preview_shopping.rb', line 47

def show_promotion
  @show_promotion
end

#video_tagObject

Multi video template tag, image_tag and video_tag are mutual exclusive.



50
51
52
# File 'lib/pinterest_sdk/models/ad_preview_shopping.rb', line 50

def video_tag
  @video_tag
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



92
93
94
# File 'lib/pinterest_sdk/models/ad_preview_shopping.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/pinterest_sdk/models/ad_preview_shopping.rb', line 97

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

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



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/pinterest_sdk/models/ad_preview_shopping.rb', line 75

def self.attribute_map
  {
    :'catalog_product_group_id' => :'catalog_product_group_id',
    :'creative_type' => :'creative_type',
    :'customizable_cta_type' => :'customizable_cta_type',
    :'hero_image_title' => :'hero_image_title',
    :'hero_image_url' => :'hero_image_url',
    :'hero_pin_id' => :'hero_pin_id',
    :'image_tag' => :'image_tag',
    :'item_id' => :'item_id',
    :'preferred_media_type' => :'preferred_media_type',
    :'show_promotion' => :'show_promotion',
    :'video_tag' => :'video_tag'
  }
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



300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
# File 'lib/pinterest_sdk/models/ad_preview_shopping.rb', line 300

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



119
120
121
122
123
# File 'lib/pinterest_sdk/models/ad_preview_shopping.rb', line 119

def self.openapi_nullable
  Set.new([
    :'customizable_cta_type',
  ])
end

.openapi_typesObject

Attribute type mapping.



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/pinterest_sdk/models/ad_preview_shopping.rb', line 102

def self.openapi_types
  {
    :'catalog_product_group_id' => :'String',
    :'creative_type' => :'AdShoppingPreviewCreativeType',
    :'customizable_cta_type' => :'CustomizableCTAType',
    :'hero_image_title' => :'String',
    :'hero_image_url' => :'String',
    :'hero_pin_id' => :'String',
    :'image_tag' => :'String',
    :'item_id' => :'String',
    :'preferred_media_type' => :'BasePreferredMediaType',
    :'show_promotion' => :'Boolean',
    :'video_tag' => :'String'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



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

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      catalog_product_group_id == o.catalog_product_group_id &&
      creative_type == o.creative_type &&
      customizable_cta_type == o.customizable_cta_type &&
      hero_image_title == o.hero_image_title &&
      hero_image_url == o.hero_image_url &&
      hero_pin_id == o.hero_pin_id &&
      image_tag == o.image_tag &&
      item_id == o.item_id &&
      preferred_media_type == o.preferred_media_type &&
      show_promotion == o.show_promotion &&
      video_tag == o.video_tag
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


287
288
289
# File 'lib/pinterest_sdk/models/ad_preview_shopping.rb', line 287

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



293
294
295
# File 'lib/pinterest_sdk/models/ad_preview_shopping.rb', line 293

def hash
  [catalog_product_group_id, creative_type, customizable_cta_type, hero_image_title, hero_image_url, hero_pin_id, image_tag, item_id, preferred_media_type, show_promotion, video_tag].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# File 'lib/pinterest_sdk/models/ad_preview_shopping.rb', line 192

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  if @catalog_product_group_id.nil?
    invalid_properties.push('invalid value for "catalog_product_group_id", catalog_product_group_id cannot be nil.')
  end

  pattern = Regexp.new(/^\d+$/)
  if @catalog_product_group_id !~ pattern
    invalid_properties.push("invalid value for \"catalog_product_group_id\", must conform to the pattern #{pattern}.")
  end

  if @creative_type.nil?
    invalid_properties.push('invalid value for "creative_type", creative_type cannot be nil.')
  end

  pattern = Regexp.new(/^\d+$/)
  if !@hero_pin_id.nil? && @hero_pin_id !~ pattern
    invalid_properties.push("invalid value for \"hero_pin_id\", must conform to the pattern #{pattern}.")
  end

  invalid_properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



322
323
324
325
326
327
328
329
330
331
332
333
334
# File 'lib/pinterest_sdk/models/ad_preview_shopping.rb', line 322

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



218
219
220
221
222
223
224
225
# File 'lib/pinterest_sdk/models/ad_preview_shopping.rb', line 218

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if @catalog_product_group_id.nil?
  return false if @catalog_product_group_id !~ Regexp.new(/^\d+$/)
  return false if @creative_type.nil?
  return false if !@hero_pin_id.nil? && @hero_pin_id !~ Regexp.new(/^\d+$/)
  true
end