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



41178
41179
41180
41181
41182
41183
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41178

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.



41176
41177
41178
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41176

def percentage
  @percentage
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



41189
41190
41191
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41189

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

#subtype_to_hashObject



41193
41194
41195
41196
41197
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41193

def subtype_to_hash
  {
    :percentage => percentage
  }
end

#to_jsonObject



41185
41186
41187
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41185

def to_json
  JSON.dump(to_hash)
end