Class: UspsApi::OriginalPackage1
- Defined in:
- lib/usps_api/models/original_package1.rb
Overview
-
Note: packageOptions.originalPackage fields cannot be used in combination
with packageOptions.returnReceiptTracking.
Instance Attribute Summary collapse
-
#original_construct_code ⇒ String
A 3-character code to identify the construct of the Original Label Tracking Number.
-
#original_tracking_number ⇒ String
The tracking number associated with the package before it was over labeled.
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.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(original_tracking_number:, original_construct_code:, additional_properties: nil) ⇒ OriginalPackage1
constructor
A new instance of OriginalPackage1.
-
#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(original_tracking_number:, original_construct_code:, additional_properties: nil) ⇒ OriginalPackage1
Returns a new instance of OriginalPackage1.
44 45 46 47 48 49 50 51 52 |
# File 'lib/usps_api/models/original_package1.rb', line 44 def initialize(original_tracking_number:, original_construct_code:, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @original_tracking_number = original_tracking_number @original_construct_code = original_construct_code @additional_properties = additional_properties end |
Instance Attribute Details
#original_construct_code ⇒ String
A 3-character code to identify the construct of the Original Label Tracking Number
24 25 26 |
# File 'lib/usps_api/models/original_package1.rb', line 24 def original_construct_code @original_construct_code end |
#original_tracking_number ⇒ String
The tracking number associated with the package before it was over labeled. For accurate tracking, this field requires a concatenated string consisting of the routingInformation and trackingNumber from the original label response.
19 20 21 |
# File 'lib/usps_api/models/original_package1.rb', line 19 def original_tracking_number @original_tracking_number end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/usps_api/models/original_package1.rb', line 55 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. original_tracking_number = hash.key?('originalTrackingNumber') ? hash['originalTrackingNumber'] : nil original_construct_code = hash.key?('originalConstructCode') ? hash['originalConstructCode'] : nil # 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. OriginalPackage1.new(original_tracking_number: original_tracking_number, original_construct_code: original_construct_code, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
27 28 29 30 31 32 |
# File 'lib/usps_api/models/original_package1.rb', line 27 def self.names @_hash = {} if @_hash.nil? @_hash['original_tracking_number'] = 'originalTrackingNumber' @_hash['original_construct_code'] = 'originalConstructCode' @_hash end |
.nullables ⇒ Object
An array for nullable fields
40 41 42 |
# File 'lib/usps_api/models/original_package1.rb', line 40 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
35 36 37 |
# File 'lib/usps_api/models/original_package1.rb', line 35 def self.optionals [] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/usps_api/models/original_package1.rb', line 79 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.original_tracking_number, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.original_construct_code, ->(val) { val.instance_of? String }) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['originalTrackingNumber'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['originalConstructCode'], ->(val) { val.instance_of? String }) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
108 109 110 111 112 113 |
# File 'lib/usps_api/models/original_package1.rb', line 108 def inspect class_name = self.class.name.split('::').last "<#{class_name} original_tracking_number: #{@original_tracking_number.inspect},"\ " original_construct_code: #{@original_construct_code.inspect}, additional_properties:"\ " #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
100 101 102 103 104 105 |
# File 'lib/usps_api/models/original_package1.rb', line 100 def to_s class_name = self.class.name.split('::').last "<#{class_name} original_tracking_number: #{@original_tracking_number},"\ " original_construct_code: #{@original_construct_code}, additional_properties:"\ " #{@additional_properties}>" end |