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.
-
#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.
22949 22950 22951 22952 22953 22954 22955 22956 22957 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22949 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))) end |
Instance Attribute Details
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
22947 22948 22949 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22947 def amount @amount end |
#base ⇒ Object (readonly)
Returns the value of attribute base.
22947 22948 22949 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22947 def base @base end |
#currency ⇒ Object (readonly)
Returns the value of attribute currency.
22947 22948 22949 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22947 def currency @currency end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
22947 22948 22949 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22947 def label @label end |
#requested ⇒ Object (readonly)
Returns the value of attribute requested.
22947 22948 22949 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22947 def requested @requested end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
22963 22964 22965 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22963 def copy(incoming={}) LocalizedLineItemDiscount.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
22967 22968 22969 22970 22971 22972 22973 22974 22975 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22967 def to_hash { :amount => amount, :currency => currency, :label => label, :base => base.nil? ? nil : base.to_hash, :requested => requested.nil? ? nil : requested.to_hash } end |
#to_json ⇒ Object
22959 22960 22961 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 22959 def to_json JSON.dump(to_hash) end |