Class: Io::Flow::V0::Models::OrderPriceDetail
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::OrderPriceDetail
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Overview
Represents a top-level order price detail, e.g. ‘Subtotal’ or ‘VAT’.
Instance Attribute Summary collapse
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#base ⇒ Object
readonly
Returns the value of attribute base.
-
#components ⇒ Object
readonly
Returns the value of attribute components.
-
#currency ⇒ Object
readonly
Returns the value of attribute currency.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#rate ⇒ Object
readonly
Returns the value of attribute rate.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ OrderPriceDetail
constructor
A new instance of OrderPriceDetail.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ OrderPriceDetail
Returns a new instance of OrderPriceDetail.
31989 31990 31991 31992 31993 31994 31995 31996 31997 31998 31999 32000 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31989 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:key, :currency, :amount, :label, :base, :components], 'OrderPriceDetail') @key = (x = opts.delete(:key); x.is_a?(::Io::Flow::V0::Models::OrderPriceDetailKey) ? x : ::Io::Flow::V0::Models::OrderPriceDetailKey.apply(x)) @currency = HttpClient::Preconditions.assert_class('currency', opts.delete(:currency), String) @amount = HttpClient::Preconditions.assert_class('amount', HttpClient::Helper.to_big_decimal(opts.delete(:amount)), BigDecimal) @label = HttpClient::Preconditions.assert_class('label', opts.delete(:label), String) @base = (x = opts.delete(:base); x.is_a?(::Io::Flow::V0::Models::Price) ? x : ::Io::Flow::V0::Models::Price.new(x)) @components = HttpClient::Preconditions.assert_class('components', opts.delete(:components), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::OrderPriceDetailComponent) ? x : ::Io::Flow::V0::Models::OrderPriceDetailComponent.new(x)) } @name = (x = opts.delete(:name); x.nil? ? nil : HttpClient::Preconditions.assert_class('name', x, String)) @rate = (x = opts.delete(:rate); x.nil? ? nil : HttpClient::Preconditions.assert_class('rate', HttpClient::Helper.to_big_decimal(x), BigDecimal)) end |
Instance Attribute Details
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
31987 31988 31989 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31987 def amount @amount end |
#base ⇒ Object (readonly)
Returns the value of attribute base.
31987 31988 31989 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31987 def base @base end |
#components ⇒ Object (readonly)
Returns the value of attribute components.
31987 31988 31989 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31987 def components @components end |
#currency ⇒ Object (readonly)
Returns the value of attribute currency.
31987 31988 31989 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31987 def currency @currency end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
31987 31988 31989 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31987 def key @key end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
31987 31988 31989 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31987 def label @label end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
31987 31988 31989 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31987 def name @name end |
#rate ⇒ Object (readonly)
Returns the value of attribute rate.
31987 31988 31989 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31987 def rate @rate end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
32006 32007 32008 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 32006 def copy(incoming={}) OrderPriceDetail.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
32010 32011 32012 32013 32014 32015 32016 32017 32018 32019 32020 32021 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 32010 def to_hash { :key => key.value, :currency => currency, :amount => amount, :label => label, :base => base.to_hash, :components => components.map { |o| o.to_hash }, :name => name, :rate => rate } end |
#to_json ⇒ Object
32002 32003 32004 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 32002 def to_json JSON.dump(to_hash) end |