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

Instance Method Summary collapse

Methods inherited from InventoryStrategy

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ InventoryBackorder

Returns a new instance of InventoryBackorder.



12263
12264
12265
12266
12267
12268
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12263

def initialize(incoming={})
  super(:name => 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.



12261
12262
12263
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12261

def quantity
  @quantity
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



12274
12275
12276
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12274

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

#subtype_to_hashObject



12278
12279
12280
12281
12282
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12278

def subtype_to_hash
  {
    :quantity => quantity
  }
end

#to_jsonObject



12270
12271
12272
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12270

def to_json
  JSON.dump(to_hash)
end