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.



54406
54407
54408
54409
54410
54411
54412
54413
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54406

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.



54404
54405
54406
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54404

def name
  @name
end

#priceObject (readonly)

Returns the value of attribute price.



54404
54405
54406
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54404

def price
  @price
end

#rateObject (readonly)

Returns the value of attribute rate.



54404
54405
54406
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54404

def rate
  @rate
end

#rate_labelObject (readonly)

Returns the value of attribute rate_label.



54404
54405
54406
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54404

def rate_label
  @rate_label
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



54419
54420
54421
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54419

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

#to_hashObject



54423
54424
54425
54426
54427
54428
54429
54430
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54423

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

#to_jsonObject



54415
54416
54417
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54415

def to_json
  JSON.dump(to_hash)
end