Class: Io::Flow::V0::Models::HopEstimateV2
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::HopEstimateV2
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Attribute Summary collapse
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#currency ⇒ Object
readonly
Returns the value of attribute currency.
-
#destination_address ⇒ Object
readonly
Returns the value of attribute destination_address.
-
#fees ⇒ Object
readonly
Returns the value of attribute fees.
-
#lane ⇒ Object
readonly
Returns the value of attribute lane.
-
#origin_address ⇒ Object
readonly
Returns the value of attribute origin_address.
-
#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.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ HopEstimateV2
constructor
A new instance of HopEstimateV2.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ HopEstimateV2
Returns a new instance of HopEstimateV2.
41809 41810 41811 41812 41813 41814 41815 41816 41817 41818 41819 41820 41821 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41809 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:origin_address, :destination_address, :service, :shipment_window, :currency, :amount, :fees, :total, :lane], 'HopEstimateV2') @origin_address = (x = opts.delete(:origin_address); x.is_a?(::Io::Flow::V0::Models::ShippingAddress) ? x : ::Io::Flow::V0::Models::ShippingAddress.new(x)) @destination_address = (x = opts.delete(:destination_address); x.is_a?(::Io::Flow::V0::Models::ShippingAddress) ? x : ::Io::Flow::V0::Models::ShippingAddress.new(x)) @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) @lane = (x = opts.delete(:lane); x.is_a?(::Io::Flow::V0::Models::LaneSummary) ? x : ::Io::Flow::V0::Models::LaneSummary.new(x)) end |
Instance Attribute Details
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
41807 41808 41809 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41807 def amount @amount end |
#currency ⇒ Object (readonly)
Returns the value of attribute currency.
41807 41808 41809 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41807 def currency @currency end |
#destination_address ⇒ Object (readonly)
Returns the value of attribute destination_address.
41807 41808 41809 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41807 def destination_address @destination_address end |
#fees ⇒ Object (readonly)
Returns the value of attribute fees.
41807 41808 41809 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41807 def fees @fees end |
#lane ⇒ Object (readonly)
Returns the value of attribute lane.
41807 41808 41809 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41807 def lane @lane end |
#origin_address ⇒ Object (readonly)
Returns the value of attribute origin_address.
41807 41808 41809 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41807 def origin_address @origin_address end |
#service ⇒ Object (readonly)
Returns the value of attribute service.
41807 41808 41809 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41807 def service @service end |
#shipment_window ⇒ Object (readonly)
Returns the value of attribute shipment_window.
41807 41808 41809 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41807 def shipment_window @shipment_window end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
41807 41808 41809 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41807 def total @total end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
41827 41828 41829 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41827 def copy(incoming={}) HopEstimateV2.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
41831 41832 41833 41834 41835 41836 41837 41838 41839 41840 41841 41842 41843 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41831 def to_hash { :origin_address => origin_address.to_hash, :destination_address => destination_address.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, :lane => lane.to_hash } end |
#to_json ⇒ Object
41823 41824 41825 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41823 def to_json JSON.dump(to_hash) end |