Class: Io::Flow::V0::Models::InventoryStrategy

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

Overview

Types of rules used to apply on inventory to calculate available quantity

Defined Under Namespace

Modules: Types

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ InventoryStrategy

Returns a new instance of InventoryStrategy.



4416
4417
4418
4419
4420
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4416

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:name], 'InventoryStrategy')
  @name = HttpClient::Preconditions.assert_class('name', opts.delete(:name), String)
end

Class Method Details

.from_json(hash) ⇒ Object



4426
4427
4428
4429
4430
4431
4432
4433
4434
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4426

def InventoryStrategy.from_json(hash)
  HttpClient::Preconditions.assert_class('hash', hash, Hash)
  case HttpClient::Helper.symbolize_keys(hash)[:discriminator]
    when Types::INVENTORY_BACKORDER; InventoryBackorder.new(hash)
    when Types::INVENTORY_STOCK; InventoryStock.new(hash)
    when Types::INVENTORY_UNLIMITED; InventoryUnlimited.new(hash)
    else InventoryStrategyUndefinedType.new(:name => union_type_name)
  end
end

Instance Method Details

#to_hashObject



4422
4423
4424
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4422

def to_hash
  subtype_to_hash.merge(:discriminator => @name)
end