Class: Io::Flow::V0::Models::DiscountRuleEntitlement

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

Defined Under Namespace

Modules: Types

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ DiscountRuleEntitlement

Returns a new instance of DiscountRuleEntitlement.



10798
10799
10800
10801
10802
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10798

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

Instance Attribute Details

#discriminatorObject (readonly)

Returns the value of attribute discriminator.



10796
10797
10798
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10796

def discriminator
  @discriminator
end

Class Method Details

.from_json(hash) ⇒ Object



10812
10813
10814
10815
10816
10817
10818
10819
10820
10821
10822
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10812

def DiscountRuleEntitlement.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[discount_rule_entitlement] requires a field named 'discriminator'"
  end
  case discriminator
    when Types::DISCOUNT_RULE_SUBSIDY_ENTITLEMENT; DiscountRuleSubsidyEntitlement.new(hash)
    else DiscountRuleEntitlementUndefinedType.new(:discriminator => discriminator)
  end
end

Instance Method Details

#subtype_to_hashObject



10804
10805
10806
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10804

def subtype_to_hash
  raise 'Cannot serialize an instance of discount_rule_entitlement directly - must use one of the specific types: discount_rule_subsidy_entitlement'
end

#to_hashObject



10808
10809
10810
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10808

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