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.



50533
50534
50535
50536
50537
50538
50539
50540
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50533

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.



50531
50532
50533
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50531

def name
  @name
end

#priceObject (readonly)

Returns the value of attribute price.



50531
50532
50533
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50531

def price
  @price
end

#rateObject (readonly)

Returns the value of attribute rate.



50531
50532
50533
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50531

def rate
  @rate
end

#rate_labelObject (readonly)

Returns the value of attribute rate_label.



50531
50532
50533
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50531

def rate_label
  @rate_label
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



50546
50547
50548
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50546

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

#to_hashObject



50550
50551
50552
50553
50554
50555
50556
50557
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50550

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

#to_jsonObject



50542
50543
50544
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50542

def to_json
  JSON.dump(to_hash)
end