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

Instance Method Summary collapse

Methods inherited from TierRuleOutcome

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ PercentMargin

Returns a new instance of PercentMargin.



13853
13854
13855
13856
13857
13858
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13853

def initialize(incoming={})
  super(:name => 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.



13851
13852
13853
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13851

def percentage
  @percentage
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



13864
13865
13866
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13864

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

#subtype_to_hashObject



13868
13869
13870
13871
13872
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13868

def subtype_to_hash
  {
    :percentage => percentage
  }
end

#to_jsonObject



13860
13861
13862
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13860

def to_json
  JSON.dump(to_hash)
end