Class: Io::Flow::V0::Models::DiscountRule
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::DiscountRule
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Attribute Summary collapse
-
#offers ⇒ Object
readonly
Returns the value of attribute offers.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ DiscountRule
constructor
A new instance of DiscountRule.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ DiscountRule
Returns a new instance of DiscountRule.
29953 29954 29955 29956 29957 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 29953 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
#offers ⇒ Object (readonly)
Returns the value of attribute offers.
29951 29952 29953 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 29951 def offers @offers end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
29963 29964 29965 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 29963 def copy(incoming={}) DiscountRule.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
29967 29968 29969 29970 29971 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 29967 def to_hash { :offers => offers.map { |o| o.to_hash } } end |
#to_json ⇒ Object
29959 29960 29961 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 29959 def to_json JSON.dump(to_hash) end |