Class: UspsApi::NoQrCodeResponse
- Defined in:
- lib/usps_api/models/no_qr_code_response.rb
Overview
Generated when no QR Code is available for ZIP Code and tracking number
Instance Attribute Summary collapse
-
#alert ⇒ String
The reason why the QR code is not available.
-
#tracking_number ⇒ String
The package tracking Number.
-
#zip_code ⇒ String
The 11-digit delivery ZIP Code.
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(tracking_number:, zip_code:, alert:, additional_properties: nil) ⇒ NoQrCodeResponse
constructor
A new instance of NoQrCodeResponse.
-
#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:, zip_code:, alert:, additional_properties: nil) ⇒ NoQrCodeResponse
Returns a new instance of NoQrCodeResponse.
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/usps_api/models/no_qr_code_response.rb', line 43 def initialize(tracking_number:, zip_code:, alert:, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @tracking_number = tracking_number @zip_code = zip_code @alert = alert @additional_properties = additional_properties end |
Instance Attribute Details
#alert ⇒ String
The reason why the QR code is not available.
22 23 24 |
# File 'lib/usps_api/models/no_qr_code_response.rb', line 22 def alert @alert end |
#tracking_number ⇒ String
The package tracking Number.
14 15 16 |
# File 'lib/usps_api/models/no_qr_code_response.rb', line 14 def tracking_number @tracking_number end |
#zip_code ⇒ String
The 11-digit delivery ZIP Code.
18 19 20 |
# File 'lib/usps_api/models/no_qr_code_response.rb', line 18 def zip_code @zip_code 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 76 |
# File 'lib/usps_api/models/no_qr_code_response.rb', line 55 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. tracking_number = hash.key?('trackingNumber') ? hash['trackingNumber'] : nil zip_code = hash.key?('ZIPCode') ? hash['ZIPCode'] : nil alert = hash.key?('alert') ? hash['alert'] : 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. NoQrCodeResponse.new(tracking_number: tracking_number, zip_code: zip_code, alert: alert, 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/no_qr_code_response.rb', line 25 def self.names @_hash = {} if @_hash.nil? @_hash['tracking_number'] = 'trackingNumber' @_hash['zip_code'] = 'ZIPCode' @_hash['alert'] = 'alert' @_hash end |
.nullables ⇒ Object
An array for nullable fields
39 40 41 |
# File 'lib/usps_api/models/no_qr_code_response.rb', line 39 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
34 35 36 |
# File 'lib/usps_api/models/no_qr_code_response.rb', line 34 def self.optionals [] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/usps_api/models/no_qr_code_response.rb', line 80 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.tracking_number, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.zip_code, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.alert, ->(val) { val.instance_of? String }) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['trackingNumber'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['ZIPCode'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['alert'], ->(val) { val.instance_of? String }) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
112 113 114 115 116 117 |
# File 'lib/usps_api/models/no_qr_code_response.rb', line 112 def inspect class_name = self.class.name.split('::').last "<#{class_name} tracking_number: #{@tracking_number.inspect}, zip_code:"\ " #{@zip_code.inspect}, alert: #{@alert.inspect}, additional_properties:"\ " #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
105 106 107 108 109 |
# File 'lib/usps_api/models/no_qr_code_response.rb', line 105 def to_s class_name = self.class.name.split('::').last "<#{class_name} tracking_number: #{@tracking_number}, zip_code: #{@zip_code}, alert:"\ " #{@alert}, additional_properties: #{@additional_properties}>" end |