Class: WalmartApIs::ItemRelationship
- Defined in:
- lib/walmart_ap_is/models/item_relationship.rb
Overview
ItemRelationship Model.
Instance Attribute Summary collapse
-
#child_items ⇒ Array[RelatedItem]
TODO: Write general description for this method.
-
#parent_items ⇒ Array[RelatedItem]
TODO: Write general description for this method.
-
#type ⇒ Type
TODO: Write general description for this method.
-
#variation_theme ⇒ VariationTheme
TODO: Write general description for this method.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(type: SKIP, child_items: SKIP, parent_items: SKIP, variation_theme: SKIP, additional_properties: nil) ⇒ ItemRelationship
constructor
A new instance of ItemRelationship.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(type: SKIP, child_items: SKIP, parent_items: SKIP, variation_theme: SKIP, additional_properties: nil) ⇒ ItemRelationship
Returns a new instance of ItemRelationship.
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/walmart_ap_is/models/item_relationship.rb', line 53 def initialize(type: SKIP, child_items: SKIP, parent_items: SKIP, variation_theme: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @type = type unless type == SKIP @child_items = child_items unless child_items == SKIP @parent_items = parent_items unless parent_items == SKIP @variation_theme = variation_theme unless variation_theme == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#child_items ⇒ Array[RelatedItem]
TODO: Write general description for this method
18 19 20 |
# File 'lib/walmart_ap_is/models/item_relationship.rb', line 18 def child_items @child_items end |
#parent_items ⇒ Array[RelatedItem]
TODO: Write general description for this method
22 23 24 |
# File 'lib/walmart_ap_is/models/item_relationship.rb', line 22 def parent_items @parent_items end |
#type ⇒ Type
TODO: Write general description for this method
14 15 16 |
# File 'lib/walmart_ap_is/models/item_relationship.rb', line 14 def type @type end |
#variation_theme ⇒ VariationTheme
TODO: Write general description for this method
26 27 28 |
# File 'lib/walmart_ap_is/models/item_relationship.rb', line 26 def variation_theme @variation_theme end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/walmart_ap_is/models/item_relationship.rb', line 66 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. type = hash.key?('type') ? hash['type'] : SKIP # Parameter is an array, so we need to iterate through it child_items = nil unless hash['childItems'].nil? child_items = [] hash['childItems'].each do |structure| child_items << (RelatedItem.from_hash(structure) if structure) end end child_items = SKIP unless hash.key?('childItems') # Parameter is an array, so we need to iterate through it parent_items = nil unless hash['parentItems'].nil? parent_items = [] hash['parentItems'].each do |structure| parent_items << (RelatedItem.from_hash(structure) if structure) end end parent_items = SKIP unless hash.key?('parentItems') variation_theme = VariationTheme.from_hash(hash['variationTheme']) if hash['variationTheme'] # 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. ItemRelationship.new(type: type, child_items: child_items, parent_items: parent_items, variation_theme: variation_theme, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
29 30 31 32 33 34 35 36 |
# File 'lib/walmart_ap_is/models/item_relationship.rb', line 29 def self.names @_hash = {} if @_hash.nil? @_hash['type'] = 'type' @_hash['child_items'] = 'childItems' @_hash['parent_items'] = 'parentItems' @_hash['variation_theme'] = 'variationTheme' @_hash end |
.nullables ⇒ Object
An array for nullable fields
49 50 51 |
# File 'lib/walmart_ap_is/models/item_relationship.rb', line 49 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
39 40 41 42 43 44 45 46 |
# File 'lib/walmart_ap_is/models/item_relationship.rb', line 39 def self.optionals %w[ type child_items parent_items variation_theme ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
117 118 119 120 121 122 |
# File 'lib/walmart_ap_is/models/item_relationship.rb', line 117 def inspect class_name = self.class.name.split('::').last "<#{class_name} type: #{@type.inspect}, child_items: #{@child_items.inspect}, parent_items:"\ " #{@parent_items.inspect}, variation_theme: #{@variation_theme.inspect},"\ " additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
109 110 111 112 113 114 |
# File 'lib/walmart_ap_is/models/item_relationship.rb', line 109 def to_s class_name = self.class.name.split('::').last "<#{class_name} type: #{@type}, child_items: #{@child_items}, parent_items:"\ " #{@parent_items}, variation_theme: #{@variation_theme}, additional_properties:"\ " #{@additional_properties}>" end |