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.



5633
5634
5635
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5633

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

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



5631
5632
5633
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5631

def value
  @value
end

Class Method Details

.ALLObject



5653
5654
5655
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5653

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



5638
5639
5640
5641
5642
5643
5644
5645
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5638

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



5677
5678
5679
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5677

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

.dutyObject



5673
5674
5675
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5673

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



5648
5649
5650
5651
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5648

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



5661
5662
5663
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5661

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

.shippingObject



5681
5682
5683
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5681

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

.subtotalObject



5665
5666
5667
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5665

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

.totalObject



5685
5686
5687
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5685

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

.vatObject



5669
5670
5671
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5669

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

Instance Method Details

#to_hashObject



5689
5690
5691
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5689

def to_hash
  value
end