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.
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.
14690 14691 14692 14693 14694 14695 14696 14697 14698 14699 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14690 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)) } end |
Instance Attribute Details
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
14688 14689 14690 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14688 def amount @amount end |
#base ⇒ Object (readonly)
Returns the value of attribute base.
14688 14689 14690 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14688 def base @base end |
#components ⇒ Object (readonly)
Returns the value of attribute components.
14688 14689 14690 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14688 def components @components end |
#currency ⇒ Object (readonly)
Returns the value of attribute currency.
14688 14689 14690 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14688 def currency @currency end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
14688 14689 14690 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14688 def key @key end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
14688 14689 14690 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14688 def label @label end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
14705 14706 14707 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14705 def copy(incoming={}) OrderPriceDetail.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
14709 14710 14711 14712 14713 14714 14715 14716 14717 14718 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14709 def to_hash { :key => key.value, :currency => currency, :amount => amount, :label => label, :base => base.to_hash, :components => components.map { |o| o.to_hash } } end |
#to_json ⇒ Object
14701 14702 14703 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14701 def to_json JSON.dump(to_hash) end |