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.



40116
40117
40118
40119
40120
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40116

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.



40114
40115
40116
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40114

def offers
  @offers
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



40126
40127
40128
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40126

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

#to_hashObject



40130
40131
40132
40133
40134
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40130

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

#to_jsonObject



40122
40123
40124
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40122

def to_json
  JSON.dump(to_hash)
end