Class: Io::Flow::V0::Models::DiscountRuleSubsidyEntitlement

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

Instance Attribute Summary collapse

Attributes inherited from DiscountRuleEntitlement

#discriminator

Instance Method Summary collapse

Methods inherited from DiscountRuleEntitlement

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ DiscountRuleSubsidyEntitlement

Returns a new instance of DiscountRuleSubsidyEntitlement.



37023
37024
37025
37026
37027
37028
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37023

def initialize(incoming={})
  super(:discriminator => DiscountRuleEntitlement::Types::DISCOUNT_RULE_SUBSIDY_ENTITLEMENT)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:targets], 'DiscountRuleSubsidyEntitlement')
  @targets = HttpClient::Preconditions.assert_class('targets', opts.delete(:targets), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::DiscountRuleSubsidyTarget) ? x : ::Io::Flow::V0::Models::DiscountRuleSubsidyTarget.apply(x)) }
end

Instance Attribute Details

#targetsObject (readonly)

Returns the value of attribute targets.



37021
37022
37023
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37021

def targets
  @targets
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



37034
37035
37036
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37034

def copy(incoming={})
  DiscountRuleSubsidyEntitlement.new(subtype_to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end

#subtype_to_hashObject



37038
37039
37040
37041
37042
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37038

def subtype_to_hash
  {
    :targets => targets.map { |o| o.value }
  }
end

#to_jsonObject



37030
37031
37032
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37030

def to_json
  JSON.dump(to_hash)
end