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.



17123
17124
17125
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17123

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

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



17121
17122
17123
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17121

def value
  @value
end

Class Method Details

.ALLObject



17143
17144
17145
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17143

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



17128
17129
17130
17131
17132
17133
17134
17135
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17128

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



17138
17139
17140
17141
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17138

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

.item_numberObject



17147
17148
17149
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17147

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

.skuObject



17151
17152
17153
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17151

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

Instance Method Details

#to_hashObject



17155
17156
17157
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17155

def to_hash
  value
end