Class: Io::Flow::V0::Models::Discount
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#price ⇒ Object
readonly
Returns the value of attribute price.
Attributes inherited from Promotion
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ Discount
constructor
A new instance of Discount.
- #subtype_to_hash ⇒ Object
- #to_json ⇒ Object
Methods inherited from Promotion
Constructor Details
#initialize(incoming = {}) ⇒ Discount
Returns a new instance of Discount.
39997 39998 39999 40000 40001 40002 40003 40004 40005 40006 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39997 def initialize(incoming={}) super(:discriminator => Promotion::Types::DISCOUNT) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:id, :label, :price], 'Discount') @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String) @code = (x = opts.delete(:code); x.nil? ? nil : HttpClient::Preconditions.assert_class('code', x, String)) @label = HttpClient::Preconditions.assert_class('label', opts.delete(:label), String) @price = (x = opts.delete(:price); x.is_a?(::Io::Flow::V0::Models::PriceWithBase) ? x : ::Io::Flow::V0::Models::PriceWithBase.new(x)) @attributes = (x = opts.delete(:attributes); x.nil? ? nil : HttpClient::Preconditions.assert_class('attributes', x, Hash).inject({}) { |h, d| h[d[0]] = HttpClient::Preconditions.assert_class('attributes', d[1], String); h }) end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
39995 39996 39997 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39995 def attributes @attributes end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
39995 39996 39997 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39995 def code @code end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
39995 39996 39997 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39995 def id @id end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
39995 39996 39997 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39995 def label @label end |
#price ⇒ Object (readonly)
Returns the value of attribute price.
39995 39996 39997 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39995 def price @price end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
40012 40013 40014 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40012 def copy(incoming={}) Discount.new(subtype_to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#subtype_to_hash ⇒ Object
40016 40017 40018 40019 40020 40021 40022 40023 40024 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40016 def subtype_to_hash { :id => id, :code => code, :label => label, :price => price.to_hash, :attributes => attributes.nil? ? nil : attributes } end |
#to_json ⇒ Object
40008 40009 40010 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40008 def to_json JSON.dump(to_hash) end |