Class: Io::Flow::V0::Models::AllocationDetailComponent

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 = {}) ⇒ AllocationDetailComponent

Returns a new instance of AllocationDetailComponent.



9332
9333
9334
9335
9336
9337
9338
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9332

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:key, :base, :target], 'AllocationDetailComponent')
  @key = (x = opts.delete(:key); x.is_a?(::Io::Flow::V0::Models::OrderPriceDetailComponentKey) ? x : ::Io::Flow::V0::Models::OrderPriceDetailComponentKey.apply(x))
  @base = HttpClient::Preconditions.assert_class('base', HttpClient::Helper.to_big_decimal(opts.delete(:base)), BigDecimal)
  @target = HttpClient::Preconditions.assert_class('target', HttpClient::Helper.to_big_decimal(opts.delete(:target)), BigDecimal)
end

Instance Attribute Details

#base ⇒ Object (readonly)

Returns the value of attribute base.



9330
9331
9332
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9330

def base
  @base
end

#key ⇒ Object (readonly)

Returns the value of attribute key.



9330
9331
9332
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9330

def key
  @key
end

#target ⇒ Object (readonly)

Returns the value of attribute target.



9330
9331
9332
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9330

def target
  @target
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



9344
9345
9346
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9344

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

#to_hash ⇒ Object



9348
9349
9350
9351
9352
9353
9354
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9348

def to_hash
  {
    :key => key.value,
    :base => base,
    :target => target
  }
end

#to_json ⇒ Object



9340
9341
9342
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9340

def to_json
  JSON.dump(to_hash)
end