Class: Io::Flow::V0::Models::Allocation

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ Allocation

Returns a new instance of Allocation.



22593
22594
22595
22596
22597
22598
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22593

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:order, :details], 'Allocation')
  @order = (x = opts.delete(:order); x.is_a?(::Io::Flow::V0::Models::AllocationOrderSummary) ? x : ::Io::Flow::V0::Models::AllocationOrderSummary.new(x))
  @details = HttpClient::Preconditions.assert_class('details', opts.delete(:details), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::AllocationDetail) ? x : ::Io::Flow::V0::Models::AllocationDetail.from_json(x)) }
end

Instance Attribute Details

#detailsObject (readonly)

Returns the value of attribute details.



22591
22592
22593
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22591

def details
  @details
end

#orderObject (readonly)

Returns the value of attribute order.



22591
22592
22593
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22591

def order
  @order
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



22604
22605
22606
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22604

def copy(incoming={})
  Allocation.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end

#to_hashObject



22608
22609
22610
22611
22612
22613
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22608

def to_hash
  {
    :order => order.to_hash,
    :details => details.map { |o| o.to_hash }
  }
end

#to_jsonObject



22600
22601
22602
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22600

def to_json
  JSON.dump(to_hash)
end