Class: StickyIoRestfulApiV2025731::ProductData3

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/sticky_io_restful_api_v2025731/models/product_data3.rb

Overview

ProductData3 Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(is_trial_product:, is_shippable:, tax_code:, is_licensed:, product_group_attributes:, disable_product_swap:, id:, name:, description:, sku:, price:, weight:, declared_value:, restocking_fee:, cost_of_goods:, max_quantity:, created_at:, updated_at:, custom_fields:, vertical:, category_id:, category:, is_bundle:, is_custom_bundle:, is_variant_enabled:, additional_properties: nil) ⇒ ProductData3

Returns a new instance of ProductData3.



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
# File 'lib/sticky_io_restful_api_v2025731/models/product_data3.rb', line 157

def initialize(is_trial_product:, is_shippable:, tax_code:, is_licensed:,
               product_group_attributes:, disable_product_swap:, id:, name:,
               description:, sku:, price:, weight:, declared_value:,
               restocking_fee:, cost_of_goods:, max_quantity:, created_at:,
               updated_at:, custom_fields:, vertical:, category_id:,
               category:, is_bundle:, is_custom_bundle:,
               is_variant_enabled:, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @is_trial_product = is_trial_product
  @is_shippable = is_shippable
  @tax_code = tax_code
  @is_licensed = is_licensed
  @product_group_attributes = product_group_attributes
  @disable_product_swap = disable_product_swap
  @id = id
  @name = name
  @description = description
  @sku = sku
  @price = price
  @weight = weight
  @declared_value = declared_value
  @restocking_fee = restocking_fee
  @cost_of_goods = cost_of_goods
  @max_quantity = max_quantity
  @created_at = created_at
  @updated_at = updated_at
  @custom_fields = custom_fields
  @vertical = vertical
  @category_id = category_id
  @category = category
  @is_bundle = is_bundle
  @is_custom_bundle = is_custom_bundle
  @is_variant_enabled = is_variant_enabled
  @additional_properties = additional_properties
end

Instance Attribute Details

#categoryCategory

TODO: Write general description for this method

Returns:



98
99
100
# File 'lib/sticky_io_restful_api_v2025731/models/product_data3.rb', line 98

def category
  @category
end

#category_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


94
95
96
# File 'lib/sticky_io_restful_api_v2025731/models/product_data3.rb', line 94

def category_id
  @category_id
end

#cost_of_goodsString

TODO: Write general description for this method

Returns:

  • (String)


70
71
72
# File 'lib/sticky_io_restful_api_v2025731/models/product_data3.rb', line 70

def cost_of_goods
  @cost_of_goods
end

#created_atCreatedAt

TODO: Write general description for this method

Returns:



78
79
80
# File 'lib/sticky_io_restful_api_v2025731/models/product_data3.rb', line 78

def created_at
  @created_at
end

#custom_fieldsArray[Object]

TODO: Write general description for this method

Returns:

  • (Array[Object])


86
87
88
# File 'lib/sticky_io_restful_api_v2025731/models/product_data3.rb', line 86

def custom_fields
  @custom_fields
end

#declared_valueString

TODO: Write general description for this method

Returns:

  • (String)


62
63
64
# File 'lib/sticky_io_restful_api_v2025731/models/product_data3.rb', line 62

def declared_value
  @declared_value
end

#descriptionString

TODO: Write general description for this method

Returns:

  • (String)


46
47
48
# File 'lib/sticky_io_restful_api_v2025731/models/product_data3.rb', line 46

def description
  @description
end

#disable_product_swapString

TODO: Write general description for this method

Returns:

  • (String)


34
35
36
# File 'lib/sticky_io_restful_api_v2025731/models/product_data3.rb', line 34

def disable_product_swap
  @disable_product_swap
end

#idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


38
39
40
# File 'lib/sticky_io_restful_api_v2025731/models/product_data3.rb', line 38

def id
  @id
end

#is_bundleInteger

TODO: Write general description for this method

Returns:

  • (Integer)


102
103
104
# File 'lib/sticky_io_restful_api_v2025731/models/product_data3.rb', line 102

def is_bundle
  @is_bundle
end

#is_custom_bundleInteger

TODO: Write general description for this method

Returns:

  • (Integer)


106
107
108
# File 'lib/sticky_io_restful_api_v2025731/models/product_data3.rb', line 106

def is_custom_bundle
  @is_custom_bundle
end

#is_licensedInteger

TODO: Write general description for this method

Returns:

  • (Integer)


26
27
28
# File 'lib/sticky_io_restful_api_v2025731/models/product_data3.rb', line 26

def is_licensed
  @is_licensed
end

#is_shippableInteger

TODO: Write general description for this method

Returns:

  • (Integer)


18
19
20
# File 'lib/sticky_io_restful_api_v2025731/models/product_data3.rb', line 18

def is_shippable
  @is_shippable
end

#is_trial_productInteger

TODO: Write general description for this method

Returns:

  • (Integer)


14
15
16
# File 'lib/sticky_io_restful_api_v2025731/models/product_data3.rb', line 14

def is_trial_product
  @is_trial_product
end

#is_variant_enabledInteger

TODO: Write general description for this method

Returns:

  • (Integer)


110
111
112
# File 'lib/sticky_io_restful_api_v2025731/models/product_data3.rb', line 110

def is_variant_enabled
  @is_variant_enabled
end

#max_quantityInteger

TODO: Write general description for this method

Returns:

  • (Integer)


74
75
76
# File 'lib/sticky_io_restful_api_v2025731/models/product_data3.rb', line 74

def max_quantity
  @max_quantity
end

#nameString

TODO: Write general description for this method

Returns:

  • (String)


42
43
44
# File 'lib/sticky_io_restful_api_v2025731/models/product_data3.rb', line 42

def name
  @name
end

#priceString

TODO: Write general description for this method

Returns:

  • (String)


54
55
56
# File 'lib/sticky_io_restful_api_v2025731/models/product_data3.rb', line 54

def price
  @price
end

#product_group_attributesString

TODO: Write general description for this method

Returns:

  • (String)


30
31
32
# File 'lib/sticky_io_restful_api_v2025731/models/product_data3.rb', line 30

def product_group_attributes
  @product_group_attributes
end

#restocking_feeString

TODO: Write general description for this method

Returns:

  • (String)


66
67
68
# File 'lib/sticky_io_restful_api_v2025731/models/product_data3.rb', line 66

def restocking_fee
  @restocking_fee
end

#skuString

TODO: Write general description for this method

Returns:

  • (String)


50
51
52
# File 'lib/sticky_io_restful_api_v2025731/models/product_data3.rb', line 50

def sku
  @sku
end

#tax_codeString

TODO: Write general description for this method

Returns:

  • (String)


22
23
24
# File 'lib/sticky_io_restful_api_v2025731/models/product_data3.rb', line 22

def tax_code
  @tax_code
end

#updated_atUpdatedAtProduct

TODO: Write general description for this method

Returns:



82
83
84
# File 'lib/sticky_io_restful_api_v2025731/models/product_data3.rb', line 82

def updated_at
  @updated_at
end

#verticalArray[Object]

TODO: Write general description for this method

Returns:

  • (Array[Object])


90
91
92
# File 'lib/sticky_io_restful_api_v2025731/models/product_data3.rb', line 90

def vertical
  @vertical
end

#weightInteger

TODO: Write general description for this method

Returns:

  • (Integer)


58
59
60
# File 'lib/sticky_io_restful_api_v2025731/models/product_data3.rb', line 58

def weight
  @weight
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
# File 'lib/sticky_io_restful_api_v2025731/models/product_data3.rb', line 196

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  is_trial_product =
    hash.key?('is_trial_product') ? hash['is_trial_product'] : nil
  is_shippable = hash.key?('is_shippable') ? hash['is_shippable'] : nil
  tax_code = hash.key?('tax_code') ? hash['tax_code'] : nil
  is_licensed = hash.key?('is_licensed') ? hash['is_licensed'] : nil
  product_group_attributes =
    hash.key?('product_group_attributes') ? hash['product_group_attributes'] : nil
  disable_product_swap =
    hash.key?('disable_product_swap') ? hash['disable_product_swap'] : nil
  id = hash.key?('id') ? hash['id'] : nil
  name = hash.key?('name') ? hash['name'] : nil
  description = hash.key?('description') ? hash['description'] : nil
  sku = hash.key?('sku') ? hash['sku'] : nil
  price = hash.key?('price') ? hash['price'] : nil
  weight = hash.key?('weight') ? hash['weight'] : nil
  declared_value =
    hash.key?('declared_value') ? hash['declared_value'] : nil
  restocking_fee =
    hash.key?('restocking_fee') ? hash['restocking_fee'] : nil
  cost_of_goods = hash.key?('cost_of_goods') ? hash['cost_of_goods'] : nil
  max_quantity = hash.key?('max_quantity') ? hash['max_quantity'] : nil
  created_at = CreatedAt.from_hash(hash['created_at']) if hash['created_at']
  updated_at = UpdatedAtProduct.from_hash(hash['updated_at']) if hash['updated_at']
  custom_fields = hash.key?('custom_fields') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:ProductData3CustomFields), hash['custom_fields']
  ) : nil
  vertical = hash.key?('vertical') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:ProductData3Vertical), hash['vertical']
  ) : nil
  category_id = hash.key?('category_id') ? hash['category_id'] : nil
  category = Category.from_hash(hash['category']) if hash['category']
  is_bundle = hash.key?('is_bundle') ? hash['is_bundle'] : nil
  is_custom_bundle =
    hash.key?('is_custom_bundle') ? hash['is_custom_bundle'] : nil
  is_variant_enabled =
    hash.key?('is_variant_enabled') ? hash['is_variant_enabled'] : nil

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  ProductData3.new(is_trial_product: is_trial_product,
                   is_shippable: is_shippable,
                   tax_code: tax_code,
                   is_licensed: is_licensed,
                   product_group_attributes: product_group_attributes,
                   disable_product_swap: disable_product_swap,
                   id: id,
                   name: name,
                   description: description,
                   sku: sku,
                   price: price,
                   weight: weight,
                   declared_value: declared_value,
                   restocking_fee: restocking_fee,
                   cost_of_goods: cost_of_goods,
                   max_quantity: max_quantity,
                   created_at: created_at,
                   updated_at: updated_at,
                   custom_fields: custom_fields,
                   vertical: vertical,
                   category_id: category_id,
                   category: category,
                   is_bundle: is_bundle,
                   is_custom_bundle: is_custom_bundle,
                   is_variant_enabled: is_variant_enabled,
                   additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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
# File 'lib/sticky_io_restful_api_v2025731/models/product_data3.rb', line 113

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['is_trial_product'] = 'is_trial_product'
  @_hash['is_shippable'] = 'is_shippable'
  @_hash['tax_code'] = 'tax_code'
  @_hash['is_licensed'] = 'is_licensed'
  @_hash['product_group_attributes'] = 'product_group_attributes'
  @_hash['disable_product_swap'] = 'disable_product_swap'
  @_hash['id'] = 'id'
  @_hash['name'] = 'name'
  @_hash['description'] = 'description'
  @_hash['sku'] = 'sku'
  @_hash['price'] = 'price'
  @_hash['weight'] = 'weight'
  @_hash['declared_value'] = 'declared_value'
  @_hash['restocking_fee'] = 'restocking_fee'
  @_hash['cost_of_goods'] = 'cost_of_goods'
  @_hash['max_quantity'] = 'max_quantity'
  @_hash['created_at'] = 'created_at'
  @_hash['updated_at'] = 'updated_at'
  @_hash['custom_fields'] = 'custom_fields'
  @_hash['vertical'] = 'vertical'
  @_hash['category_id'] = 'category_id'
  @_hash['category'] = 'category'
  @_hash['is_bundle'] = 'is_bundle'
  @_hash['is_custom_bundle'] = 'is_custom_bundle'
  @_hash['is_variant_enabled'] = 'is_variant_enabled'
  @_hash
end

.nullablesObject

An array for nullable fields



149
150
151
152
153
154
155
# File 'lib/sticky_io_restful_api_v2025731/models/product_data3.rb', line 149

def self.nullables
  %w[
    tax_code
    product_group_attributes
    disable_product_swap
  ]
end

.optionalsObject

An array for optional fields



144
145
146
# File 'lib/sticky_io_restful_api_v2025731/models/product_data3.rb', line 144

def self.optionals
  []
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:

  • The (ProductData3 | Hash)

    value against the validation is performed.



275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
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
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
# File 'lib/sticky_io_restful_api_v2025731/models/product_data3.rb', line 275

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.is_trial_product,
                            ->(val) { val.instance_of? Integer }) and
        APIHelper.valid_type?(value.is_shippable,
                              ->(val) { val.instance_of? Integer }) and
        APIHelper.valid_type?(value.tax_code,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.is_licensed,
                              ->(val) { val.instance_of? Integer }) and
        APIHelper.valid_type?(value.product_group_attributes,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.disable_product_swap,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.id,
                              ->(val) { val.instance_of? Integer }) and
        APIHelper.valid_type?(value.name,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.description,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.sku,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.price,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.weight,
                              ->(val) { val.instance_of? Integer }) and
        APIHelper.valid_type?(value.declared_value,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.restocking_fee,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.cost_of_goods,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.max_quantity,
                              ->(val) { val.instance_of? Integer }) and
        APIHelper.valid_type?(value.created_at,
                              ->(val) { CreatedAt.validate(val) },
                              is_model_hash: true) and
        APIHelper.valid_type?(value.updated_at,
                              ->(val) { UpdatedAtProduct.validate(val) },
                              is_model_hash: true) and
        UnionTypeLookUp.get(:ProductData3CustomFields)
                       .validate(value.custom_fields) and
        UnionTypeLookUp.get(:ProductData3Vertical)
                       .validate(value.vertical) and
        APIHelper.valid_type?(value.category_id,
                              ->(val) { val.instance_of? Integer }) and
        APIHelper.valid_type?(value.category,
                              ->(val) { Category.validate(val) },
                              is_model_hash: true) and
        APIHelper.valid_type?(value.is_bundle,
                              ->(val) { val.instance_of? Integer }) and
        APIHelper.valid_type?(value.is_custom_bundle,
                              ->(val) { val.instance_of? Integer }) and
        APIHelper.valid_type?(value.is_variant_enabled,
                              ->(val) { val.instance_of? Integer })
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['is_trial_product'],
                          ->(val) { val.instance_of? Integer }) and
      APIHelper.valid_type?(value['is_shippable'],
                            ->(val) { val.instance_of? Integer }) and
      APIHelper.valid_type?(value['tax_code'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['is_licensed'],
                            ->(val) { val.instance_of? Integer }) and
      APIHelper.valid_type?(value['product_group_attributes'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['disable_product_swap'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['id'],
                            ->(val) { val.instance_of? Integer }) and
      APIHelper.valid_type?(value['name'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['description'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['sku'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['price'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['weight'],
                            ->(val) { val.instance_of? Integer }) and
      APIHelper.valid_type?(value['declared_value'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['restocking_fee'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['cost_of_goods'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['max_quantity'],
                            ->(val) { val.instance_of? Integer }) and
      APIHelper.valid_type?(value['created_at'],
                            ->(val) { CreatedAt.validate(val) },
                            is_model_hash: true) and
      APIHelper.valid_type?(value['updated_at'],
                            ->(val) { UpdatedAtProduct.validate(val) },
                            is_model_hash: true) and
      UnionTypeLookUp.get(:ProductData3CustomFields)
                     .validate(value['custom_fields']) and
      UnionTypeLookUp.get(:ProductData3Vertical)
                     .validate(value['vertical']) and
      APIHelper.valid_type?(value['category_id'],
                            ->(val) { val.instance_of? Integer }) and
      APIHelper.valid_type?(value['category'],
                            ->(val) { Category.validate(val) },
                            is_model_hash: true) and
      APIHelper.valid_type?(value['is_bundle'],
                            ->(val) { val.instance_of? Integer }) and
      APIHelper.valid_type?(value['is_custom_bundle'],
                            ->(val) { val.instance_of? Integer }) and
      APIHelper.valid_type?(value['is_variant_enabled'],
                            ->(val) { val.instance_of? Integer })
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
# File 'lib/sticky_io_restful_api_v2025731/models/product_data3.rb', line 409

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} is_trial_product: #{@is_trial_product.inspect}, is_shippable:"\
  " #{@is_shippable.inspect}, tax_code: #{@tax_code.inspect}, is_licensed:"\
  " #{@is_licensed.inspect}, product_group_attributes: #{@product_group_attributes.inspect},"\
  " disable_product_swap: #{@disable_product_swap.inspect}, id: #{@id.inspect}, name:"\
  " #{@name.inspect}, description: #{@description.inspect}, sku: #{@sku.inspect}, price:"\
  " #{@price.inspect}, weight: #{@weight.inspect}, declared_value: #{@declared_value.inspect},"\
  " restocking_fee: #{@restocking_fee.inspect}, cost_of_goods: #{@cost_of_goods.inspect},"\
  " max_quantity: #{@max_quantity.inspect}, created_at: #{@created_at.inspect}, updated_at:"\
  " #{@updated_at.inspect}, custom_fields: #{@custom_fields.inspect}, vertical:"\
  " #{@vertical.inspect}, category_id: #{@category_id.inspect}, category:"\
  " #{@category.inspect}, is_bundle: #{@is_bundle.inspect}, is_custom_bundle:"\
  " #{@is_custom_bundle.inspect}, is_variant_enabled: #{@is_variant_enabled.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



394
395
396
397
398
399
400
401
402
403
404
405
406
# File 'lib/sticky_io_restful_api_v2025731/models/product_data3.rb', line 394

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} is_trial_product: #{@is_trial_product}, is_shippable: #{@is_shippable},"\
  " tax_code: #{@tax_code}, is_licensed: #{@is_licensed}, product_group_attributes:"\
  " #{@product_group_attributes}, disable_product_swap: #{@disable_product_swap}, id: #{@id},"\
  " name: #{@name}, description: #{@description}, sku: #{@sku}, price: #{@price}, weight:"\
  " #{@weight}, declared_value: #{@declared_value}, restocking_fee: #{@restocking_fee},"\
  " cost_of_goods: #{@cost_of_goods}, max_quantity: #{@max_quantity}, created_at:"\
  " #{@created_at}, updated_at: #{@updated_at}, custom_fields: #{@custom_fields}, vertical:"\
  " #{@vertical}, category_id: #{@category_id}, category: #{@category}, is_bundle:"\
  " #{@is_bundle}, is_custom_bundle: #{@is_custom_bundle}, is_variant_enabled:"\
  " #{@is_variant_enabled}, additional_properties: #{@additional_properties}>"
end