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.



4955
4956
4957
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4955

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

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



4953
4954
4955
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4953

def value
  @value
end

Class Method Details

.ALLObject



4975
4976
4977
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4975

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



4960
4961
4962
4963
4964
4965
4966
4967
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4960

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



4999
5000
5001
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4999

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

.dutyObject



4995
4996
4997
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4995

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



4970
4971
4972
4973
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4970

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



4983
4984
4985
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4983

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

.shippingObject



5003
5004
5005
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5003

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

.subtotalObject



4987
4988
4989
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4987

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

.totalObject



5007
5008
5009
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5007

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

.vatObject



4991
4992
4993
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4991

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

Instance Method Details

#to_hashObject



5011
5012
5013
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 5011

def to_hash
  value
end