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.
57293 57294 57295 57296 57297 57298 57299 57300 57301 57302 57303 57304 57305 57306 57307 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57293 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.
57291 57292 57293 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57291 def amount @amount end |
#currency ⇒ Object (readonly)
Returns the value of attribute currency.
57291 57292 57293 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57291 def currency @currency end |
#delivered_duty ⇒ Object (readonly)
Returns the value of attribute delivered_duty.
57291 57292 57293 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57291 def delivered_duty @delivered_duty end |
#dimensional_weight ⇒ Object (readonly)
Returns the value of attribute dimensional_weight.
57291 57292 57293 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57291 def dimensional_weight @dimensional_weight end |
#fees ⇒ Object (readonly)
Returns the value of attribute fees.
57291 57292 57293 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57291 def fees @fees end |
#gravitational_weight ⇒ Object (readonly)
Returns the value of attribute gravitational_weight.
57291 57292 57293 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57291 def gravitational_weight @gravitational_weight end |
#line_items ⇒ Object (readonly)
Returns the value of attribute line_items.
57291 57292 57293 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57291 def line_items @line_items end |
#service ⇒ Object (readonly)
Returns the value of attribute service.
57291 57292 57293 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57291 def service @service end |
#shipment_window ⇒ Object (readonly)
Returns the value of attribute shipment_window.
57291 57292 57293 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57291 def shipment_window @shipment_window end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
57291 57292 57293 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57291 def total @total end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
57313 57314 57315 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57313 def copy(incoming={}) RatecardEstimateV1.new(subtype_to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#subtype_to_hash ⇒ Object
57317 57318 57319 57320 57321 57322 57323 57324 57325 57326 57327 57328 57329 57330 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57317 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
57309 57310 57311 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 57309 def to_json JSON.dump(to_hash) end |