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.
9240 9241 9242 9243 9244 9245 9246 9247 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9240 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.
9238 9239 9240 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9238 def currency @currency end |
#items ⇒ Object (readonly)
Returns the value of attribute items.
9238 9239 9240 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9238 def items @items end |
#order ⇒ Object (readonly)
Returns the value of attribute order.
9238 9239 9240 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9238 def order @order end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
9238 9239 9240 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9238 def total @total end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
9253 9254 9255 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9253 def copy(incoming={}) Allocation.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
9257 9258 9259 9260 9261 9262 9263 9264 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9257 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
9249 9250 9251 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9249 def to_json JSON.dump(to_hash) end |