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.



42218
42219
42220
42221
42222
42223
42224
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42218

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.



42216
42217
42218
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42216

def rate
  @rate
end

#rate_labelObject (readonly)

Returns the value of attribute rate_label.



42216
42217
42218
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42216

def rate_label
  @rate_label
end

#valueObject (readonly)

Returns the value of attribute value.



42216
42217
42218
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42216

def value
  @value
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



42230
42231
42232
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42230

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

#to_hashObject



42234
42235
42236
42237
42238
42239
42240
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42234

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

#to_jsonObject



42226
42227
42228
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42226

def to_json
  JSON.dump(to_hash)
end