Class: WalmartApIs::Package
- Defined in:
- lib/walmart_ap_is/models/package.rb
Overview
Package Model.
Instance Attribute Summary collapse
-
#dimensions ⇒ PackageDimensions
TODO: Write general description for this method.
-
#insured_value ⇒ Money
TODO: Write general description for this method.
-
#is_hazmat ⇒ TrueClass | FalseClass
TODO: Write general description for this method.
-
#items ⇒ Array[Item3]
Seller-supplied unique id for this package within the shipment.
-
#package_client_reference_id ⇒ String
Seller-supplied unique id for this package within the shipment.
-
#seller_declared_value ⇒ Money
TODO: Write general description for this method.
-
#weight ⇒ Weight
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(dimensions:, weight:, package_client_reference_id:, insured_value: SKIP, is_hazmat: SKIP, seller_declared_value: SKIP, items: SKIP, additional_properties: nil) ⇒ Package
constructor
A new instance of Package.
-
#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(dimensions:, weight:, package_client_reference_id:, insured_value: SKIP, is_hazmat: SKIP, seller_declared_value: SKIP, items: SKIP, additional_properties: nil) ⇒ Package
Returns a new instance of Package.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/walmart_ap_is/models/package.rb', line 68 def initialize(dimensions:, weight:, package_client_reference_id:, insured_value: SKIP, is_hazmat: SKIP, seller_declared_value: SKIP, items: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @dimensions = dimensions @weight = weight @insured_value = insured_value unless insured_value == SKIP @is_hazmat = is_hazmat unless is_hazmat == SKIP @seller_declared_value = seller_declared_value unless seller_declared_value == SKIP @package_client_reference_id = package_client_reference_id @items = items unless items == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#dimensions ⇒ PackageDimensions
TODO: Write general description for this method
14 15 16 |
# File 'lib/walmart_ap_is/models/package.rb', line 14 def dimensions @dimensions end |
#insured_value ⇒ Money
TODO: Write general description for this method
22 23 24 |
# File 'lib/walmart_ap_is/models/package.rb', line 22 def insured_value @insured_value end |
#is_hazmat ⇒ TrueClass | FalseClass
TODO: Write general description for this method
26 27 28 |
# File 'lib/walmart_ap_is/models/package.rb', line 26 def is_hazmat @is_hazmat end |
#items ⇒ Array[Item3]
Seller-supplied unique id for this package within the shipment.
38 39 40 |
# File 'lib/walmart_ap_is/models/package.rb', line 38 def items @items end |
#package_client_reference_id ⇒ String
Seller-supplied unique id for this package within the shipment.
34 35 36 |
# File 'lib/walmart_ap_is/models/package.rb', line 34 def package_client_reference_id @package_client_reference_id end |
#seller_declared_value ⇒ Money
TODO: Write general description for this method
30 31 32 |
# File 'lib/walmart_ap_is/models/package.rb', line 30 def seller_declared_value @seller_declared_value end |
#weight ⇒ Weight
TODO: Write general description for this method
18 19 20 |
# File 'lib/walmart_ap_is/models/package.rb', line 18 def weight @weight end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
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 |
# File 'lib/walmart_ap_is/models/package.rb', line 86 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. dimensions = PackageDimensions.from_hash(hash['dimensions']) if hash['dimensions'] weight = Weight.from_hash(hash['weight']) if hash['weight'] package_client_reference_id = hash.key?('packageClientReferenceId') ? hash['packageClientReferenceId'] : nil insured_value = Money.from_hash(hash['insuredValue']) if hash['insuredValue'] is_hazmat = hash.key?('isHazmat') ? hash['isHazmat'] : SKIP seller_declared_value = Money.from_hash(hash['sellerDeclaredValue']) if hash['sellerDeclaredValue'] # Parameter is an array, so we need to iterate through it items = nil unless hash['items'].nil? items = [] hash['items'].each do |structure| items << (Item3.from_hash(structure) if structure) end end items = SKIP unless hash.key?('items') # 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. Package.new(dimensions: dimensions, weight: weight, package_client_reference_id: package_client_reference_id, insured_value: insured_value, is_hazmat: is_hazmat, seller_declared_value: seller_declared_value, items: items, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/walmart_ap_is/models/package.rb', line 41 def self.names @_hash = {} if @_hash.nil? @_hash['dimensions'] = 'dimensions' @_hash['weight'] = 'weight' @_hash['insured_value'] = 'insuredValue' @_hash['is_hazmat'] = 'isHazmat' @_hash['seller_declared_value'] = 'sellerDeclaredValue' @_hash['package_client_reference_id'] = 'packageClientReferenceId' @_hash['items'] = 'items' @_hash end |
.nullables ⇒ Object
An array for nullable fields
64 65 66 |
# File 'lib/walmart_ap_is/models/package.rb', line 64 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
54 55 56 57 58 59 60 61 |
# File 'lib/walmart_ap_is/models/package.rb', line 54 def self.optionals %w[ insured_value is_hazmat seller_declared_value items ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
137 138 139 140 141 142 143 144 |
# File 'lib/walmart_ap_is/models/package.rb', line 137 def inspect class_name = self.class.name.split('::').last "<#{class_name} dimensions: #{@dimensions.inspect}, weight: #{@weight.inspect},"\ " insured_value: #{@insured_value.inspect}, is_hazmat: #{@is_hazmat.inspect},"\ " seller_declared_value: #{@seller_declared_value.inspect}, package_client_reference_id:"\ " #{@package_client_reference_id.inspect}, items: #{@items.inspect}, additional_properties:"\ " #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
128 129 130 131 132 133 134 |
# File 'lib/walmart_ap_is/models/package.rb', line 128 def to_s class_name = self.class.name.split('::').last "<#{class_name} dimensions: #{@dimensions}, weight: #{@weight}, insured_value:"\ " #{@insured_value}, is_hazmat: #{@is_hazmat}, seller_declared_value:"\ " #{@seller_declared_value}, package_client_reference_id: #{@package_client_reference_id},"\ " items: #{@items}, additional_properties: #{@additional_properties}>" end |