Class: Io::Flow::V0::Models::RatecardEstimateV1
- Inherits:
-
RatecardEstimate
- Object
- RatecardEstimate
- Io::Flow::V0::Models::RatecardEstimateV1
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Overview
Represents a summary of a cost estimate based on rate card data for an origin/destination and weight, either gravitational or dimensional
Instance Attribute Summary collapse
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#currency ⇒ Object
readonly
Returns the value of attribute currency.
-
#delivered_duty ⇒ Object
readonly
Returns the value of attribute delivered_duty.
-
#dimensional_weight ⇒ Object
readonly
Returns the value of attribute dimensional_weight.
-
#fees ⇒ Object
readonly
Returns the value of attribute fees.
-
#gravitational_weight ⇒ Object
readonly
Returns the value of attribute gravitational_weight.
-
#line_items ⇒ Object
readonly
Returns the value of attribute line_items.
-
#service ⇒ Object
readonly
Returns the value of attribute service.
-
#shipment_window ⇒ Object
readonly
Returns the value of attribute shipment_window.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
Attributes inherited from RatecardEstimate
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ RatecardEstimateV1
constructor
A new instance of RatecardEstimateV1.
- #subtype_to_hash ⇒ Object
- #to_json ⇒ Object
Methods inherited from RatecardEstimate
Constructor Details
#initialize(incoming = {}) ⇒ RatecardEstimateV1
Returns a new instance of RatecardEstimateV1.
46220 46221 46222 46223 46224 46225 46226 46227 46228 46229 46230 46231 46232 46233 46234 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46220 def initialize(incoming={}) super(:discriminator => RatecardEstimate::Types::RATECARD_ESTIMATE_V1) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:service, :shipment_window, :currency, :amount, :fees, :total, :delivered_duty], 'RatecardEstimateV1') @service = (x = opts.delete(:service); x.is_a?(::Io::Flow::V0::Models::RatecardServiceSummary) ? x : ::Io::Flow::V0::Models::RatecardServiceSummary.new(x)) @shipment_window = (x = opts.delete(:shipment_window); x.is_a?(::Io::Flow::V0::Models::ShipmentWindow) ? x : ::Io::Flow::V0::Models::ShipmentWindow.new(x)) @currency = HttpClient::Preconditions.assert_class('currency', opts.delete(:currency), String) @amount = HttpClient::Preconditions.assert_class('amount', opts.delete(:amount), Numeric) @fees = HttpClient::Preconditions.assert_class('fees', opts.delete(:fees), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::RatecardFee) ? x : ::Io::Flow::V0::Models::RatecardFee.from_json(x)) } @total = HttpClient::Preconditions.assert_class('total', opts.delete(:total), Numeric) @delivered_duty = (x = opts.delete(:delivered_duty); x.is_a?(::Io::Flow::V0::Models::DeliveredDuty) ? x : ::Io::Flow::V0::Models::DeliveredDuty.apply(x)) @dimensional_weight = (x = opts.delete(:dimensional_weight); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::Measurement) ? x : ::Io::Flow::V0::Models::Measurement.new(x))) @gravitational_weight = (x = opts.delete(:gravitational_weight); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::Measurement) ? x : ::Io::Flow::V0::Models::Measurement.new(x))) @line_items = (x = opts.delete(:line_items); x.nil? ? nil : HttpClient::Preconditions.assert_class('line_items', x, Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::LineItemForm) ? x : ::Io::Flow::V0::Models::LineItemForm.new(x)) }) end |
Instance Attribute Details
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
46218 46219 46220 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46218 def amount @amount end |
#currency ⇒ Object (readonly)
Returns the value of attribute currency.
46218 46219 46220 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46218 def currency @currency end |
#delivered_duty ⇒ Object (readonly)
Returns the value of attribute delivered_duty.
46218 46219 46220 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46218 def delivered_duty @delivered_duty end |
#dimensional_weight ⇒ Object (readonly)
Returns the value of attribute dimensional_weight.
46218 46219 46220 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46218 def dimensional_weight @dimensional_weight end |
#fees ⇒ Object (readonly)
Returns the value of attribute fees.
46218 46219 46220 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46218 def fees @fees end |
#gravitational_weight ⇒ Object (readonly)
Returns the value of attribute gravitational_weight.
46218 46219 46220 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46218 def gravitational_weight @gravitational_weight end |
#line_items ⇒ Object (readonly)
Returns the value of attribute line_items.
46218 46219 46220 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46218 def line_items @line_items end |
#service ⇒ Object (readonly)
Returns the value of attribute service.
46218 46219 46220 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46218 def service @service end |
#shipment_window ⇒ Object (readonly)
Returns the value of attribute shipment_window.
46218 46219 46220 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46218 def shipment_window @shipment_window end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
46218 46219 46220 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46218 def total @total end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
46240 46241 46242 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46240 def copy(incoming={}) RatecardEstimateV1.new(subtype_to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#subtype_to_hash ⇒ Object
46244 46245 46246 46247 46248 46249 46250 46251 46252 46253 46254 46255 46256 46257 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46244 def subtype_to_hash { :service => service.to_hash, :shipment_window => shipment_window.to_hash, :currency => currency, :amount => amount, :fees => fees.map { |o| o.to_hash }, :total => total, :delivered_duty => delivered_duty.value, :dimensional_weight => dimensional_weight.nil? ? nil : dimensional_weight.to_hash, :gravitational_weight => gravitational_weight.nil? ? nil : gravitational_weight.to_hash, :line_items => line_items.nil? ? nil : line_items.map { |o| o.to_hash } } end |
#to_json ⇒ Object
46236 46237 46238 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46236 def to_json JSON.dump(to_hash) end |