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.



17978
17979
17980
17981
17982
17983
17984
17985
17986
17987
17988
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17978

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.



17976
17977
17978
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17976

def fixed
  @fixed
end

#idObject (readonly)

Returns the value of attribute id.



17976
17977
17978
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17976

def id
  @id
end

#keyObject (readonly)

Returns the value of attribute key.



17976
17977
17978
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17976

def key
  @key
end

#nameObject (readonly)

Returns the value of attribute name.



17976
17977
17978
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17976

def name
  @name
end

#percentObject (readonly)

Returns the value of attribute percent.



17976
17977
17978
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17976

def percent
  @percent
end

#positionObject (readonly)

Returns the value of attribute position.



17976
17977
17978
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17976

def position
  @position
end

#qObject (readonly)

Returns the value of attribute q.



17976
17977
17978
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17976

def q
  @q
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



17994
17995
17996
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17994

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

#to_hashObject



17998
17999
18000
18001
18002
18003
18004
18005
18006
18007
18008
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17998

def to_hash
  {
    :id => id,
    :key => key,
    :name => name,
    :q => q,
    :fixed => fixed,
    :percent => percent,
    :position => position
  }
end

#to_jsonObject



17990
17991
17992
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17990

def to_json
  JSON.dump(to_hash)
end