Class: UspsApi::ExtraService6
- Defined in:
- lib/usps_api/models/extra_service6.rb
Overview
ExtraService6 Model.
Instance Attribute Summary collapse
-
#extra_service ⇒ String
The code for the extra service.
-
#name ⇒ String
Name of the extra service.
-
#price ⇒ Float
The price for the extra service.
-
#price_type ⇒ InternationalPriceType
The type of price applied.
-
#sku ⇒ String
SKU of the extra service.
-
#warnings ⇒ Array[Warning]
List of warnings.
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, extra_service: SKIP, price_type: SKIP, warnings: SKIP) ⇒ ExtraService6
constructor
A new instance of ExtraService6.
-
#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, extra_service: SKIP, price_type: SKIP, warnings: SKIP) ⇒ ExtraService6
Returns a new instance of ExtraService6.
69 70 71 72 73 74 75 76 77 |
# File 'lib/usps_api/models/extra_service6.rb', line 69 def initialize(name: SKIP, sku: SKIP, price: SKIP, extra_service: SKIP, price_type: SKIP, warnings: SKIP) @name = name unless name == SKIP @sku = sku unless sku == SKIP @price = price unless price == SKIP @extra_service = extra_service unless extra_service == SKIP @price_type = price_type unless price_type == SKIP @warnings = warnings unless warnings == SKIP end |
Instance Attribute Details
#extra_service ⇒ String
The code for the extra service.
26 27 28 |
# File 'lib/usps_api/models/extra_service6.rb', line 26 def extra_service @extra_service end |
#name ⇒ String
Name of the extra service.
14 15 16 |
# File 'lib/usps_api/models/extra_service6.rb', line 14 def name @name end |
#price ⇒ Float
The price for the extra service.
22 23 24 |
# File 'lib/usps_api/models/extra_service6.rb', line 22 def price @price end |
#price_type ⇒ InternationalPriceType
The type of price applied.
* Valid Options for Domestic Prices include: 'RETAIL', 'COMMERCIAL', &
‘CONTRACT’
* Valid Options for International Prices include: 'RETAIL', 'COMMERCIAL',
‘COMMERCIAL_BASE’, ‘COMMERCIAL_PLUS’, & ‘CONTRACT’
34 35 36 |
# File 'lib/usps_api/models/extra_service6.rb', line 34 def price_type @price_type end |
#sku ⇒ String
SKU of the extra service.
18 19 20 |
# File 'lib/usps_api/models/extra_service6.rb', line 18 def sku @sku end |
#warnings ⇒ Array[Warning]
List of warnings
38 39 40 |
# File 'lib/usps_api/models/extra_service6.rb', line 38 def warnings @warnings end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
80 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/extra_service6.rb', line 80 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 extra_service = hash.key?('extraService') ? hash['extraService'] : SKIP price_type = hash.key?('priceType') ? hash['priceType'] : 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. ExtraService6.new(name: name, sku: sku, price: price, extra_service: extra_service, price_type: price_type, warnings: warnings) end |
.names ⇒ Object
A mapping from model property names to API property names.
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/usps_api/models/extra_service6.rb', line 41 def self.names @_hash = {} if @_hash.nil? @_hash['name'] = 'name' @_hash['sku'] = 'SKU' @_hash['price'] = 'price' @_hash['extra_service'] = 'extraService' @_hash['price_type'] = 'priceType' @_hash['warnings'] = 'warnings' @_hash end |
.nullables ⇒ Object
An array for nullable fields
65 66 67 |
# File 'lib/usps_api/models/extra_service6.rb', line 65 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/usps_api/models/extra_service6.rb', line 53 def self.optionals %w[ name sku price extra_service price_type warnings ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
111 112 113 114 115 116 117 |
# File 'lib/usps_api/models/extra_service6.rb', line 111 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.
127 128 129 130 131 132 |
# File 'lib/usps_api/models/extra_service6.rb', line 127 def inspect class_name = self.class.name.split('::').last "<#{class_name} name: #{@name.inspect}, sku: #{@sku.inspect}, price: #{@price.inspect},"\ " extra_service: #{@extra_service.inspect}, price_type: #{@price_type.inspect}, warnings:"\ " #{@warnings.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
120 121 122 123 124 |
# File 'lib/usps_api/models/extra_service6.rb', line 120 def to_s class_name = self.class.name.split('::').last "<#{class_name} name: #{@name}, sku: #{@sku}, price: #{@price}, extra_service:"\ " #{@extra_service}, price_type: #{@price_type}, warnings: #{@warnings}>" end |