Class: UspsApi::TrailerInfo
- Defined in:
- lib/usps_api/models/trailer_info.rb
Overview
Information about the trailer for the appointment.
Instance Attribute Summary collapse
-
#bill_of_lading_number_array ⇒ Array[BillOfLadingNumberArray]
max of two values in the array.
-
#carrier ⇒ Carrier
Details about the carrier for the appointment.
-
#trailer ⇒ Array[Trailer]
max of two objects in the array.
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(trailer: SKIP, carrier: SKIP, bill_of_lading_number_array: SKIP, additional_properties: nil) ⇒ TrailerInfo
constructor
A new instance of TrailerInfo.
-
#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(trailer: SKIP, carrier: SKIP, bill_of_lading_number_array: SKIP, additional_properties: nil) ⇒ TrailerInfo
Returns a new instance of TrailerInfo.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/usps_api/models/trailer_info.rb', line 47 def initialize(trailer: SKIP, carrier: SKIP, bill_of_lading_number_array: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @trailer = trailer unless trailer == SKIP @carrier = carrier unless carrier == SKIP unless bill_of_lading_number_array == SKIP @bill_of_lading_number_array = bill_of_lading_number_array end @additional_properties = additional_properties end |
Instance Attribute Details
#bill_of_lading_number_array ⇒ Array[BillOfLadingNumberArray]
max of two values in the array
22 23 24 |
# File 'lib/usps_api/models/trailer_info.rb', line 22 def bill_of_lading_number_array @bill_of_lading_number_array end |
#carrier ⇒ Carrier
Details about the carrier for the appointment.
18 19 20 |
# File 'lib/usps_api/models/trailer_info.rb', line 18 def carrier @carrier end |
#trailer ⇒ Array[Trailer]
max of two objects in the array
14 15 16 |
# File 'lib/usps_api/models/trailer_info.rb', line 14 def trailer @trailer end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
63 64 65 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 |
# File 'lib/usps_api/models/trailer_info.rb', line 63 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 trailer = nil unless hash['trailer'].nil? trailer = [] hash['trailer'].each do |structure| trailer << (Trailer.from_hash(structure) if structure) end end trailer = SKIP unless hash.key?('trailer') carrier = Carrier.from_hash(hash['carrier']) if hash['carrier'] # Parameter is an array, so we need to iterate through it bill_of_lading_number_array = nil unless hash['billOfLadingNumberArray'].nil? bill_of_lading_number_array = [] hash['billOfLadingNumberArray'].each do |structure| bill_of_lading_number_array << (BillOfLadingNumberArray.from_hash(structure) if structure) end end bill_of_lading_number_array = SKIP unless hash.key?('billOfLadingNumberArray') # 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. TrailerInfo.new(trailer: trailer, carrier: carrier, bill_of_lading_number_array: bill_of_lading_number_array, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
25 26 27 28 29 30 31 |
# File 'lib/usps_api/models/trailer_info.rb', line 25 def self.names @_hash = {} if @_hash.nil? @_hash['trailer'] = 'trailer' @_hash['carrier'] = 'carrier' @_hash['bill_of_lading_number_array'] = 'billOfLadingNumberArray' @_hash end |
.nullables ⇒ Object
An array for nullable fields
43 44 45 |
# File 'lib/usps_api/models/trailer_info.rb', line 43 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
34 35 36 37 38 39 40 |
# File 'lib/usps_api/models/trailer_info.rb', line 34 def self.optionals %w[ trailer carrier bill_of_lading_number_array ] 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/trailer_info.rb', line 111 def inspect class_name = self.class.name.split('::').last "<#{class_name} trailer: #{@trailer.inspect}, carrier: #{@carrier.inspect},"\ " bill_of_lading_number_array: #{@bill_of_lading_number_array.inspect},"\ " additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
104 105 106 107 108 |
# File 'lib/usps_api/models/trailer_info.rb', line 104 def to_s class_name = self.class.name.split('::').last "<#{class_name} trailer: #{@trailer}, carrier: #{@carrier}, bill_of_lading_number_array:"\ " #{@bill_of_lading_number_array}, additional_properties: #{@additional_properties}>" end |