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.
15069 15070 15071 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15069 def initialize(value) @value = HttpClient::Preconditions.assert_class('value', value, String) end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
15067 15068 15069 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15067 def value @value end |
Class Method Details
.ALL ⇒ Object
15089 15090 15091 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15089 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
15074 15075 15076 15077 15078 15079 15080 15081 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15074 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
15084 15085 15086 15087 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15084 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.
15094 15095 15096 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15094 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.
15100 15101 15102 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15100 def DiscountTarget.shipping @@_shipping ||= DiscountTarget.new('shipping') end |
Instance Method Details
#to_hash ⇒ Object
15104 15105 15106 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 15104 def to_hash value end |