Class: Io::Flow::V0::Models::AllocationLineDetail

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

Instance Attribute Summary collapse

Attributes inherited from AllocationDetail

#discriminator

Instance Method Summary collapse

Methods inherited from AllocationDetail

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ AllocationLineDetail

Returns a new instance of AllocationLineDetail.



12433
12434
12435
12436
12437
12438
12439
12440
12441
12442
12443
12444
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12433

def initialize(incoming={})
  super(:discriminator => AllocationDetail::Types::ALLOCATION_LINE_DETAIL)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:number, :quantity, :key, :price, :total, :included, :not_included], 'AllocationLineDetail')
  @number = HttpClient::Preconditions.assert_class('number', opts.delete(:number), String)
  @quantity = HttpClient::Preconditions.assert_class('quantity', opts.delete(:quantity), Integer)
  @key = (x = opts.delete(:key); x.is_a?(::Io::Flow::V0::Models::OrderPriceDetailKey) ? x : ::Io::Flow::V0::Models::OrderPriceDetailKey.apply(x))
  @price = (x = opts.delete(:price); x.is_a?(::Io::Flow::V0::Models::PriceWithBase) ? x : ::Io::Flow::V0::Models::PriceWithBase.new(x))
  @total = (x = opts.delete(:total); x.is_a?(::Io::Flow::V0::Models::PriceWithBase) ? x : ::Io::Flow::V0::Models::PriceWithBase.new(x))
  @included = HttpClient::Preconditions.assert_class('included', opts.delete(:included), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::AllocationComponent) ? x : ::Io::Flow::V0::Models::AllocationComponent.from_json(x)) }
  @not_included = HttpClient::Preconditions.assert_class('not_included', opts.delete(:not_included), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::AllocationComponent) ? x : ::Io::Flow::V0::Models::AllocationComponent.from_json(x)) }
end

Instance Attribute Details

#includedObject (readonly)

Returns the value of attribute included.



12431
12432
12433
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12431

def included
  @included
end

#keyObject (readonly)

Returns the value of attribute key.



12431
12432
12433
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12431

def key
  @key
end

#not_includedObject (readonly)

Returns the value of attribute not_included.



12431
12432
12433
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12431

def not_included
  @not_included
end

#numberObject (readonly)

Returns the value of attribute number.



12431
12432
12433
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12431

def number
  @number
end

#priceObject (readonly)

Returns the value of attribute price.



12431
12432
12433
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12431

def price
  @price
end

#quantityObject (readonly)

Returns the value of attribute quantity.



12431
12432
12433
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12431

def quantity
  @quantity
end

#totalObject (readonly)

Returns the value of attribute total.



12431
12432
12433
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12431

def total
  @total
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



12450
12451
12452
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12450

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

#subtype_to_hashObject



12454
12455
12456
12457
12458
12459
12460
12461
12462
12463
12464
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12454

def subtype_to_hash
  {
    :number => number,
    :quantity => quantity,
    :key => key.value,
    :price => price.to_hash,
    :total => total.to_hash,
    :included => included.map { |o| o.to_hash },
    :not_included => not_included.map { |o| o.to_hash }
  }
end

#to_jsonObject



12446
12447
12448
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12446

def to_json
  JSON.dump(to_hash)
end