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.



35726
35727
35728
35729
35730
35731
35732
35733
35734
35735
35736
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35726

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)
end

Instance Attribute Details

#fixedObject (readonly)

Returns the value of attribute fixed.



35724
35725
35726
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35724

def fixed
  @fixed
end

#idObject (readonly)

Returns the value of attribute id.



35724
35725
35726
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35724

def id
  @id
end

#keyObject (readonly)

Returns the value of attribute key.



35724
35725
35726
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35724

def key
  @key
end

#nameObject (readonly)

Returns the value of attribute name.



35724
35725
35726
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35724

def name
  @name
end

#percentObject (readonly)

Returns the value of attribute percent.



35724
35725
35726
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35724

def percent
  @percent
end

#positionObject (readonly)

Returns the value of attribute position.



35724
35725
35726
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35724

def position
  @position
end

#qObject (readonly)

Returns the value of attribute q.



35724
35725
35726
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35724

def q
  @q
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



35742
35743
35744
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35742

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

#to_hashObject



35746
35747
35748
35749
35750
35751
35752
35753
35754
35755
35756
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35746

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
  }
end

#to_jsonObject



35738
35739
35740
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 35738

def to_json
  JSON.dump(to_hash)
end