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.



17029
17030
17031
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17029

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

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



17027
17028
17029
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17027

def value
  @value
end

Class Method Details

.ALLObject



17049
17050
17051
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17049

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



17034
17035
17036
17037
17038
17039
17040
17041
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17034

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



17044
17045
17046
17047
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17044

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

.item_numberObject



17053
17054
17055
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17053

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

.skuObject



17057
17058
17059
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17057

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

Instance Method Details

#to_hashObject



17061
17062
17063
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17061

def to_hash
  value
end