Class: Io::Flow::V0::Models::DiscountTarget
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::DiscountTarget
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
- .ALL ⇒ Object
-
.apply(value) ⇒ Object
Returns the instance of DiscountTarget for this value, creating a new instance for an unknown value.
-
.from_string(value) ⇒ Object
Returns the instance of DiscountTarget for this value, or nil if not found.
-
.item ⇒ Object
Discount is targeted to an item.
-
.shipping ⇒ Object
Discount is targeting to shipping.
Instance Method Summary collapse
-
#initialize(value) ⇒ DiscountTarget
constructor
A new instance of DiscountTarget.
- #to_hash ⇒ Object
Constructor Details
#initialize(value) ⇒ DiscountTarget
Returns a new instance of DiscountTarget.
18994 18995 18996 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18994 def initialize(value) @value = HttpClient::Preconditions.assert_class('value', value, String) end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
18992 18993 18994 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18992 def value @value end |
Class Method Details
.ALL ⇒ Object
19014 19015 19016 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19014 def DiscountTarget.ALL @@all ||= [DiscountTarget.item, DiscountTarget.shipping] end |
.apply(value) ⇒ Object
Returns the instance of DiscountTarget for this value, creating a new instance for an unknown value
18999 19000 19001 19002 19003 19004 19005 19006 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18999 def DiscountTarget.apply(value) if value.instance_of?(DiscountTarget) value else HttpClient::Preconditions.assert_class_or_nil('value', value, String) value.nil? ? nil : (from_string(value) || DiscountTarget.new(value)) end end |
.from_string(value) ⇒ Object
Returns the instance of DiscountTarget for this value, or nil if not found
19009 19010 19011 19012 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19009 def DiscountTarget.from_string(value) HttpClient::Preconditions.assert_class('value', value, String) DiscountTarget.ALL.find { |v| v.value == value } end |
.item ⇒ Object
Discount is targeted to an item.
19019 19020 19021 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19019 def DiscountTarget.item @@_item ||= DiscountTarget.new('item') end |
.shipping ⇒ Object
Discount is targeting to shipping. Only applicable if the discount is provided at the order level.
19025 19026 19027 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19025 def DiscountTarget.shipping @@_shipping ||= DiscountTarget.new('shipping') end |
Instance Method Details
#to_hash ⇒ Object
19029 19030 19031 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 19029 def to_hash value end |