Class: Io::Flow::V0::Models::RatecardEstimateV4
- Inherits:
-
RatecardEstimate
- Object
- RatecardEstimate
- Io::Flow::V0::Models::RatecardEstimateV4
- 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_id ⇒ Object
readonly
Returns the value of attribute ratecard_id.
Attributes inherited from RatecardEstimate
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ RatecardEstimateV4
constructor
A new instance of RatecardEstimateV4.
- #subtype_to_hash ⇒ Object
- #to_json ⇒ Object
Methods inherited from RatecardEstimate
Constructor Details
#initialize(incoming = {}) ⇒ RatecardEstimateV4
Returns a new instance of RatecardEstimateV4.
62109 62110 62111 62112 62113 62114 62115 62116 62117 62118 62119 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 62109 def initialize(incoming={}) super(:discriminator => RatecardEstimate::Types::RATECARD_ESTIMATE_V4) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:hops, :delivered_duty], 'RatecardEstimateV4') @hops = HttpClient::Preconditions.assert_class('hops', opts.delete(:hops), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::HopV2) ? x : ::Io::Flow::V0::Models::HopV2.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))) @ratecard_id = (x = opts.delete(:ratecard_id); x.nil? ? nil : HttpClient::Preconditions.assert_class('ratecard_id', x, String)) @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
#delivered_duty ⇒ Object (readonly)
Returns the value of attribute delivered_duty.
62107 62108 62109 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 62107 def delivered_duty @delivered_duty end |
#dimensional_weight ⇒ Object (readonly)
Returns the value of attribute dimensional_weight.
62107 62108 62109 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 62107 def dimensional_weight @dimensional_weight end |
#gravitational_weight ⇒ Object (readonly)
Returns the value of attribute gravitational_weight.
62107 62108 62109 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 62107 def gravitational_weight @gravitational_weight end |
#hops ⇒ Object (readonly)
Returns the value of attribute hops.
62107 62108 62109 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 62107 def hops @hops end |
#line_items ⇒ Object (readonly)
Returns the value of attribute line_items.
62107 62108 62109 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 62107 def line_items @line_items end |
#ratecard_id ⇒ Object (readonly)
Returns the value of attribute ratecard_id.
62107 62108 62109 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 62107 def ratecard_id @ratecard_id end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
62125 62126 62127 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 62125 def copy(incoming={}) RatecardEstimateV4.new(subtype_to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#subtype_to_hash ⇒ Object
62129 62130 62131 62132 62133 62134 62135 62136 62137 62138 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 62129 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, :ratecard_id => ratecard_id, :line_items => line_items.nil? ? nil : line_items.map { |o| o.to_hash } } end |
#to_json ⇒ Object
62121 62122 62123 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 62121 def to_json JSON.dump(to_hash) end |