Class: UspsApi::DomesticRateOptions
- Defined in:
- lib/usps_api/models/domestic_rate_options.rb
Overview
Options for domestic rate
Instance Attribute Summary collapse
-
#commitment ⇒ ShipmentsCommitment
The commitment and the scheduled delivery date of the package.
-
#extra_services ⇒ Array[ExtraService6]
Extra services requested on the package.
-
#rates ⇒ Array[Rate]
List of available rates for the package including base postage and extra service fees.
-
#total_base_price ⇒ Float
The price of the rate, fees, and pound postage.
-
#total_price ⇒ Float
The total price, including the ‘totalBasePrice` and all extra service prices.
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(commitment: SKIP, total_price: SKIP, total_base_price: SKIP, rates: SKIP, extra_services: SKIP, additional_properties: nil) ⇒ DomesticRateOptions
constructor
A new instance of DomesticRateOptions.
-
#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(commitment: SKIP, total_price: SKIP, total_base_price: SKIP, rates: SKIP, extra_services: SKIP, additional_properties: nil) ⇒ DomesticRateOptions
Returns a new instance of DomesticRateOptions.
63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/usps_api/models/domestic_rate_options.rb', line 63 def initialize(commitment: SKIP, total_price: SKIP, total_base_price: SKIP, rates: SKIP, extra_services: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @commitment = commitment unless commitment == SKIP @total_price = total_price unless total_price == SKIP @total_base_price = total_base_price unless total_base_price == SKIP @rates = rates unless rates == SKIP @extra_services = extra_services unless extra_services == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#commitment ⇒ ShipmentsCommitment
The commitment and the scheduled delivery date of the package.
14 15 16 |
# File 'lib/usps_api/models/domestic_rate_options.rb', line 14 def commitment @commitment end |
#extra_services ⇒ Array[ExtraService6]
Extra services requested on the package.
34 35 36 |
# File 'lib/usps_api/models/domestic_rate_options.rb', line 34 def extra_services @extra_services end |
#rates ⇒ Array[Rate]
List of available rates for the package including base postage and extra service fees
30 31 32 |
# File 'lib/usps_api/models/domestic_rate_options.rb', line 30 def rates @rates end |
#total_base_price ⇒ Float
The price of the rate, fees, and pound postage.
25 26 27 |
# File 'lib/usps_api/models/domestic_rate_options.rb', line 25 def total_base_price @total_base_price end |
#total_price ⇒ Float
The total price, including the ‘totalBasePrice` and all extra service prices. Note: This field is only returned when `extraServices` are passed in the request.
21 22 23 |
# File 'lib/usps_api/models/domestic_rate_options.rb', line 21 def total_price @total_price end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
78 79 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 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/usps_api/models/domestic_rate_options.rb', line 78 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. commitment = ShipmentsCommitment.from_hash(hash['commitment']) if hash['commitment'] total_price = hash.key?('totalPrice') ? hash['totalPrice'] : SKIP total_base_price = hash.key?('totalBasePrice') ? hash['totalBasePrice'] : SKIP # Parameter is an array, so we need to iterate through it rates = nil unless hash['rates'].nil? rates = [] hash['rates'].each do |structure| rates << (Rate.from_hash(structure) if structure) end end rates = SKIP unless hash.key?('rates') # Parameter is an array, so we need to iterate through it extra_services = nil unless hash['extraServices'].nil? extra_services = [] hash['extraServices'].each do |structure| extra_services << (ExtraService6.from_hash(structure) if structure) end end extra_services = SKIP unless hash.key?('extraServices') # 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. DomesticRateOptions.new(commitment: commitment, total_price: total_price, total_base_price: total_base_price, rates: rates, extra_services: extra_services, 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 |
# File 'lib/usps_api/models/domestic_rate_options.rb', line 37 def self.names @_hash = {} if @_hash.nil? @_hash['commitment'] = 'commitment' @_hash['total_price'] = 'totalPrice' @_hash['total_base_price'] = 'totalBasePrice' @_hash['rates'] = 'rates' @_hash['extra_services'] = 'extraServices' @_hash end |
.nullables ⇒ Object
An array for nullable fields
59 60 61 |
# File 'lib/usps_api/models/domestic_rate_options.rb', line 59 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
48 49 50 51 52 53 54 55 56 |
# File 'lib/usps_api/models/domestic_rate_options.rb', line 48 def self.optionals %w[ commitment total_price total_base_price rates extra_services ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
125 126 127 128 129 130 131 |
# File 'lib/usps_api/models/domestic_rate_options.rb', line 125 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.
142 143 144 145 146 147 |
# File 'lib/usps_api/models/domestic_rate_options.rb', line 142 def inspect class_name = self.class.name.split('::').last "<#{class_name} commitment: #{@commitment.inspect}, total_price: #{@total_price.inspect},"\ " total_base_price: #{@total_base_price.inspect}, rates: #{@rates.inspect}, extra_services:"\ " #{@extra_services.inspect}, additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
134 135 136 137 138 139 |
# File 'lib/usps_api/models/domestic_rate_options.rb', line 134 def to_s class_name = self.class.name.split('::').last "<#{class_name} commitment: #{@commitment}, total_price: #{@total_price}, total_base_price:"\ " #{@total_base_price}, rates: #{@rates}, extra_services: #{@extra_services},"\ " additional_properties: #{@additional_properties}>" end |