Class: Io::Flow::V0::Models::TierRuleOutcomeForm
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::TierRuleOutcomeForm
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Direct Known Subclasses
AmountMarginForm, FlatRateForm, TierRuleOutcomeFormUndefinedType
Defined Under Namespace
Modules: Types
Instance Attribute Summary collapse
-
#discriminator ⇒ Object
readonly
Returns the value of attribute discriminator.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(incoming = {}) ⇒ TierRuleOutcomeForm
constructor
A new instance of TierRuleOutcomeForm.
- #subtype_to_hash ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ TierRuleOutcomeForm
Returns a new instance of TierRuleOutcomeForm.
16065 16066 16067 16068 16069 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16065 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:discriminator], 'TierRuleOutcomeForm') @discriminator = HttpClient::Preconditions.assert_class('discriminator', opts.delete(:discriminator), String) end |
Instance Attribute Details
#discriminator ⇒ Object (readonly)
Returns the value of attribute discriminator.
16063 16064 16065 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16063 def discriminator @discriminator end |
Class Method Details
.from_json(hash) ⇒ Object
16079 16080 16081 16082 16083 16084 16085 16086 16087 16088 16089 16090 16091 16092 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16079 def TierRuleOutcomeForm.from_json(hash) HttpClient::Preconditions.assert_class('hash', hash, Hash) discriminator = HttpClient::Helper.symbolize_keys(hash)[:discriminator].to_s.strip if discriminator.empty? raise "Union type[tier_rule_outcome_form] requires a field named 'discriminator'" end case discriminator when Types::AMOUNT_MARGIN_FORM; AmountMarginForm.new(hash) when Types::FLAT_RATE_FORM; FlatRateForm.new(hash) when Types::AT_COST; AtCost.new(hash) when Types::PERCENT_MARGIN; PercentMargin.new(hash) else TierRuleOutcomeFormUndefinedType.new(:discriminator => discriminator) end end |
Instance Method Details
#subtype_to_hash ⇒ Object
16071 16072 16073 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16071 def subtype_to_hash raise 'Cannot serialize an instance of tier_rule_outcome_form directly - must use one of the specific types: amount_margin_form, flat_rate_form, at_cost, percent_margin' end |
#to_hash ⇒ Object
16075 16076 16077 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16075 def to_hash subtype_to_hash.merge(:discriminator => @discriminator) end |