Class: Io::Flow::V0::Models::TierRuleOutcome

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Overview

Possible outcome types from a tier rule

Defined Under Namespace

Modules: Types

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ TierRuleOutcome

Returns a new instance of TierRuleOutcome.



4248
4249
4250
4251
4252
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4248

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:name], 'TierRuleOutcome')
  @name = HttpClient::Preconditions.assert_class('name', opts.delete(:name), String)
end

Class Method Details

.from_json(hash) ⇒ Object



4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4258

def TierRuleOutcome.from_json(hash)
  HttpClient::Preconditions.assert_class('hash', hash, Hash)
  case HttpClient::Helper.symbolize_keys(hash)[:discriminator]
    when Types::AMOUNT_MARGIN; AmountMargin.new(hash)
    when Types::AT_COST; AtCost.new(hash)
    when Types::FLAT_RATE; FlatRate.new(hash)
    when Types::PERCENT_MARGIN; PercentMargin.new(hash)
    else TierRuleOutcomeUndefinedType.new(:name => union_type_name)
  end
end

Instance Method Details

#to_hashObject



4254
4255
4256
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4254

def to_hash
  subtype_to_hash.merge(:discriminator => @name)
end