Class: Io::Flow::V0::Models::RatecardEstimateV2
- Inherits:
-
RatecardEstimate
- Object
- RatecardEstimate
- Io::Flow::V0::Models::RatecardEstimateV2
- 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
-
#delivered_duty ⇒ Object
readonly
Returns the value of attribute delivered_duty.
-
#dimensional_weight ⇒ Object
readonly
Returns the value of attribute dimensional_weight.
-
#gravitational_weight ⇒ Object
readonly
Returns the value of attribute gravitational_weight.
-
#hops ⇒ Object
readonly
Returns the value of attribute hops.
-
#line_items ⇒ Object
readonly
Returns the value of attribute line_items.
-
#ratecard_owner ⇒ Object
readonly
Returns the value of attribute ratecard_owner.
Attributes inherited from RatecardEstimate
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ RatecardEstimateV2
constructor
A new instance of RatecardEstimateV2.
- #subtype_to_hash ⇒ Object
- #to_json ⇒ Object
Methods inherited from RatecardEstimate
Constructor Details
#initialize(incoming = {}) ⇒ RatecardEstimateV2
Returns a new instance of RatecardEstimateV2.
62031 62032 62033 62034 62035 62036 62037 62038 62039 62040 62041 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 62031 def initialize(incoming={}) super(:discriminator => RatecardEstimate::Types::RATECARD_ESTIMATE_V2) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:hops, :delivered_duty], 'RatecardEstimateV2') @hops = HttpClient::Preconditions.assert_class('hops', opts.delete(:hops), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::Hop) ? x : ::Io::Flow::V0::Models::Hop.new(x)) } @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)) }) @ratecard_owner = (x = opts.delete(:ratecard_owner); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::RatecardOwner) ? x : ::Io::Flow::V0::Models::RatecardOwner.apply(x))) end |
Instance Attribute Details
#delivered_duty ⇒ Object (readonly)
Returns the value of attribute delivered_duty.
62029 62030 62031 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 62029 def delivered_duty @delivered_duty end |
#dimensional_weight ⇒ Object (readonly)
Returns the value of attribute dimensional_weight.
62029 62030 62031 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 62029 def dimensional_weight @dimensional_weight end |
#gravitational_weight ⇒ Object (readonly)
Returns the value of attribute gravitational_weight.
62029 62030 62031 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 62029 def gravitational_weight @gravitational_weight end |
#hops ⇒ Object (readonly)
Returns the value of attribute hops.
62029 62030 62031 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 62029 def hops @hops end |
#line_items ⇒ Object (readonly)
Returns the value of attribute line_items.
62029 62030 62031 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 62029 def line_items @line_items end |
#ratecard_owner ⇒ Object (readonly)
Returns the value of attribute ratecard_owner.
62029 62030 62031 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 62029 def ratecard_owner @ratecard_owner end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
62047 62048 62049 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 62047 def copy(incoming={}) RatecardEstimateV2.new(subtype_to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#subtype_to_hash ⇒ Object
62051 62052 62053 62054 62055 62056 62057 62058 62059 62060 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 62051 def subtype_to_hash { :hops => hops.map { |o| o.to_hash }, :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 }, :ratecard_owner => ratecard_owner.nil? ? nil : ratecard_owner.value } end |
#to_json ⇒ Object
62043 62044 62045 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 62043 def to_json JSON.dump(to_hash) end |