Class: UspsApi::ExtraService12
- Defined in:
- lib/usps_api/models/extra_service12.rb
Overview
ExtraService12 Model.
Instance Attribute Summary collapse
-
#extra_service ⇒ ExtraServiceCodes1
Extra Service Code requested * ‘370` - USPS Delivery Duties Paid Fee * `813` - HAZMAT Class 7 - Radioactive Materials Package * `820` - HAZMAT Class 9 - Lithium batteries, unmarked package * `826` - HAZMAT Division 6.2 – Infectious Substances Package * `857` - Hazardous Material * `930` - Insurance <= $500 * `931` - Insurance > $500 * `955` - Return Receipt (Unsupported as of 01/19/2025).
-
#name ⇒ String
Description of the Extra Service.
-
#price ⇒ Float
The postage rate.
-
#price_type ⇒ InternationalPriceType
Price type can be * ‘RETAIL’ * ‘COMMERCIAL’ * ‘COMMERCIAL_BASE’ * ‘COMMERCIAL_PLUS’ * ‘CONTRACT’.
-
#sku ⇒ String
The stock keeping unit for the designated rate.
-
#warnings ⇒ Array[ContainersContainerWarnings]
A list of warnings associated with the rate calculation.
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(sku: SKIP, price: SKIP, price_type: SKIP, extra_service: SKIP, name: SKIP, warnings: SKIP, additional_properties: nil) ⇒ ExtraService12
constructor
A new instance of ExtraService12.
-
#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(sku: SKIP, price: SKIP, price_type: SKIP, extra_service: SKIP, name: SKIP, warnings: SKIP, additional_properties: nil) ⇒ ExtraService12
Returns a new instance of ExtraService12.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/usps_api/models/extra_service12.rb', line 74 def initialize(sku: SKIP, price: SKIP, price_type: SKIP, extra_service: SKIP, name: SKIP, warnings: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @sku = sku unless sku == SKIP @price = price unless price == SKIP @price_type = price_type unless price_type == SKIP @extra_service = extra_service unless extra_service == SKIP @name = name unless name == SKIP @warnings = warnings unless warnings == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#extra_service ⇒ ExtraServiceCodes1
Extra Service Code requested
-
‘370` - USPS Delivery Duties Paid Fee
-
‘813` - HAZMAT Class 7 - Radioactive Materials Package
-
‘820` - HAZMAT Class 9 - Lithium batteries, unmarked package
-
‘826` - HAZMAT Division 6.2 – Infectious Substances Package
-
‘857` - Hazardous Material
-
‘930` - Insurance <= $500
-
‘931` - Insurance > $500
-
‘955` - Return Receipt (Unsupported as of 01/19/2025)
35 36 37 |
# File 'lib/usps_api/models/extra_service12.rb', line 35 def extra_service @extra_service end |
#name ⇒ String
Description of the Extra Service
39 40 41 |
# File 'lib/usps_api/models/extra_service12.rb', line 39 def name @name end |
#price ⇒ Float
The postage rate.
18 19 20 |
# File 'lib/usps_api/models/extra_service12.rb', line 18 def price @price end |
#price_type ⇒ InternationalPriceType
Price type can be * ‘RETAIL’ * ‘COMMERCIAL’ * ‘COMMERCIAL_BASE’ * ‘COMMERCIAL_PLUS’ * ‘CONTRACT’
23 24 25 |
# File 'lib/usps_api/models/extra_service12.rb', line 23 def price_type @price_type end |
#sku ⇒ String
The stock keeping unit for the designated rate.
14 15 16 |
# File 'lib/usps_api/models/extra_service12.rb', line 14 def sku @sku end |
#warnings ⇒ Array[ContainersContainerWarnings]
A list of warnings associated with the rate calculation.
43 44 45 |
# File 'lib/usps_api/models/extra_service12.rb', line 43 def warnings @warnings end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/usps_api/models/extra_service12.rb', line 90 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. sku = hash.key?('SKU') ? hash['SKU'] : SKIP price = hash.key?('price') ? hash['price'] : SKIP price_type = hash.key?('priceType') ? hash['priceType'] : SKIP extra_service = hash.key?('extraService') ? hash['extraService'] : SKIP name = hash.key?('name') ? hash['name'] : SKIP # Parameter is an array, so we need to iterate through it warnings = nil unless hash['warnings'].nil? warnings = [] hash['warnings'].each do |structure| warnings << (ContainersContainerWarnings.from_hash(structure) if structure) end end warnings = SKIP unless hash.key?('warnings') # 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. ExtraService12.new(sku: sku, price: price, price_type: price_type, extra_service: extra_service, name: name, warnings: warnings, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/usps_api/models/extra_service12.rb', line 46 def self.names @_hash = {} if @_hash.nil? @_hash['sku'] = 'SKU' @_hash['price'] = 'price' @_hash['price_type'] = 'priceType' @_hash['extra_service'] = 'extraService' @_hash['name'] = 'name' @_hash['warnings'] = 'warnings' @_hash end |
.nullables ⇒ Object
An array for nullable fields
70 71 72 |
# File 'lib/usps_api/models/extra_service12.rb', line 70 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/usps_api/models/extra_service12.rb', line 58 def self.optionals %w[ sku price price_type extra_service name warnings ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
136 137 138 139 140 141 |
# File 'lib/usps_api/models/extra_service12.rb', line 136 def inspect class_name = self.class.name.split('::').last "<#{class_name} sku: #{@sku.inspect}, price: #{@price.inspect}, price_type:"\ " #{@price_type.inspect}, extra_service: #{@extra_service.inspect}, name: #{@name.inspect},"\ " warnings: #{@warnings.inspect}, additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
128 129 130 131 132 133 |
# File 'lib/usps_api/models/extra_service12.rb', line 128 def to_s class_name = self.class.name.split('::').last "<#{class_name} sku: #{@sku}, price: #{@price}, price_type: #{@price_type}, extra_service:"\ " #{@extra_service}, name: #{@name}, warnings: #{@warnings}, additional_properties:"\ " #{@additional_properties}>" end |