Class: Io::Flow::V0::Models::LocalizedPriceKey

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) ⇒ LocalizedPriceKey

Returns a new instance of LocalizedPriceKey.



5329
5330
5331
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5329

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

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



5327
5328
5329
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5327

def value
  @value
end

Class Method Details

.ALLObject



5349
5350
5351
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5349

def LocalizedPriceKey.ALL
  @@all ||= [LocalizedPriceKey.price, LocalizedPriceKey.subtotal, LocalizedPriceKey.vat, LocalizedPriceKey.duty, LocalizedPriceKey.discount, LocalizedPriceKey.shipping, LocalizedPriceKey.total]
end

.apply(value) ⇒ Object

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



5334
5335
5336
5337
5338
5339
5340
5341
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5334

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

.discountObject



5373
5374
5375
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5373

def LocalizedPriceKey.discount
  @@_discount ||= LocalizedPriceKey.new('discount')
end

.dutyObject



5369
5370
5371
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5369

def LocalizedPriceKey.duty
  @@_duty ||= LocalizedPriceKey.new('duty')
end

.from_string(value) ⇒ Object

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



5344
5345
5346
5347
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5344

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

.priceObject

The calculated price, taking into account pricing settings. For example, if vat is set to be included in the price, this value will be equal to subtotal + vat, rounded per the settings. This is the price you should lead with when displaying to consumers



5357
5358
5359
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5357

def LocalizedPriceKey.price
  @@_price ||= LocalizedPriceKey.new('price')
end

.shippingObject



5377
5378
5379
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5377

def LocalizedPriceKey.shipping
  @@_shipping ||= LocalizedPriceKey.new('shipping')
end

.subtotalObject



5361
5362
5363
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5361

def LocalizedPriceKey.subtotal
  @@_subtotal ||= LocalizedPriceKey.new('subtotal')
end

.totalObject



5381
5382
5383
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5381

def LocalizedPriceKey.total
  @@_total ||= LocalizedPriceKey.new('total')
end

.vatObject



5365
5366
5367
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5365

def LocalizedPriceKey.vat
  @@_vat ||= LocalizedPriceKey.new('vat')
end

Instance Method Details

#to_hashObject



5385
5386
5387
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5385

def to_hash
  value
end