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.
-
#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.
13029 13030 13031 13032 13033 13034 13035 13036 13037 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13029 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:key, :currency, :amount, :label, :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', opts.delete(:amount), Numeric) @label = HttpClient::Preconditions.assert_class('label', opts.delete(:label), String) @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.
13027 13028 13029 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13027 def amount @amount end |
#components ⇒ Object (readonly)
Returns the value of attribute components.
13027 13028 13029 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13027 def components @components end |
#currency ⇒ Object (readonly)
Returns the value of attribute currency.
13027 13028 13029 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13027 def currency @currency end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
13027 13028 13029 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13027 def key @key end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
13027 13028 13029 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13027 def label @label end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
13043 13044 13045 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13043 def copy(incoming={}) OrderPriceDetail.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
13047 13048 13049 13050 13051 13052 13053 13054 13055 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13047 def to_hash { :key => key.value, :currency => currency, :amount => amount, :label => label, :components => components.map { |o| o.to_hash } } end |
#to_json ⇒ Object
13039 13040 13041 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13039 def to_json JSON.dump(to_hash) end |