Class: WalmartApIs::ShipPackage
- Defined in:
- lib/walmart_ap_is/models/ship_package.rb
Overview
ShipPackage Model.
Instance Attribute Summary collapse
-
#dimensions ⇒ PackageDimensions1
Physical dimensions of a shipped package.
-
#lines ⇒ Array[ShipPackageLine]
Physical dimensions of a shipped package.
-
#package_id ⇒ String
Caller-supplied stable identifier for this physical package.
-
#tracking_info ⇒ TrackingInfo
Caller-supplied stable identifier for this physical package.
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(tracking_info:, lines:, package_id: SKIP, dimensions: SKIP, additional_properties: nil) ⇒ ShipPackage
constructor
A new instance of ShipPackage.
-
#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(tracking_info:, lines:, package_id: SKIP, dimensions: SKIP, additional_properties: nil) ⇒ ShipPackage
Returns a new instance of ShipPackage.
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/walmart_ap_is/models/ship_package.rb', line 59 def initialize(tracking_info:, lines:, package_id: SKIP, dimensions: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @package_id = package_id unless package_id == SKIP @tracking_info = tracking_info @dimensions = dimensions unless dimensions == SKIP @lines = lines @additional_properties = additional_properties end |
Instance Attribute Details
#dimensions ⇒ PackageDimensions1
Physical dimensions of a shipped package. All numeric values are non-negative; unit enums avoid the unit-ambiguity bug that bit gmp-orders-mono PayloadUtil pre-2024.
28 29 30 |
# File 'lib/walmart_ap_is/models/ship_package.rb', line 28 def dimensions @dimensions end |
#lines ⇒ Array[ShipPackageLine]
Physical dimensions of a shipped package. All numeric values are non-negative; unit enums avoid the unit-ambiguity bug that bit gmp-orders-mono PayloadUtil pre-2024.
34 35 36 |
# File 'lib/walmart_ap_is/models/ship_package.rb', line 34 def lines @lines end |
#package_id ⇒ String
Caller-supplied stable identifier for this physical package. Optional — server falls back to the package's tracking number when echoed in the response.
16 17 18 |
# File 'lib/walmart_ap_is/models/ship_package.rb', line 16 def package_id @package_id end |
#tracking_info ⇒ TrackingInfo
Caller-supplied stable identifier for this physical package. Optional — server falls back to the package's tracking number when echoed in the response.
22 23 24 |
# File 'lib/walmart_ap_is/models/ship_package.rb', line 22 def tracking_info @tracking_info end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
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 |
# File 'lib/walmart_ap_is/models/ship_package.rb', line 72 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. tracking_info = TrackingInfo.from_hash(hash['trackingInfo']) if hash['trackingInfo'] # Parameter is an array, so we need to iterate through it lines = nil unless hash['lines'].nil? lines = [] hash['lines'].each do |structure| lines << (ShipPackageLine.from_hash(structure) if structure) end end lines = nil unless hash.key?('lines') package_id = hash.key?('packageId') ? hash['packageId'] : SKIP dimensions = PackageDimensions1.from_hash(hash['dimensions']) if hash['dimensions'] # 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. ShipPackage.new(tracking_info: tracking_info, lines: lines, package_id: package_id, dimensions: dimensions, 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 |
# File 'lib/walmart_ap_is/models/ship_package.rb', line 37 def self.names @_hash = {} if @_hash.nil? @_hash['package_id'] = 'packageId' @_hash['tracking_info'] = 'trackingInfo' @_hash['dimensions'] = 'dimensions' @_hash['lines'] = 'lines' @_hash end |
.nullables ⇒ Object
An array for nullable fields
55 56 57 |
# File 'lib/walmart_ap_is/models/ship_package.rb', line 55 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
47 48 49 50 51 52 |
# File 'lib/walmart_ap_is/models/ship_package.rb', line 47 def self.optionals %w[ package_id dimensions ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
113 114 115 116 117 118 |
# File 'lib/walmart_ap_is/models/ship_package.rb', line 113 def inspect class_name = self.class.name.split('::').last "<#{class_name} package_id: #{@package_id.inspect}, tracking_info:"\ " #{@tracking_info.inspect}, dimensions: #{@dimensions.inspect}, lines: #{@lines.inspect},"\ " additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
106 107 108 109 110 |
# File 'lib/walmart_ap_is/models/ship_package.rb', line 106 def to_s class_name = self.class.name.split('::').last "<#{class_name} package_id: #{@package_id}, tracking_info: #{@tracking_info}, dimensions:"\ " #{@dimensions}, lines: #{@lines}, additional_properties: #{@additional_properties}>" end |