Class: Io::Flow::V0::Models::InventoryBackorder

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

Overview

Enables backorders, setting an optional number of units that we allow for backorder. For example, a backorder w/ quantity 10 will enable selling until the actual inventory quantity is -10.

Instance Attribute Summary collapse

Attributes inherited from InventoryStrategy

#discriminator

Instance Method Summary collapse

Methods inherited from InventoryStrategy

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ InventoryBackorder



15078
15079
15080
15081
15082
15083
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15078

def initialize(incoming={})
  super(:discriminator => InventoryStrategy::Types::INVENTORY_BACKORDER)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:quantity], 'InventoryBackorder')
  @quantity = HttpClient::Preconditions.assert_class('quantity', opts.delete(:quantity), Integer)
end

Instance Attribute Details

#quantityObject (readonly)

Returns the value of attribute quantity.



15076
15077
15078
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15076

def quantity
  @quantity
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



15089
15090
15091
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15089

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

#subtype_to_hashObject



15093
15094
15095
15096
15097
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15093

def subtype_to_hash
  {
    :quantity => quantity
  }
end

#to_jsonObject



15085
15086
15087
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15085

def to_json
  JSON.dump(to_hash)
end