Class: Io::Flow::V0::Models::FeeDeduction

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

Returns a new instance of FeeDeduction.



39824
39825
39826
39827
39828
39829
39830
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39824

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:type, :amount, :description], 'FeeDeduction')
  @type = (x = opts.delete(:type); x.is_a?(::Io::Flow::V0::Models::FeeDeductionType) ? x : ::Io::Flow::V0::Models::FeeDeductionType.apply(x))
  @amount = HttpClient::Preconditions.assert_class('amount', HttpClient::Helper.to_big_decimal(opts.delete(:amount)), BigDecimal)
  @description = HttpClient::Preconditions.assert_class('description', opts.delete(:description), String)
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



39822
39823
39824
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39822

def amount
  @amount
end

#descriptionObject (readonly)

Returns the value of attribute description.



39822
39823
39824
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39822

def description
  @description
end

#typeObject (readonly)

Returns the value of attribute type.



39822
39823
39824
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39822

def type
  @type
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



39836
39837
39838
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39836

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

#to_hashObject



39840
39841
39842
39843
39844
39845
39846
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39840

def to_hash
  {
    :type => type.value,
    :amount => amount.to_f.to_s,
    :description => description
  }
end

#to_jsonObject



39832
39833
39834
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39832

def to_json
  JSON.dump(to_hash)
end