Class: Io::Flow::V0::Models::Allocation
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::Allocation
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Attribute Summary collapse
-
#currency ⇒ Object
readonly
Returns the value of attribute currency.
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#order ⇒ Object
readonly
Returns the value of attribute order.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ Allocation
constructor
A new instance of Allocation.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ Allocation
Returns a new instance of Allocation.
9289 9290 9291 9292 9293 9294 9295 9296 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9289 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:order, :currency, :total, :items], 'Allocation') @order = (x = opts.delete(:order); x.is_a?(::Io::Flow::V0::Models::OrderReference) ? x : ::Io::Flow::V0::Models::OrderReference.new(x)) @currency = (x = opts.delete(:currency); x.is_a?(::Io::Flow::V0::Models::AllocationCurrencies) ? x : ::Io::Flow::V0::Models::AllocationCurrencies.new(x)) @total = (x = opts.delete(:total); x.is_a?(::Io::Flow::V0::Models::AllocationTotals) ? x : ::Io::Flow::V0::Models::AllocationTotals.new(x)) @items = HttpClient::Preconditions.assert_class('items', opts.delete(:items), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::AllocationItem) ? x : ::Io::Flow::V0::Models::AllocationItem.new(x)) } end |
Instance Attribute Details
#currency ⇒ Object (readonly)
Returns the value of attribute currency.
9287 9288 9289 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9287 def currency @currency end |
#items ⇒ Object (readonly)
Returns the value of attribute items.
9287 9288 9289 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9287 def items @items end |
#order ⇒ Object (readonly)
Returns the value of attribute order.
9287 9288 9289 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9287 def order @order end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
9287 9288 9289 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9287 def total @total end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
9302 9303 9304 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9302 def copy(incoming={}) Allocation.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
9306 9307 9308 9309 9310 9311 9312 9313 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9306 def to_hash { :order => order.to_hash, :currency => currency.to_hash, :total => total.to_hash, :items => items.map { |o| o.to_hash } } end |
#to_json ⇒ Object
9298 9299 9300 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9298 def to_json JSON.dump(to_hash) end |