Class: UspsApi::InternationalRateOptions
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- UspsApi::InternationalRateOptions
- Defined in:
- lib/usps_api/models/international_rate_options.rb
Overview
Options for international rate
Instance Attribute Summary collapse
-
#duties_taxes_fees_quote ⇒ DutiesTaxesFeesQuote
The duties, taxes, and fees details.
-
#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(duties_taxes_fees_quote: SKIP, total_price: SKIP, total_base_price: SKIP, rates: SKIP, extra_services: SKIP, additional_properties: nil) ⇒ InternationalRateOptions
constructor
A new instance of InternationalRateOptions.
-
#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(duties_taxes_fees_quote: SKIP, total_price: SKIP, total_base_price: SKIP, rates: SKIP, extra_services: SKIP, additional_properties: nil) ⇒ InternationalRateOptions
Returns a new instance of InternationalRateOptions.
65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/usps_api/models/international_rate_options.rb', line 65 def initialize(duties_taxes_fees_quote: 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? @duties_taxes_fees_quote = duties_taxes_fees_quote unless duties_taxes_fees_quote == 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
#duties_taxes_fees_quote ⇒ DutiesTaxesFeesQuote
The duties, taxes, and fees details. Included if ‘requestDutiesTaxesFees` is `true` and the shipping destination has applicable duties, taxes, and fees.
16 17 18 |
# File 'lib/usps_api/models/international_rate_options.rb', line 16 def duties_taxes_fees_quote @duties_taxes_fees_quote end |
#extra_services ⇒ Array[ExtraService6]
Extra services requested on the package.
36 37 38 |
# File 'lib/usps_api/models/international_rate_options.rb', line 36 def extra_services @extra_services end |
#rates ⇒ Array[Rate]
List of available rates for the package including base postage and extra service fees
32 33 34 |
# File 'lib/usps_api/models/international_rate_options.rb', line 32 def rates @rates end |
#total_base_price ⇒ Float
The price of the rate, fees, and pound postage.
27 28 29 |
# File 'lib/usps_api/models/international_rate_options.rb', line 27 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.
23 24 25 |
# File 'lib/usps_api/models/international_rate_options.rb', line 23 def total_price @total_price 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 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/usps_api/models/international_rate_options.rb', line 80 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. duties_taxes_fees_quote = DutiesTaxesFeesQuote.from_hash(hash['dutiesTaxesFeesQuote']) if hash['dutiesTaxesFeesQuote'] 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. InternationalRateOptions.new(duties_taxes_fees_quote: duties_taxes_fees_quote, 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.
39 40 41 42 43 44 45 46 47 |
# File 'lib/usps_api/models/international_rate_options.rb', line 39 def self.names @_hash = {} if @_hash.nil? @_hash['duties_taxes_fees_quote'] = 'dutiesTaxesFeesQuote' @_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
61 62 63 |
# File 'lib/usps_api/models/international_rate_options.rb', line 61 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
50 51 52 53 54 55 56 57 58 |
# File 'lib/usps_api/models/international_rate_options.rb', line 50 def self.optionals %w[ duties_taxes_fees_quote total_price total_base_price rates extra_services ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
128 129 130 131 132 133 134 |
# File 'lib/usps_api/models/international_rate_options.rb', line 128 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.
145 146 147 148 149 150 151 |
# File 'lib/usps_api/models/international_rate_options.rb', line 145 def inspect class_name = self.class.name.split('::').last "<#{class_name} duties_taxes_fees_quote: #{@duties_taxes_fees_quote.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.
137 138 139 140 141 142 |
# File 'lib/usps_api/models/international_rate_options.rb', line 137 def to_s class_name = self.class.name.split('::').last "<#{class_name} duties_taxes_fees_quote: #{@duties_taxes_fees_quote}, total_price:"\ " #{@total_price}, total_base_price: #{@total_base_price}, rates: #{@rates}, extra_services:"\ " #{@extra_services}, additional_properties: #{@additional_properties}>" end |