Class: NewStoreApi::SalesOrderProductAttributes

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/new_store_api/models/sales_order_product_attributes.rb

Overview

Additional product-related information.

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(name = nil, additional_variant_1 = SKIP, additional_variant_2 = SKIP, color = SKIP, image_url = SKIP, size = SKIP) ⇒ SalesOrderProductAttributes

Returns a new instance of SalesOrderProductAttributes.



64
65
66
67
68
69
70
71
72
73
# File 'lib/new_store_api/models/sales_order_product_attributes.rb', line 64

def initialize(name = nil, additional_variant_1 = SKIP,
               additional_variant_2 = SKIP, color = SKIP, image_url = SKIP,
               size = SKIP)
  @additional_variant_1 = additional_variant_1 unless additional_variant_1 == SKIP
  @additional_variant_2 = additional_variant_2 unless additional_variant_2 == SKIP
  @color = color unless color == SKIP
  @image_url = image_url unless image_url == SKIP
  @name = name
  @size = size unless size == SKIP
end

Instance Attribute Details

#additional_variant_1String

A free form field for additional product attributes.

Returns:

  • (String)


14
15
16
# File 'lib/new_store_api/models/sales_order_product_attributes.rb', line 14

def additional_variant_1
  @additional_variant_1
end

#additional_variant_2String

A free form field for additional product attributes.

Returns:

  • (String)


18
19
20
# File 'lib/new_store_api/models/sales_order_product_attributes.rb', line 18

def additional_variant_2
  @additional_variant_2
end

#colorString

The color of the product.

Returns:

  • (String)


22
23
24
# File 'lib/new_store_api/models/sales_order_product_attributes.rb', line 22

def color
  @color
end

#image_urlString

The URL to a product image.

Returns:

  • (String)


26
27
28
# File 'lib/new_store_api/models/sales_order_product_attributes.rb', line 26

def image_url
  @image_url
end

#nameString

The name of the product.

Returns:

  • (String)


30
31
32
# File 'lib/new_store_api/models/sales_order_product_attributes.rb', line 30

def name
  @name
end

#sizeString

The size of the product.

Returns:

  • (String)


34
35
36
# File 'lib/new_store_api/models/sales_order_product_attributes.rb', line 34

def size
  @size
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/new_store_api/models/sales_order_product_attributes.rb', line 76

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  name = hash.key?('name') ? hash['name'] : nil
  additional_variant_1 =
    hash.key?('additional_variant_1') ? hash['additional_variant_1'] : SKIP
  additional_variant_2 =
    hash.key?('additional_variant_2') ? hash['additional_variant_2'] : SKIP
  color = hash.key?('color') ? hash['color'] : SKIP
  image_url = hash.key?('image_url') ? hash['image_url'] : SKIP
  size = hash.key?('size') ? hash['size'] : SKIP

  # Create object from extracted values.
  SalesOrderProductAttributes.new(name,
                                  additional_variant_1,
                                  additional_variant_2,
                                  color,
                                  image_url,
                                  size)
end

.namesObject

A mapping from model property names to API property names.



37
38
39
40
41
42
43
44
45
46
# File 'lib/new_store_api/models/sales_order_product_attributes.rb', line 37

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['additional_variant_1'] = 'additional_variant_1'
  @_hash['additional_variant_2'] = 'additional_variant_2'
  @_hash['color'] = 'color'
  @_hash['image_url'] = 'image_url'
  @_hash['name'] = 'name'
  @_hash['size'] = 'size'
  @_hash
end

.nullablesObject

An array for nullable fields



60
61
62
# File 'lib/new_store_api/models/sales_order_product_attributes.rb', line 60

def self.nullables
  []
end

.optionalsObject

An array for optional fields



49
50
51
52
53
54
55
56
57
# File 'lib/new_store_api/models/sales_order_product_attributes.rb', line 49

def self.optionals
  %w[
    additional_variant_1
    additional_variant_2
    color
    image_url
    size
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



107
108
109
110
111
112
# File 'lib/new_store_api/models/sales_order_product_attributes.rb', line 107

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} additional_variant_1: #{@additional_variant_1.inspect},"\
  " additional_variant_2: #{@additional_variant_2.inspect}, color: #{@color.inspect},"\
  " image_url: #{@image_url.inspect}, name: #{@name.inspect}, size: #{@size.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



99
100
101
102
103
104
# File 'lib/new_store_api/models/sales_order_product_attributes.rb', line 99

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} additional_variant_1: #{@additional_variant_1}, additional_variant_2:"\
  " #{@additional_variant_2}, color: #{@color}, image_url: #{@image_url}, name: #{@name},"\
  " size: #{@size}>"
end