Class: Io::Flow::V0::Models::ItemMargin

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Overview

Defines a fixed and percent margin to apply to items matching a query.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ ItemMargin

Returns a new instance of ItemMargin.



43848
43849
43850
43851
43852
43853
43854
43855
43856
43857
43858
43859
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43848

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :key, :name, :q, :fixed, :percent, :position], 'ItemMargin')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @key = HttpClient::Preconditions.assert_class('key', opts.delete(:key), String)
  @name = HttpClient::Preconditions.assert_class('name', opts.delete(:name), String)
  @q = HttpClient::Preconditions.assert_class('q', opts.delete(:q), String)
  @fixed = HttpClient::Preconditions.assert_class('fixed', HttpClient::Helper.to_big_decimal(opts.delete(:fixed)), BigDecimal)
  @percent = HttpClient::Preconditions.assert_class('percent', HttpClient::Helper.to_big_decimal(opts.delete(:percent)), BigDecimal)
  @position = HttpClient::Preconditions.assert_class('position', opts.delete(:position), Integer)
  @experience = (x = opts.delete(:experience); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::ExperienceReference) ? x : ::Io::Flow::V0::Models::ExperienceReference.new(x)))
end

Instance Attribute Details

#experienceObject (readonly)

Returns the value of attribute experience.



43846
43847
43848
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43846

def experience
  @experience
end

#fixedObject (readonly)

Returns the value of attribute fixed.



43846
43847
43848
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43846

def fixed
  @fixed
end

#idObject (readonly)

Returns the value of attribute id.



43846
43847
43848
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43846

def id
  @id
end

#keyObject (readonly)

Returns the value of attribute key.



43846
43847
43848
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43846

def key
  @key
end

#nameObject (readonly)

Returns the value of attribute name.



43846
43847
43848
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43846

def name
  @name
end

#percentObject (readonly)

Returns the value of attribute percent.



43846
43847
43848
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43846

def percent
  @percent
end

#positionObject (readonly)

Returns the value of attribute position.



43846
43847
43848
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43846

def position
  @position
end

#qObject (readonly)

Returns the value of attribute q.



43846
43847
43848
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43846

def q
  @q
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



43865
43866
43867
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43865

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

#to_hashObject



43869
43870
43871
43872
43873
43874
43875
43876
43877
43878
43879
43880
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43869

def to_hash
  {
    :id => id,
    :key => key,
    :name => name,
    :q => q,
    :fixed => fixed.to_f.to_s,
    :percent => percent.to_f.to_s,
    :position => position,
    :experience => experience.nil? ? nil : experience.to_hash
  }
end

#to_jsonObject



43861
43862
43863
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 43861

def to_json
  JSON.dump(to_hash)
end