Class: Io::Flow::V0::Models::DiscountRuleEntitlement
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::DiscountRuleEntitlement
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Direct Known Subclasses
DiscountRuleEntitlementUndefinedType, DiscountRuleSubsidyEntitlement
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 = {}) ⇒ DiscountRuleEntitlement
constructor
A new instance of DiscountRuleEntitlement.
- #subtype_to_hash ⇒ Object
- #to_hash ⇒ Object
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
#discriminator ⇒ Object (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_hash ⇒ Object
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_hash ⇒ Object
10808 10809 10810 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10808 def to_hash subtype_to_hash.merge(:discriminator => @discriminator) end |