class Io::Flow::V0::Models::HopEstimate
Attributes
amount[R]
currency[R]
destination_address[R]
fees[R]
origin_address[R]
service[R]
shipment_window[R]
total[R]
Public Class Methods
new(incoming={})
click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 44988 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], 'HopEstimate') @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) end
Public Instance Methods
copy(incoming={})
click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 45005 def copy(incoming={}) HopEstimate.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end
to_hash()
click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 45009 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 } end
to_json()
click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 45001 def to_json JSON.dump(to_hash) end