Class: Io::Flow::V0::Models::LocalizedLineItemDiscount
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::LocalizedLineItemDiscount
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Overview
Represents the requested, base, and localized amounts for a discount on a given line item. It applies to the entire line regardless of quantity.
Instance Attribute Summary collapse
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#base ⇒ Object
readonly
Returns the value of attribute base.
-
#currency ⇒ Object
readonly
Returns the value of attribute currency.
-
#discount_label ⇒ Object
readonly
Returns the value of attribute discount_label.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#requested ⇒ Object
readonly
Returns the value of attribute requested.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ LocalizedLineItemDiscount
constructor
A new instance of LocalizedLineItemDiscount.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ LocalizedLineItemDiscount
Returns a new instance of LocalizedLineItemDiscount.
38763 38764 38765 38766 38767 38768 38769 38770 38771 38772 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 38763 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:amount, :currency], 'LocalizedLineItemDiscount') @amount = HttpClient::Preconditions.assert_class('amount', opts.delete(:amount), Numeric) @currency = HttpClient::Preconditions.assert_class('currency', opts.delete(:currency), String) @label = (x = opts.delete(:label); x.nil? ? nil : HttpClient::Preconditions.assert_class('label', x, String)) @base = (x = opts.delete(:base); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::Price) ? x : ::Io::Flow::V0::Models::Price.new(x))) @requested = (x = opts.delete(:requested); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::Money) ? x : ::Io::Flow::V0::Models::Money.new(x))) @discount_label = (x = opts.delete(:discount_label); x.nil? ? nil : HttpClient::Preconditions.assert_class('discount_label', x, String)) end |
Instance Attribute Details
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
38761 38762 38763 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 38761 def amount @amount end |
#base ⇒ Object (readonly)
Returns the value of attribute base.
38761 38762 38763 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 38761 def base @base end |
#currency ⇒ Object (readonly)
Returns the value of attribute currency.
38761 38762 38763 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 38761 def currency @currency end |
#discount_label ⇒ Object (readonly)
Returns the value of attribute discount_label.
38761 38762 38763 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 38761 def discount_label @discount_label end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
38761 38762 38763 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 38761 def label @label end |
#requested ⇒ Object (readonly)
Returns the value of attribute requested.
38761 38762 38763 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 38761 def requested @requested end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
38778 38779 38780 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 38778 def copy(incoming={}) LocalizedLineItemDiscount.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
38782 38783 38784 38785 38786 38787 38788 38789 38790 38791 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 38782 def to_hash { :amount => amount, :currency => currency, :label => label, :base => base.nil? ? nil : base.to_hash, :requested => requested.nil? ? nil : requested.to_hash, :discount_label => discount_label } end |
#to_json ⇒ Object
38774 38775 38776 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 38774 def to_json JSON.dump(to_hash) end |