Class: Io::Flow::V0::Models::OrderSummaryPriceDetail

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Overview

Summaries the io.flow.order.price.v0.models.order_price_detail, removing components and accuracy which are not needed for summary views

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ OrderSummaryPriceDetail

Returns a new instance of OrderSummaryPriceDetail.



41706
41707
41708
41709
41710
41711
41712
41713
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41706

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:price], 'OrderSummaryPriceDetail')
  @price = (x = opts.delete(:price); x.is_a?(::Io::Flow::V0::Models::Price) ? x : ::Io::Flow::V0::Models::Price.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))
  @rate_label = (x = opts.delete(:rate_label); x.nil? ? nil : HttpClient::Preconditions.assert_class('rate_label', x, String))
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



41704
41705
41706
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41704

def name
  @name
end

#priceObject (readonly)

Returns the value of attribute price.



41704
41705
41706
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41704

def price
  @price
end

#rateObject (readonly)

Returns the value of attribute rate.



41704
41705
41706
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41704

def rate
  @rate
end

#rate_labelObject (readonly)

Returns the value of attribute rate_label.



41704
41705
41706
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41704

def rate_label
  @rate_label
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



41719
41720
41721
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41719

def copy(incoming={})
  OrderSummaryPriceDetail.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end

#to_hashObject



41723
41724
41725
41726
41727
41728
41729
41730
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41723

def to_hash
  {
    :price => price.to_hash,
    :name => name,
    :rate => rate.to_f.to_s,
    :rate_label => rate_label
  }
end

#to_jsonObject



41715
41716
41717
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41715

def to_json
  JSON.dump(to_hash)
end