Class: UspsApi::LabelsExtraServiceResponse
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- UspsApi::LabelsExtraServiceResponse
- Defined in:
- lib/usps_api/models/labels_extra_service_response.rb
Overview
Extra services requested on the container
Instance Attribute Summary collapse
-
#name ⇒ String
Name of the extra service.
-
#price ⇒ Float
The price for the extra service.
-
#sku ⇒ String
SKU of the extra service.
-
#warnings ⇒ Array[Warning]
Warnings and additional details around the Extra Services.
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(name: SKIP, sku: SKIP, price: SKIP, warnings: SKIP) ⇒ LabelsExtraServiceResponse
constructor
A new instance of LabelsExtraServiceResponse.
-
#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(name: SKIP, sku: SKIP, price: SKIP, warnings: SKIP) ⇒ LabelsExtraServiceResponse
Returns a new instance of LabelsExtraServiceResponse.
53 54 55 56 57 58 |
# File 'lib/usps_api/models/labels_extra_service_response.rb', line 53 def initialize(name: SKIP, sku: SKIP, price: SKIP, warnings: SKIP) @name = name unless name == SKIP @sku = sku unless sku == SKIP @price = price unless price == SKIP @warnings = warnings unless warnings == SKIP end |
Instance Attribute Details
#name ⇒ String
Name of the extra service.
14 15 16 |
# File 'lib/usps_api/models/labels_extra_service_response.rb', line 14 def name @name end |
#price ⇒ Float
The price for the extra service.
22 23 24 |
# File 'lib/usps_api/models/labels_extra_service_response.rb', line 22 def price @price end |
#sku ⇒ String
SKU of the extra service.
18 19 20 |
# File 'lib/usps_api/models/labels_extra_service_response.rb', line 18 def sku @sku end |
#warnings ⇒ Array[Warning]
Warnings and additional details around the Extra Services.
26 27 28 |
# File 'lib/usps_api/models/labels_extra_service_response.rb', line 26 def warnings @warnings end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/usps_api/models/labels_extra_service_response.rb', line 61 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. name = hash.key?('name') ? hash['name'] : SKIP sku = hash.key?('SKU') ? hash['SKU'] : SKIP price = hash.key?('price') ? hash['price'] : 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 << (Warning.from_hash(structure) if structure) end end warnings = SKIP unless hash.key?('warnings') # Create object from extracted values. LabelsExtraServiceResponse.new(name: name, sku: sku, price: price, warnings: warnings) end |
.names ⇒ Object
A mapping from model property names to API property names.
29 30 31 32 33 34 35 36 |
# File 'lib/usps_api/models/labels_extra_service_response.rb', line 29 def self.names @_hash = {} if @_hash.nil? @_hash['name'] = 'name' @_hash['sku'] = 'SKU' @_hash['price'] = 'price' @_hash['warnings'] = 'warnings' @_hash end |
.nullables ⇒ Object
An array for nullable fields
49 50 51 |
# File 'lib/usps_api/models/labels_extra_service_response.rb', line 49 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
39 40 41 42 43 44 45 46 |
# File 'lib/usps_api/models/labels_extra_service_response.rb', line 39 def self.optionals %w[ name sku price warnings ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
88 89 90 91 92 93 94 |
# File 'lib/usps_api/models/labels_extra_service_response.rb', line 88 def self.validate(value) return true if value.instance_of? self return false unless value.instance_of? Hash true end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
103 104 105 106 107 |
# File 'lib/usps_api/models/labels_extra_service_response.rb', line 103 def inspect class_name = self.class.name.split('::').last "<#{class_name} name: #{@name.inspect}, sku: #{@sku.inspect}, price: #{@price.inspect},"\ " warnings: #{@warnings.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
97 98 99 100 |
# File 'lib/usps_api/models/labels_extra_service_response.rb', line 97 def to_s class_name = self.class.name.split('::').last "<#{class_name} name: #{@name}, sku: #{@sku}, price: #{@price}, warnings: #{@warnings}>" end |