Class: UspsApi::AssessedPackage
- Defined in:
- lib/usps_api/models/assessed_package.rb
Overview
Assessed package details used to determine the refund amount.
Instance Attribute Summary collapse
-
#height ⇒ Float
Assessed package details used to determine the refund amount.
-
#length ⇒ Float
Assessed package details used to determine the refund amount.
-
#mail_class ⇒ String
Assessed mail class of the package.
-
#packaging ⇒ String
Assessed packaging type of the package.
-
#weight ⇒ Float
Assessed weight of the package used to determine the refund amount.
-
#width ⇒ Float
Assessed package details used to determine the refund amount.
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(mail_class: SKIP, packaging: SKIP, weight: SKIP, length: SKIP, width: SKIP, height: SKIP, additional_properties: nil) ⇒ AssessedPackage
constructor
A new instance of AssessedPackage.
-
#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(mail_class: SKIP, packaging: SKIP, weight: SKIP, length: SKIP, width: SKIP, height: SKIP, additional_properties: nil) ⇒ AssessedPackage
Returns a new instance of AssessedPackage.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/usps_api/models/assessed_package.rb', line 65 def initialize(mail_class: SKIP, packaging: SKIP, weight: SKIP, length: SKIP, width: SKIP, height: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @mail_class = mail_class unless mail_class == SKIP @packaging = packaging unless packaging == SKIP @weight = weight unless weight == SKIP @length = length unless length == SKIP @width = width unless width == SKIP @height = height unless height == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#height ⇒ Float
Assessed package details used to determine the refund amount.
34 35 36 |
# File 'lib/usps_api/models/assessed_package.rb', line 34 def height @height end |
#length ⇒ Float
Assessed package details used to determine the refund amount.
26 27 28 |
# File 'lib/usps_api/models/assessed_package.rb', line 26 def length @length end |
#mail_class ⇒ String
Assessed mail class of the package.
14 15 16 |
# File 'lib/usps_api/models/assessed_package.rb', line 14 def mail_class @mail_class end |
#packaging ⇒ String
Assessed packaging type of the package.
18 19 20 |
# File 'lib/usps_api/models/assessed_package.rb', line 18 def packaging @packaging end |
#weight ⇒ Float
Assessed weight of the package used to determine the refund amount.
22 23 24 |
# File 'lib/usps_api/models/assessed_package.rb', line 22 def weight @weight end |
#width ⇒ Float
Assessed package details used to determine the refund amount.
30 31 32 |
# File 'lib/usps_api/models/assessed_package.rb', line 30 def width @width end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/usps_api/models/assessed_package.rb', line 81 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. mail_class = hash.key?('mailClass') ? hash['mailClass'] : SKIP packaging = hash.key?('packaging') ? hash['packaging'] : SKIP weight = hash.key?('weight') ? hash['weight'] : SKIP length = hash.key?('length') ? hash['length'] : SKIP width = hash.key?('width') ? hash['width'] : SKIP height = hash.key?('height') ? hash['height'] : 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. AssessedPackage.new(mail_class: mail_class, packaging: packaging, weight: weight, length: length, width: width, height: height, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/usps_api/models/assessed_package.rb', line 37 def self.names @_hash = {} if @_hash.nil? @_hash['mail_class'] = 'mailClass' @_hash['packaging'] = 'packaging' @_hash['weight'] = 'weight' @_hash['length'] = 'length' @_hash['width'] = 'width' @_hash['height'] = 'height' @_hash end |
.nullables ⇒ Object
An array for nullable fields
61 62 63 |
# File 'lib/usps_api/models/assessed_package.rb', line 61 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/usps_api/models/assessed_package.rb', line 49 def self.optionals %w[ mail_class packaging weight length width height ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
118 119 120 121 122 123 |
# File 'lib/usps_api/models/assessed_package.rb', line 118 def inspect class_name = self.class.name.split('::').last "<#{class_name} mail_class: #{@mail_class.inspect}, packaging: #{@packaging.inspect},"\ " weight: #{@weight.inspect}, length: #{@length.inspect}, width: #{@width.inspect}, height:"\ " #{@height.inspect}, additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
110 111 112 113 114 115 |
# File 'lib/usps_api/models/assessed_package.rb', line 110 def to_s class_name = self.class.name.split('::').last "<#{class_name} mail_class: #{@mail_class}, packaging: #{@packaging}, weight: #{@weight},"\ " length: #{@length}, width: #{@width}, height: #{@height}, additional_properties:"\ " #{@additional_properties}>" end |