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.
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.
21969 21970 21971 21972 21973 21974 21975 21976 21977 21978 21979 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21969 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)) end |
Instance Attribute Details
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
21967 21968 21969 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21967 def amount @amount end |
#base ⇒ Object (readonly)
Returns the value of attribute base.
21967 21968 21969 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21967 def base @base end |
#components ⇒ Object (readonly)
Returns the value of attribute components.
21967 21968 21969 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21967 def components @components end |
#currency ⇒ Object (readonly)
Returns the value of attribute currency.
21967 21968 21969 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21967 def currency @currency end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
21967 21968 21969 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21967 def key @key end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
21967 21968 21969 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21967 def label @label end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
21967 21968 21969 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21967 def name @name end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
21985 21986 21987 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21985 def copy(incoming={}) OrderPriceDetail.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
21989 21990 21991 21992 21993 21994 21995 21996 21997 21998 21999 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21989 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 } end |
#to_json ⇒ Object
21981 21982 21983 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21981 def to_json JSON.dump(to_hash) end |