Class: Io::Flow::V0::Models::DiscountForm
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::DiscountForm
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Attribute Summary collapse
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#offer ⇒ Object
readonly
Returns the value of attribute offer.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ DiscountForm
constructor
A new instance of DiscountForm.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ DiscountForm
Returns a new instance of DiscountForm.
40032 40033 40034 40035 40036 40037 40038 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40032 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:offer], 'DiscountForm') @offer = (x = opts.delete(:offer); x.is_a?(::Io::Flow::V0::Models::DiscountOffer) ? x : ::Io::Flow::V0::Models::DiscountOffer.from_json(x)) @target = (x = (x = opts.delete(:target); x.nil? ? "item" : x); x.is_a?(::Io::Flow::V0::Models::DiscountTarget) ? x : ::Io::Flow::V0::Models::DiscountTarget.apply(x)) @label = (x = opts.delete(:label); x.nil? ? nil : HttpClient::Preconditions.assert_class('label', x, String)) end |
Instance Attribute Details
#label ⇒ Object (readonly)
Returns the value of attribute label.
40030 40031 40032 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40030 def label @label end |
#offer ⇒ Object (readonly)
Returns the value of attribute offer.
40030 40031 40032 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40030 def offer @offer end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
40030 40031 40032 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40030 def target @target end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
40044 40045 40046 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40044 def copy(incoming={}) DiscountForm.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
40048 40049 40050 40051 40052 40053 40054 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40048 def to_hash { :offer => offer.to_hash, :target => target.value, :label => label } end |
#to_json ⇒ Object
40040 40041 40042 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40040 def to_json JSON.dump(to_hash) end |