Class: Io::Flow::V0::Models::AmountMargin

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 price

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 = {}) ⇒ AmountMargin

Returns a new instance of AmountMargin.



26687
26688
26689
26690
26691
26692
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26687

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

Instance Attribute Details

#marginObject (readonly)

Returns the value of attribute margin.



26685
26686
26687
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26685

def margin
  @margin
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



26698
26699
26700
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26698

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

#subtype_to_hashObject



26702
26703
26704
26705
26706
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26702

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

#to_jsonObject



26694
26695
26696
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26694

def to_json
  JSON.dump(to_hash)
end