Class: Io::Flow::V0::Models::MarginType

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

Returns a new instance of MarginType.



12868
12869
12870
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12868

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

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



12866
12867
12868
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12866

def value
  @value
end

Class Method Details

.ALLObject



12888
12889
12890
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12888

def MarginType.ALL
  @@all ||= [MarginType.fixed, MarginType.percent]
end

.apply(value) ⇒ Object

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



12873
12874
12875
12876
12877
12878
12879
12880
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12873

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

.fixedObject

A fixed amount to add, e.g 2.5 would add an absolute margin of 2.5 in the base currency of your item.



12894
12895
12896
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12894

def MarginType.fixed
  @@_fixed ||= MarginType.new('fixed')
end

.from_string(value) ⇒ Object

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



12883
12884
12885
12886
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12883

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

.percentObject

A percent of the base cost to add, e.g. 1.2 would represent a 1.2% increase.



12899
12900
12901
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12899

def MarginType.percent
  @@_percent ||= MarginType.new('percent')
end

Instance Method Details

#to_hashObject



12903
12904
12905
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12903

def to_hash
  value
end