Class: Io::Flow::V0::Models::HopEstimate
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::HopEstimate
- 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.
-
#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 = {}) ⇒ HopEstimate
constructor
A new instance of HopEstimate.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ HopEstimate
Returns a new instance of HopEstimate.
30280 30281 30282 30283 30284 30285 30286 30287 30288 30289 30290 30291 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30280 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 |
Instance Attribute Details
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
30278 30279 30280 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30278 def amount @amount end |
#currency ⇒ Object (readonly)
Returns the value of attribute currency.
30278 30279 30280 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30278 def currency @currency end |
#destination_address ⇒ Object (readonly)
Returns the value of attribute destination_address.
30278 30279 30280 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30278 def destination_address @destination_address end |
#fees ⇒ Object (readonly)
Returns the value of attribute fees.
30278 30279 30280 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30278 def fees @fees end |
#origin_address ⇒ Object (readonly)
Returns the value of attribute origin_address.
30278 30279 30280 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30278 def origin_address @origin_address end |
#service ⇒ Object (readonly)
Returns the value of attribute service.
30278 30279 30280 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30278 def service @service end |
#shipment_window ⇒ Object (readonly)
Returns the value of attribute shipment_window.
30278 30279 30280 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30278 def shipment_window @shipment_window end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
30278 30279 30280 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30278 def total @total end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
30297 30298 30299 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30297 def copy(incoming={}) HopEstimate.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
30301 30302 30303 30304 30305 30306 30307 30308 30309 30310 30311 30312 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30301 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 ⇒ Object
30293 30294 30295 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30293 def to_json JSON.dump(to_hash) end |