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.
61984 61985 61986 61987 61988 61989 61990 61991 61992 61993 61994 61995 61996 61997 61998 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 61984 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.
61982 61983 61984 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 61982 def amount @amount end |
#currency ⇒ Object (readonly)
Returns the value of attribute currency.
61982 61983 61984 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 61982 def currency @currency end |
#delivered_duty ⇒ Object (readonly)
Returns the value of attribute delivered_duty.
61982 61983 61984 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 61982 def delivered_duty @delivered_duty end |
#dimensional_weight ⇒ Object (readonly)
Returns the value of attribute dimensional_weight.
61982 61983 61984 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 61982 def dimensional_weight @dimensional_weight end |
#fees ⇒ Object (readonly)
Returns the value of attribute fees.
61982 61983 61984 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 61982 def fees @fees end |
#gravitational_weight ⇒ Object (readonly)
Returns the value of attribute gravitational_weight.
61982 61983 61984 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 61982 def gravitational_weight @gravitational_weight end |
#line_items ⇒ Object (readonly)
Returns the value of attribute line_items.
61982 61983 61984 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 61982 def line_items @line_items end |
#service ⇒ Object (readonly)
Returns the value of attribute service.
61982 61983 61984 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 61982 def service @service end |
#shipment_window ⇒ Object (readonly)
Returns the value of attribute shipment_window.
61982 61983 61984 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 61982 def shipment_window @shipment_window end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
61982 61983 61984 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 61982 def total @total end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
62004 62005 62006 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 62004 def copy(incoming={}) RatecardEstimateV1.new(subtype_to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#subtype_to_hash ⇒ Object
62008 62009 62010 62011 62012 62013 62014 62015 62016 62017 62018 62019 62020 62021 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 62008 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
62000 62001 62002 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 62000 def to_json JSON.dump(to_hash) end |