Class: Io::Flow::V0::Models::PercentMargin

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

Overview

Rule outcome where shipping surfaced in quote is actual cost plus a predefined margin percentage

Instance Attribute Summary collapse

Attributes inherited from TierRuleOutcome

#discriminator

Instance Method Summary collapse

Methods inherited from TierRuleOutcome

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ PercentMargin

Returns a new instance of PercentMargin.



26487
26488
26489
26490
26491
26492
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26487

def initialize(incoming={})
  super(:discriminator => TierRuleOutcome::Types::PERCENT_MARGIN)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:percentage], 'PercentMargin')
  @percentage = HttpClient::Preconditions.assert_class('percentage', opts.delete(:percentage), Numeric)
end

Instance Attribute Details

#percentageObject (readonly)

Returns the value of attribute percentage.



26485
26486
26487
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26485

def percentage
  @percentage
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



26498
26499
26500
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26498

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

#subtype_to_hashObject



26502
26503
26504
26505
26506
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26502

def subtype_to_hash
  {
    :percentage => percentage
  }
end

#to_jsonObject



26494
26495
26496
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26494

def to_json
  JSON.dump(to_hash)
end