Class: KlaviyoAPI::DynamicProductBlockProperties

Inherits:
Object
  • Object
show all
Defined in:
lib/klaviyo-api-sdk/models/dynamic_product_block_properties.rb

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ DynamicProductBlockProperties

Initializes the object

Parameters:

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

    Model attributes in the form of hash



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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/klaviyo-api-sdk/models/dynamic_product_block_properties.rb', line 143

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `KlaviyoAPI::DynamicProductBlockProperties` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!self.class.attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `KlaviyoAPI::DynamicProductBlockProperties`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Instance Attribute Details

#button_textObject

Returns the value of attribute button_text.



41
42
43
# File 'lib/klaviyo-api-sdk/models/dynamic_product_block_properties.rb', line 41

def button_text
  @button_text
end

#dynamicObject

Returns the value of attribute dynamic.



39
40
41
# File 'lib/klaviyo-api-sdk/models/dynamic_product_block_properties.rb', line 39

def dynamic
  @dynamic
end

#feedObject

Returns the value of attribute feed.



43
44
45
# File 'lib/klaviyo-api-sdk/models/dynamic_product_block_properties.rb', line 43

def feed
  @feed
end

#feed_offsetObject

Returns the value of attribute feed_offset.



45
46
47
# File 'lib/klaviyo-api-sdk/models/dynamic_product_block_properties.rb', line 45

def feed_offset
  @feed_offset
end

#is_ai_generatedObject

Returns the value of attribute is_ai_generated.



17
18
19
# File 'lib/klaviyo-api-sdk/models/dynamic_product_block_properties.rb', line 17

def is_ai_generated
  @is_ai_generated
end

#is_nbpObject

Returns the value of attribute is_nbp.



47
48
49
# File 'lib/klaviyo-api-sdk/models/dynamic_product_block_properties.rb', line 47

def is_nbp
  @is_nbp
end

#is_prebuilt_contentObject

Returns the value of attribute is_prebuilt_content.



19
20
21
# File 'lib/klaviyo-api-sdk/models/dynamic_product_block_properties.rb', line 19

def is_prebuilt_content
  @is_prebuilt_content
end

#item_subtype_idObject

Returns the value of attribute item_subtype_id.



21
22
23
# File 'lib/klaviyo-api-sdk/models/dynamic_product_block_properties.rb', line 21

def item_subtype_id
  @item_subtype_id
end

#show_buttonObject

Returns the value of attribute show_button.



23
24
25
# File 'lib/klaviyo-api-sdk/models/dynamic_product_block_properties.rb', line 23

def show_button
  @show_button
end

#show_original_priceObject

Returns the value of attribute show_original_price.



25
26
27
# File 'lib/klaviyo-api-sdk/models/dynamic_product_block_properties.rb', line 25

def show_original_price
  @show_original_price
end

#show_priceObject

Returns the value of attribute show_price.



27
28
29
# File 'lib/klaviyo-api-sdk/models/dynamic_product_block_properties.rb', line 27

def show_price
  @show_price
end

#show_ratingObject

Returns the value of attribute show_rating.



29
30
31
# File 'lib/klaviyo-api-sdk/models/dynamic_product_block_properties.rb', line 29

def show_rating
  @show_rating
end

#show_rating_countObject

Returns the value of attribute show_rating_count.



31
32
33
# File 'lib/klaviyo-api-sdk/models/dynamic_product_block_properties.rb', line 31

def show_rating_count
  @show_rating_count
end

#show_titleObject

Returns the value of attribute show_title.



33
34
35
# File 'lib/klaviyo-api-sdk/models/dynamic_product_block_properties.rb', line 33

def show_title
  @show_title
end

Returns the value of attribute show_title_links.



35
36
37
# File 'lib/klaviyo-api-sdk/models/dynamic_product_block_properties.rb', line 35

def show_title_links
  @show_title_links
end

#title_placeholderObject

Returns the value of attribute title_placeholder.



37
38
39
# File 'lib/klaviyo-api-sdk/models/dynamic_product_block_properties.rb', line 37

def title_placeholder
  @title_placeholder
end

Class Method Details

.acceptable_attributesObject

Returns all the JSON keys this model knows about



94
95
96
# File 'lib/klaviyo-api-sdk/models/dynamic_product_block_properties.rb', line 94

def self.acceptable_attributes
  attribute_map.values
end

.attribute_mapObject

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



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/klaviyo-api-sdk/models/dynamic_product_block_properties.rb', line 72

def self.attribute_map
  {
    :'is_ai_generated' => :'is_ai_generated',
    :'is_prebuilt_content' => :'is_prebuilt_content',
    :'item_subtype_id' => :'item_subtype_id',
    :'show_button' => :'show_button',
    :'show_original_price' => :'show_original_price',
    :'show_price' => :'show_price',
    :'show_rating' => :'show_rating',
    :'show_rating_count' => :'show_rating_count',
    :'show_title' => :'show_title',
    :'show_title_links' => :'show_title_links',
    :'title_placeholder' => :'title_placeholder',
    :'dynamic' => :'dynamic',
    :'button_text' => :'button_text',
    :'feed' => :'feed',
    :'feed_offset' => :'feed_offset',
    :'is_nbp' => :'is_nbp'
  }
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



289
290
291
# File 'lib/klaviyo-api-sdk/models/dynamic_product_block_properties.rb', line 289

def self.build_from_hash(attributes)
  new.build_from_hash(attributes)
end

.openapi_nullableObject

List of attributes with nullable: true



121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/klaviyo-api-sdk/models/dynamic_product_block_properties.rb', line 121

def self.openapi_nullable
  Set.new([
    :'is_ai_generated',
    :'is_prebuilt_content',
    :'item_subtype_id',
    :'show_button',
    :'show_original_price',
    :'show_price',
    :'show_rating',
    :'show_rating_count',
    :'show_title',
    :'show_title_links',
    :'title_placeholder',
    :'button_text',
    :'feed',
    :'feed_offset',
    :'is_nbp'
  ])
end

.openapi_typesObject

Attribute type mapping.



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/klaviyo-api-sdk/models/dynamic_product_block_properties.rb', line 99

def self.openapi_types
  {
    :'is_ai_generated' => :'Boolean',
    :'is_prebuilt_content' => :'Boolean',
    :'item_subtype_id' => :'Integer',
    :'show_button' => :'Boolean',
    :'show_original_price' => :'Boolean',
    :'show_price' => :'Boolean',
    :'show_rating' => :'Boolean',
    :'show_rating_count' => :'Boolean',
    :'show_title' => :'Boolean',
    :'show_title_links' => :'Boolean',
    :'title_placeholder' => :'String',
    :'dynamic' => :'Boolean',
    :'button_text' => :'String',
    :'feed' => :'String',
    :'feed_offset' => :'Integer',
    :'is_nbp' => :'Boolean'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
# File 'lib/klaviyo-api-sdk/models/dynamic_product_block_properties.rb', line 253

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      is_ai_generated == o.is_ai_generated &&
      is_prebuilt_content == o.is_prebuilt_content &&
      item_subtype_id == o.item_subtype_id &&
      show_button == o.show_button &&
      show_original_price == o.show_original_price &&
      show_price == o.show_price &&
      show_rating == o.show_rating &&
      show_rating_count == o.show_rating_count &&
      show_title == o.show_title &&
      show_title_links == o.show_title_links &&
      title_placeholder == o.title_placeholder &&
      dynamic == o.dynamic &&
      button_text == o.button_text &&
      feed == o.feed &&
      feed_offset == o.feed_offset &&
      is_nbp == o.is_nbp
end

#_deserialize(type, value) ⇒ Object

Deserializes the data based on type

Parameters:

  • string

    type Data type

  • string

    value Value to be deserialized

Returns:

  • (Object)

    Deserialized data



320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
# File 'lib/klaviyo-api-sdk/models/dynamic_product_block_properties.rb', line 320

def _deserialize(type, value)
  case type.to_sym
  when :Time
    Time.parse(value)
  when :Date
    Date.parse(value)
  when :String
    value.to_s
  when :Integer
    value.to_i
  when :Float
    value.to_f
  when :Boolean
    if value.to_s =~ /\A(true|t|yes|y|1)\z/i
      true
    else
      false
    end
  when :Object
    # generic object (usually a Hash), return directly
    value
  when /\AArray<(?<inner_type>.+)>\z/
    inner_type = Regexp.last_match[:inner_type]
    value.map { |v| _deserialize(inner_type, v) }
  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
    k_type = Regexp.last_match[:k_type]
    v_type = Regexp.last_match[:v_type]
    {}.tap do |hash|
      value.each do |k, v|
        hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
      end
    end
  else # model
    # models (e.g. Pet) or oneOf
    klass = KlaviyoAPI.const_get(type)
    klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
  end
end

#_to_hash(value) ⇒ Hash

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

Parameters:

  • value (Object)

    Any valid value

Returns:

  • (Hash)

    Returns the value in the form of hash



391
392
393
394
395
396
397
398
399
400
401
402
403
# File 'lib/klaviyo-api-sdk/models/dynamic_product_block_properties.rb', line 391

def _to_hash(value)
  if value.is_a?(Array)
    value.compact.map { |v| _to_hash(v) }
  elsif value.is_a?(Hash)
    {}.tap do |hash|
      value.each { |k, v| hash[k] = _to_hash(v) }
    end
  elsif value.respond_to? :to_hash
    value.to_hash
  else
    value
  end
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



296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
# File 'lib/klaviyo-api-sdk/models/dynamic_product_block_properties.rb', line 296

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  attributes = attributes.transform_keys(&:to_sym)
  self.class.openapi_types.each_pair do |key, type|
    if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
      self.send("#{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[self.class.attribute_map[key]].is_a?(Array)
        self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
    end
  end

  self
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


276
277
278
# File 'lib/klaviyo-api-sdk/models/dynamic_product_block_properties.rb', line 276

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



282
283
284
# File 'lib/klaviyo-api-sdk/models/dynamic_product_block_properties.rb', line 282

def hash
  [is_ai_generated, is_prebuilt_content, item_subtype_id, show_button, show_original_price, show_price, show_rating, show_rating_count, show_title, show_title_links, title_placeholder, dynamic, button_text, feed, feed_offset, is_nbp].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



223
224
225
226
227
228
229
230
# File 'lib/klaviyo-api-sdk/models/dynamic_product_block_properties.rb', line 223

def list_invalid_properties
  invalid_properties = Array.new
  if @dynamic.nil?
    invalid_properties.push('invalid value for "dynamic", dynamic cannot be nil.')
  end

  invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • (Hash)

    Returns the object in the form of hash



367
368
369
# File 'lib/klaviyo-api-sdk/models/dynamic_product_block_properties.rb', line 367

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



373
374
375
376
377
378
379
380
381
382
383
384
385
# File 'lib/klaviyo-api-sdk/models/dynamic_product_block_properties.rb', line 373

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

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



361
362
363
# File 'lib/klaviyo-api-sdk/models/dynamic_product_block_properties.rb', line 361

def to_s
  to_hash.to_s
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



234
235
236
237
238
239
# File 'lib/klaviyo-api-sdk/models/dynamic_product_block_properties.rb', line 234

def valid?
  return false if @dynamic.nil?
  dynamic_validator = EnumAttributeValidator.new('Boolean', ["true"])
  return false unless dynamic_validator.valid?(@dynamic)
  true
end