Class: Io::Flow::V0::Models::AmountMarginForm

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

Instance Attribute Summary collapse

Attributes inherited from TierRuleOutcomeForm

#discriminator

Instance Method Summary collapse

Methods inherited from TierRuleOutcomeForm

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ AmountMarginForm

Returns a new instance of AmountMarginForm.



12063
12064
12065
12066
12067
12068
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12063

def initialize(incoming={})
  super(:discriminator => TierRuleOutcomeForm::Types::AMOUNT_MARGIN_FORM)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:margin], 'AmountMarginForm')
  @margin = (x = opts.delete(:margin); x.is_a?(::Io::Flow::V0::Models::Money) ? x : ::Io::Flow::V0::Models::Money.new(x))
end

Instance Attribute Details

#marginObject (readonly)

Returns the value of attribute margin.



12061
12062
12063
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12061

def margin
  @margin
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



12074
12075
12076
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12074

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

#subtype_to_hashObject



12078
12079
12080
12081
12082
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12078

def subtype_to_hash
  {
    :margin => margin.to_hash
  }
end

#to_jsonObject



12070
12071
12072
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12070

def to_json
  JSON.dump(to_hash)
end