Class: Io::Flow::V0::Models::ItemIdentifier

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ ItemIdentifier

Returns a new instance of ItemIdentifier.



19481
19482
19483
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19481

def initialize(value)
  @value = HttpClient::Preconditions.assert_class('value', value, String)
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



19479
19480
19481
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19479

def value
  @value
end

Class Method Details

.ALLObject



19501
19502
19503
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19501

def ItemIdentifier.ALL
  @@all ||= [ItemIdentifier.item_number, ItemIdentifier.sku]
end

.apply(value) ⇒ Object

Returns the instance of ItemIdentifier for this value, creating a new instance for an unknown value



19486
19487
19488
19489
19490
19491
19492
19493
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19486

def ItemIdentifier.apply(value)
  if value.instance_of?(ItemIdentifier)
    value
  else
    HttpClient::Preconditions.assert_class_or_nil('value', value, String)
    value.nil? ? nil : (from_string(value) || ItemIdentifier.new(value))
  end
end

.from_string(value) ⇒ Object

Returns the instance of ItemIdentifier for this value, or nil if not found



19496
19497
19498
19499
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19496

def ItemIdentifier.from_string(value)
  HttpClient::Preconditions.assert_class('value', value, String)
  ItemIdentifier.ALL.find { |v| v.value == value }
end

.item_numberObject



19505
19506
19507
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19505

def ItemIdentifier.item_number
  @@_item_number ||= ItemIdentifier.new('item_number')
end

.skuObject



19509
19510
19511
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19509

def ItemIdentifier.sku
  @@_sku ||= ItemIdentifier.new('sku')
end

Instance Method Details

#to_hashObject



19513
19514
19515
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19513

def to_hash
  value
end