Class: UspsApi::Pallet
- Defined in:
- lib/usps_api/models/pallet.rb
Overview
Pallet Model.
Instance Attribute Summary collapse
-
#count ⇒ Integer
Count for pallets.
-
#handling_unit_type ⇒ HandlingUnitType
Types of containers used in appointment.
-
#pallet_pre_sort_level ⇒ Array[PalletPreSortLevel]
Required for Create actions.
-
#pallet_type ⇒ PalletType
Pallet type used to house handing units.
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(pallet_pre_sort_level: SKIP, count: SKIP, handling_unit_type: SKIP, pallet_type: SKIP, additional_properties: nil) ⇒ Pallet
constructor
A new instance of Pallet.
-
#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(pallet_pre_sort_level: SKIP, count: SKIP, handling_unit_type: SKIP, pallet_type: SKIP, additional_properties: nil) ⇒ Pallet
Returns a new instance of Pallet.
54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/usps_api/models/pallet.rb', line 54 def initialize(pallet_pre_sort_level: SKIP, count: SKIP, handling_unit_type: SKIP, pallet_type: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @pallet_pre_sort_level = pallet_pre_sort_level unless pallet_pre_sort_level == SKIP @count = count unless count == SKIP @handling_unit_type = handling_unit_type unless handling_unit_type == SKIP @pallet_type = pallet_type unless pallet_type == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#count ⇒ Integer
Count for pallets. Required for Create actions. (One of pallets, sacks, trays count)
19 20 21 |
# File 'lib/usps_api/models/pallet.rb', line 19 def count @count end |
#handling_unit_type ⇒ HandlingUnitType
Types of containers used in appointment. Required for Create actions.
23 24 25 |
# File 'lib/usps_api/models/pallet.rb', line 23 def handling_unit_type @handling_unit_type end |
#pallet_pre_sort_level ⇒ Array[PalletPreSortLevel]
Required for Create actions.
14 15 16 |
# File 'lib/usps_api/models/pallet.rb', line 14 def pallet_pre_sort_level @pallet_pre_sort_level end |
#pallet_type ⇒ PalletType
Pallet type used to house handing units. Required for Create actions.
27 28 29 |
# File 'lib/usps_api/models/pallet.rb', line 27 def pallet_type @pallet_type end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
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 |
# File 'lib/usps_api/models/pallet.rb', line 68 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. # Parameter is an array, so we need to iterate through it pallet_pre_sort_level = nil unless hash['palletPreSortLevel'].nil? pallet_pre_sort_level = [] hash['palletPreSortLevel'].each do |structure| pallet_pre_sort_level << (PalletPreSortLevel.from_hash(structure) if structure) end end pallet_pre_sort_level = SKIP unless hash.key?('palletPreSortLevel') count = hash.key?('count') ? hash['count'] : SKIP handling_unit_type = hash.key?('handlingUnitType') ? hash['handlingUnitType'] : SKIP pallet_type = hash.key?('palletType') ? hash['palletType'] : SKIP # 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. Pallet.new(pallet_pre_sort_level: pallet_pre_sort_level, count: count, handling_unit_type: handling_unit_type, pallet_type: pallet_type, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
30 31 32 33 34 35 36 37 |
# File 'lib/usps_api/models/pallet.rb', line 30 def self.names @_hash = {} if @_hash.nil? @_hash['pallet_pre_sort_level'] = 'palletPreSortLevel' @_hash['count'] = 'count' @_hash['handling_unit_type'] = 'handlingUnitType' @_hash['pallet_type'] = 'palletType' @_hash end |
.nullables ⇒ Object
An array for nullable fields
50 51 52 |
# File 'lib/usps_api/models/pallet.rb', line 50 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
40 41 42 43 44 45 46 47 |
# File 'lib/usps_api/models/pallet.rb', line 40 def self.optionals %w[ pallet_pre_sort_level count handling_unit_type pallet_type ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
111 112 113 114 115 116 |
# File 'lib/usps_api/models/pallet.rb', line 111 def inspect class_name = self.class.name.split('::').last "<#{class_name} pallet_pre_sort_level: #{@pallet_pre_sort_level.inspect}, count:"\ " #{@count.inspect}, handling_unit_type: #{@handling_unit_type.inspect}, pallet_type:"\ " #{@pallet_type.inspect}, additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
103 104 105 106 107 108 |
# File 'lib/usps_api/models/pallet.rb', line 103 def to_s class_name = self.class.name.split('::').last "<#{class_name} pallet_pre_sort_level: #{@pallet_pre_sort_level}, count: #{@count},"\ " handling_unit_type: #{@handling_unit_type}, pallet_type: #{@pallet_type},"\ " additional_properties: #{@additional_properties}>" end |