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.



20246
20247
20248
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20246

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

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



20244
20245
20246
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20244

def value
  @value
end

Class Method Details

.ALLObject



20266
20267
20268
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20266

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



20251
20252
20253
20254
20255
20256
20257
20258
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20251

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



20261
20262
20263
20264
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20261

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

.item_numberObject



20270
20271
20272
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20270

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

.skuObject



20274
20275
20276
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20274

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

Instance Method Details

#to_hashObject



20278
20279
20280
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20278

def to_hash
  value
end