Class: WalmartApIs::Item1
- Defined in:
- lib/walmart_ap_is/models/item1.rb
Overview
Item1 Model.
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Item attribute key-value pairs for the listing.
-
#fulfillment_availability ⇒ Array[FulfillmentAvailability]
Item attribute key-value pairs for the listing.
-
#issues ⇒ Array[Issue]
Item attribute key-value pairs for the listing.
-
#offers ⇒ Array[ItemOfferByMarketplace]
Item attribute key-value pairs for the listing.
-
#sku ⇒ String
TODO: Write general description for this method.
-
#summaries ⇒ Array[ItemSummaryByMarketplace]
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(sku:, summaries: SKIP, attributes: SKIP, issues: SKIP, offers: SKIP, fulfillment_availability: SKIP, additional_properties: nil) ⇒ Item1
constructor
A new instance of Item1.
-
#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(sku:, summaries: SKIP, attributes: SKIP, issues: SKIP, offers: SKIP, fulfillment_availability: SKIP, additional_properties: nil) ⇒ Item1
Returns a new instance of Item1.
64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/walmart_ap_is/models/item1.rb', line 64 def initialize(sku:, summaries: SKIP, attributes: SKIP, issues: SKIP, offers: SKIP, fulfillment_availability: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @sku = sku @summaries = summaries unless summaries == SKIP @attributes = attributes unless attributes == SKIP @issues = issues unless issues == SKIP @offers = offers unless offers == SKIP @fulfillment_availability = fulfillment_availability unless fulfillment_availability == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#attributes ⇒ Object
Item attribute key-value pairs for the listing
22 23 24 |
# File 'lib/walmart_ap_is/models/item1.rb', line 22 def attributes @attributes end |
#fulfillment_availability ⇒ Array[FulfillmentAvailability]
Item attribute key-value pairs for the listing
34 35 36 |
# File 'lib/walmart_ap_is/models/item1.rb', line 34 def fulfillment_availability @fulfillment_availability end |
#issues ⇒ Array[Issue]
Item attribute key-value pairs for the listing
26 27 28 |
# File 'lib/walmart_ap_is/models/item1.rb', line 26 def issues @issues end |
#offers ⇒ Array[ItemOfferByMarketplace]
Item attribute key-value pairs for the listing
30 31 32 |
# File 'lib/walmart_ap_is/models/item1.rb', line 30 def offers @offers end |
#sku ⇒ String
TODO: Write general description for this method
14 15 16 |
# File 'lib/walmart_ap_is/models/item1.rb', line 14 def sku @sku end |
#summaries ⇒ Array[ItemSummaryByMarketplace]
TODO: Write general description for this method
18 19 20 |
# File 'lib/walmart_ap_is/models/item1.rb', line 18 def summaries @summaries end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
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 107 108 109 110 111 112 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 142 |
# File 'lib/walmart_ap_is/models/item1.rb', line 80 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. sku = hash.key?('sku') ? hash['sku'] : nil # Parameter is an array, so we need to iterate through it summaries = nil unless hash['summaries'].nil? summaries = [] hash['summaries'].each do |structure| summaries << (ItemSummaryByMarketplace.from_hash(structure) if structure) end end summaries = SKIP unless hash.key?('summaries') attributes = hash.key?('attributes') ? hash['attributes'] : SKIP # Parameter is an array, so we need to iterate through it issues = nil unless hash['issues'].nil? issues = [] hash['issues'].each do |structure| issues << (Issue.from_hash(structure) if structure) end end issues = SKIP unless hash.key?('issues') # Parameter is an array, so we need to iterate through it offers = nil unless hash['offers'].nil? offers = [] hash['offers'].each do |structure| offers << (ItemOfferByMarketplace.from_hash(structure) if structure) end end offers = SKIP unless hash.key?('offers') # Parameter is an array, so we need to iterate through it fulfillment_availability = nil unless hash['fulfillmentAvailability'].nil? fulfillment_availability = [] hash['fulfillmentAvailability'].each do |structure| fulfillment_availability << (FulfillmentAvailability.from_hash(structure) if structure) end end fulfillment_availability = SKIP unless hash.key?('fulfillmentAvailability') # 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. Item1.new(sku: sku, summaries: summaries, attributes: attributes, issues: issues, offers: offers, fulfillment_availability: fulfillment_availability, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/walmart_ap_is/models/item1.rb', line 37 def self.names @_hash = {} if @_hash.nil? @_hash['sku'] = 'sku' @_hash['summaries'] = 'summaries' @_hash['attributes'] = 'attributes' @_hash['issues'] = 'issues' @_hash['offers'] = 'offers' @_hash['fulfillment_availability'] = 'fulfillmentAvailability' @_hash end |
.nullables ⇒ Object
An array for nullable fields
60 61 62 |
# File 'lib/walmart_ap_is/models/item1.rb', line 60 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
49 50 51 52 53 54 55 56 57 |
# File 'lib/walmart_ap_is/models/item1.rb', line 49 def self.optionals %w[ summaries attributes issues offers fulfillment_availability ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
153 154 155 156 157 158 159 |
# File 'lib/walmart_ap_is/models/item1.rb', line 153 def inspect class_name = self.class.name.split('::').last "<#{class_name} sku: #{@sku.inspect}, summaries: #{@summaries.inspect}, attributes:"\ " #{@attributes.inspect}, issues: #{@issues.inspect}, offers: #{@offers.inspect},"\ " fulfillment_availability: #{@fulfillment_availability.inspect}, additional_properties:"\ " #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
145 146 147 148 149 150 |
# File 'lib/walmart_ap_is/models/item1.rb', line 145 def to_s class_name = self.class.name.split('::').last "<#{class_name} sku: #{@sku}, summaries: #{@summaries}, attributes: #{@attributes}, issues:"\ " #{@issues}, offers: #{@offers}, fulfillment_availability: #{@fulfillment_availability},"\ " additional_properties: #{@additional_properties}>" end |