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
-
#accuracy ⇒ Object
readonly
Returns the value of attribute accuracy.
-
#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.
-
#rate_label ⇒ Object
readonly
Returns the value of attribute rate_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.
41035 41036 41037 41038 41039 41040 41041 41042 41043 41044 41045 41046 41047 41048 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41035 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)) @accuracy = (x = (x = opts.delete(:accuracy); x.nil? ? "calculated" : x); x.is_a?(::Io::Flow::V0::Models::PriceAccuracy) ? x : ::Io::Flow::V0::Models::PriceAccuracy.apply(x)) @rate_label = (x = opts.delete(:rate_label); x.nil? ? nil : HttpClient::Preconditions.assert_class('rate_label', x, String)) end |
Instance Attribute Details
#accuracy ⇒ Object (readonly)
Returns the value of attribute accuracy.
41033 41034 41035 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41033 def accuracy @accuracy end |
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
41033 41034 41035 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41033 def amount @amount end |
#base ⇒ Object (readonly)
Returns the value of attribute base.
41033 41034 41035 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41033 def base @base end |
#components ⇒ Object (readonly)
Returns the value of attribute components.
41033 41034 41035 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41033 def components @components end |
#currency ⇒ Object (readonly)
Returns the value of attribute currency.
41033 41034 41035 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41033 def currency @currency end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
41033 41034 41035 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41033 def key @key end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
41033 41034 41035 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41033 def label @label end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
41033 41034 41035 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41033 def name @name end |
#rate ⇒ Object (readonly)
Returns the value of attribute rate.
41033 41034 41035 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41033 def rate @rate end |
#rate_label ⇒ Object (readonly)
Returns the value of attribute rate_label.
41033 41034 41035 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41033 def rate_label @rate_label end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
41054 41055 41056 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41054 def copy(incoming={}) OrderPriceDetail.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
41058 41059 41060 41061 41062 41063 41064 41065 41066 41067 41068 41069 41070 41071 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41058 def to_hash { :key => key.value, :currency => currency, :amount => amount.to_f.to_s, :label => label, :base => base.to_hash, :components => components.map { |o| o.to_hash }, :name => name, :rate => rate.to_f.to_s, :accuracy => accuracy.value, :rate_label => rate_label } end |
#to_json ⇒ Object
41050 41051 41052 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41050 def to_json JSON.dump(to_hash) end |