Class: Io::Flow::V0::Models::AmountMargin
- Inherits:
-
TierRuleOutcome
- Object
- TierRuleOutcome
- Io::Flow::V0::Models::AmountMargin
- 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
-
#margin ⇒ Object
readonly
Returns the value of attribute margin.
Attributes inherited from TierRuleOutcome
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ AmountMargin
constructor
A new instance of AmountMargin.
- #subtype_to_hash ⇒ Object
- #to_json ⇒ Object
Methods inherited from TierRuleOutcome
Constructor Details
#initialize(incoming = {}) ⇒ AmountMargin
Returns a new instance of AmountMargin.
20117 20118 20119 20120 20121 20122 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20117 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
#margin ⇒ Object (readonly)
Returns the value of attribute margin.
20115 20116 20117 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20115 def margin @margin end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
20128 20129 20130 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20128 def copy(incoming={}) AmountMargin.new(subtype_to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#subtype_to_hash ⇒ Object
20132 20133 20134 20135 20136 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20132 def subtype_to_hash { :margin => margin.to_hash } end |
#to_json ⇒ Object
20124 20125 20126 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20124 def to_json JSON.dump(to_hash) end |