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

#to_hash

Constructor Details

#initialize(incoming = {}) ⇒ PercentMargin

Returns a new instance of PercentMargin.



18109
18110
18111
18112
18113
18114
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18109

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

#percentage ⇒ Object (readonly)

Returns the value of attribute percentage.



18107
18108
18109
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18107

def percentage
  @percentage
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



18120
18121
18122
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18120

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

#subtype_to_hash ⇒ Object



18124
18125
18126
18127
18128
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18124

def subtype_to_hash
  {
    :percentage => percentage
  }
end

#to_json ⇒ Object



18116
18117
18118
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18116

def to_json
  JSON.dump(to_hash)
end