Class: Io::Flow::V0::Models::TaxabilityValue

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

Returns a new instance of TaxabilityValue.



20069
20070
20071
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20069

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

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



20067
20068
20069
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20067

def value
  @value
end

Class Method Details

.ALLObject



20089
20090
20091
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20089

def TaxabilityValue.ALL
  @@all ||= [TaxabilityValue.exempt]
end

.apply(value) ⇒ Object

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



20074
20075
20076
20077
20078
20079
20080
20081
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20074

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

.exemptObject

An item with this value is exempt from being taxed.



20094
20095
20096
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20094

def TaxabilityValue.exempt
  @@_exempt ||= TaxabilityValue.new('exempt')
end

.from_string(value) ⇒ Object

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



20084
20085
20086
20087
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20084

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

Instance Method Details

#to_hashObject



20098
20099
20100
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20098

def to_hash
  value
end