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.



43043
43044
43045
43046
43047
43048
43049
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43043

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:type, :amount], '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 = (x = opts.delete(:description); x.nil? ? nil : HttpClient::Preconditions.assert_class('description', x, String))
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



43041
43042
43043
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43041

def amount
  @amount
end

#descriptionObject (readonly)

Returns the value of attribute description.



43041
43042
43043
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43041

def description
  @description
end

#typeObject (readonly)

Returns the value of attribute type.



43041
43042
43043
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43041

def type
  @type
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



43055
43056
43057
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43055

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

#to_hashObject



43059
43060
43061
43062
43063
43064
43065
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43059

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

#to_jsonObject



43051
43052
43053
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43051

def to_json
  JSON.dump(to_hash)
end