Class: Io::Flow::V0::Models::AllocationOrderDetail

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

Overview

Represents an order-specific detail such as shipping, insurance, or an order-level discount.

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 = {}) ⇒ AllocationOrderDetail

Returns a new instance of AllocationOrderDetail.



28134
28135
28136
28137
28138
28139
28140
28141
28142
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28134

def initialize(incoming={})
  super(:discriminator => AllocationDetail::Types::ALLOCATION_ORDER_DETAIL)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:key, :total, :included, :not_included], 'AllocationOrderDetail')
  @key = (x = opts.delete(:key); x.is_a?(::Io::Flow::V0::Models::OrderPriceDetailKey) ? x : ::Io::Flow::V0::Models::OrderPriceDetailKey.apply(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.



28132
28133
28134
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28132

def included
  @included
end

#keyObject (readonly)

Returns the value of attribute key.



28132
28133
28134
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28132

def key
  @key
end

#not_includedObject (readonly)

Returns the value of attribute not_included.



28132
28133
28134
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28132

def not_included
  @not_included
end

#totalObject (readonly)

Returns the value of attribute total.



28132
28133
28134
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28132

def total
  @total
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



28148
28149
28150
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28148

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

#subtype_to_hashObject



28152
28153
28154
28155
28156
28157
28158
28159
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28152

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

#to_jsonObject



28144
28145
28146
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28144

def to_json
  JSON.dump(to_hash)
end