Class: UspsApi::TrackingNumber1
- Defined in:
- lib/usps_api/models/tracking_number1.rb
Overview
TrackingNumber1 Model.
Instance Attribute Summary collapse
-
#errors ⇒ Array[Error11]
The unique pieceID of the tracking number for the campaign.
-
#piece_id ⇒ Integer
The unique pieceID of the tracking number for the campaign.
-
#tracking_number ⇒ String
The tracking number included in the request.
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_number: SKIP, piece_id: SKIP, errors: SKIP, additional_properties: nil) ⇒ TrackingNumber1
constructor
A new instance of TrackingNumber1.
-
#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_number: SKIP, piece_id: SKIP, errors: SKIP, additional_properties: nil) ⇒ TrackingNumber1
Returns a new instance of TrackingNumber1.
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/usps_api/models/tracking_number1.rb', line 55 def initialize(tracking_number: SKIP, piece_id: SKIP, errors: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @tracking_number = tracking_number unless tracking_number == SKIP @piece_id = piece_id unless piece_id == SKIP @errors = errors unless errors == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#errors ⇒ Array[Error11]
The unique pieceID of the tracking number for the campaign. This pieceID will be unique if a tracking number is added to multiple campaigns. The pieceID will be non-null if the tracking number was successfully added to the package campaign.
28 29 30 |
# File 'lib/usps_api/models/tracking_number1.rb', line 28 def errors @errors end |
#piece_id ⇒ Integer
The unique pieceID of the tracking number for the campaign. This pieceID will be unique if a tracking number is added to multiple campaigns. The pieceID will be non-null if the tracking number was successfully added to the package campaign.
21 22 23 |
# File 'lib/usps_api/models/tracking_number1.rb', line 21 def piece_id @piece_id end |
#tracking_number ⇒ String
The tracking number included in the request.
14 15 16 |
# File 'lib/usps_api/models/tracking_number1.rb', line 14 def tracking_number @tracking_number end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
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 |
# File 'lib/usps_api/models/tracking_number1.rb', line 67 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. tracking_number = hash.key?('trackingNumber') ? hash['trackingNumber'] : SKIP piece_id = hash.key?('pieceID') ? hash['pieceID'] : SKIP # Parameter is an array, so we need to iterate through it errors = nil unless hash['errors'].nil? errors = [] hash['errors'].each do |structure| errors << (Error11.from_hash(structure) if structure) end end errors = SKIP unless hash.key?('errors') # 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. TrackingNumber1.new(tracking_number: tracking_number, piece_id: piece_id, errors: errors, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
31 32 33 34 35 36 37 |
# File 'lib/usps_api/models/tracking_number1.rb', line 31 def self.names @_hash = {} if @_hash.nil? @_hash['tracking_number'] = 'trackingNumber' @_hash['piece_id'] = 'pieceID' @_hash['errors'] = 'errors' @_hash end |
.nullables ⇒ Object
An array for nullable fields
49 50 51 52 53 |
# File 'lib/usps_api/models/tracking_number1.rb', line 49 def self.nullables %w[ piece_id ] end |
.optionals ⇒ Object
An array for optional fields
40 41 42 43 44 45 46 |
# File 'lib/usps_api/models/tracking_number1.rb', line 40 def self.optionals %w[ tracking_number piece_id errors ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
107 108 109 110 111 112 |
# File 'lib/usps_api/models/tracking_number1.rb', line 107 def inspect class_name = self.class.name.split('::').last "<#{class_name} tracking_number: #{@tracking_number.inspect}, piece_id:"\ " #{@piece_id.inspect}, errors: #{@errors.inspect}, additional_properties:"\ " #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
100 101 102 103 104 |
# File 'lib/usps_api/models/tracking_number1.rb', line 100 def to_s class_name = self.class.name.split('::').last "<#{class_name} tracking_number: #{@tracking_number}, piece_id: #{@piece_id}, errors:"\ " #{@errors}, additional_properties: #{@additional_properties}>" end |