class Io::Flow::V0::Models::Discount
Attributes
attributes[R]
code[R]
id[R]
label[R]
price[R]
Public Class Methods
new(incoming={})
click to toggle source
Calls superclass method
Io::Flow::V0::Models::Promotion::new
# 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
Public Instance Methods
copy(incoming={})
click to toggle source
# 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()
click to toggle source
# 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()
click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 40008 def to_json JSON.dump(to_hash) end