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.



39095
39096
39097
39098
39099
39100
39101
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39095

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))
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



39093
39094
39095
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39093

def name
  @name
end

#priceObject (readonly)

Returns the value of attribute price.



39093
39094
39095
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39093

def price
  @price
end

#rateObject (readonly)

Returns the value of attribute rate.



39093
39094
39095
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39093

def rate
  @rate
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



39107
39108
39109
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39107

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

#to_hashObject



39111
39112
39113
39114
39115
39116
39117
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39111

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

#to_jsonObject



39103
39104
39105
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39103

def to_json
  JSON.dump(to_hash)
end