Class: Io::Flow::V0::Models::OrderSummaryLevy

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ OrderSummaryLevy

Returns a new instance of OrderSummaryLevy.



41579
41580
41581
41582
41583
41584
41585
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41579

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:rate, :value], 'OrderSummaryLevy')
  @rate = HttpClient::Preconditions.assert_class('rate', HttpClient::Helper.to_big_decimal(opts.delete(:rate)), BigDecimal)
  @rate_label = (x = opts.delete(:rate_label); x.nil? ? nil : HttpClient::Preconditions.assert_class('rate_label', x, String))
  @value = (x = opts.delete(:value); x.is_a?(::Io::Flow::V0::Models::Price) ? x : ::Io::Flow::V0::Models::Price.new(x))
end

Instance Attribute Details

#rateObject (readonly)

Returns the value of attribute rate.



41577
41578
41579
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41577

def rate
  @rate
end

#rate_labelObject (readonly)

Returns the value of attribute rate_label.



41577
41578
41579
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41577

def rate_label
  @rate_label
end

#valueObject (readonly)

Returns the value of attribute value.



41577
41578
41579
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41577

def value
  @value
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



41591
41592
41593
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41591

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

#to_hashObject



41595
41596
41597
41598
41599
41600
41601
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41595

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

#to_jsonObject



41587
41588
41589
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41587

def to_json
  JSON.dump(to_hash)
end