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



13067
13068
13069
13070
13071
13072
13073
13074
13075
13076
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13067

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :name, :q, :fixed, :percent, :position], 'ItemMargin')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), 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.



13065
13066
13067
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13065

def fixed
  @fixed
end

#idObject (readonly)

Returns the value of attribute id.



13065
13066
13067
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13065

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



13065
13066
13067
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13065

def name
  @name
end

#percentObject (readonly)

Returns the value of attribute percent.



13065
13066
13067
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13065

def percent
  @percent
end

#positionObject (readonly)

Returns the value of attribute position.



13065
13066
13067
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13065

def position
  @position
end

#qObject (readonly)

Returns the value of attribute q.



13065
13066
13067
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13065

def q
  @q
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



13082
13083
13084
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13082

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

#to_hashObject



13086
13087
13088
13089
13090
13091
13092
13093
13094
13095
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13086

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

#to_jsonObject



13078
13079
13080
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13078

def to_json
  JSON.dump(to_hash)
end