Class: Io::Flow::V0::Models::DiscountRule

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ DiscountRule

Returns a new instance of DiscountRule.



30652
30653
30654
30655
30656
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30652

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:offers], 'DiscountRule')
  @offers = HttpClient::Preconditions.assert_class('offers', opts.delete(:offers), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::DiscountRuleOffer) ? x : ::Io::Flow::V0::Models::DiscountRuleOffer.new(x)) }
end

Instance Attribute Details

#offersObject (readonly)

Returns the value of attribute offers.



30650
30651
30652
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30650

def offers
  @offers
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



30662
30663
30664
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30662

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

#to_hashObject



30666
30667
30668
30669
30670
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30666

def to_hash
  {
    :offers => offers.map { |o| o.to_hash }
  }
end

#to_jsonObject



30658
30659
30660
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30658

def to_json
  JSON.dump(to_hash)
end