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.



14852
14853
14854
14855
14856
14857
14858
14859
14860
14861
14862
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14852

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

#fixed ⇒ Object (readonly)

Returns the value of attribute fixed.



14850
14851
14852
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14850

def fixed
  @fixed
end

#id ⇒ Object (readonly)

Returns the value of attribute id.



14850
14851
14852
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14850

def id
  @id
end

#key ⇒ Object (readonly)

Returns the value of attribute key.



14850
14851
14852
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14850

def key
  @key
end

#name ⇒ Object (readonly)

Returns the value of attribute name.



14850
14851
14852
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14850

def name
  @name
end

#percent ⇒ Object (readonly)

Returns the value of attribute percent.



14850
14851
14852
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14850

def percent
  @percent
end

#position ⇒ Object (readonly)

Returns the value of attribute position.



14850
14851
14852
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14850

def position
  @position
end

#q ⇒ Object (readonly)

Returns the value of attribute q.



14850
14851
14852
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14850

def q
  @q
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



14868
14869
14870
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14868

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

#to_hash ⇒ Object



14872
14873
14874
14875
14876
14877
14878
14879
14880
14881
14882
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14872

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

#to_json ⇒ Object



14864
14865
14866
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14864

def to_json
  JSON.dump(to_hash)
end