Class: Io::Flow::V0::Models::ItemMarginPostForm

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

Overview

A percent and/or fixed margin to apply to items based on query.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ ItemMarginPostForm

Returns a new instance of ItemMarginPostForm.



34152
34153
34154
34155
34156
34157
34158
34159
34160
34161
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34152

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:name, :q], 'ItemMarginPostForm')
  @name = HttpClient::Preconditions.assert_class('name', opts.delete(:name), String)
  @q = HttpClient::Preconditions.assert_class('q', opts.delete(:q), String)
  @key = (x = opts.delete(:key); x.nil? ? nil : HttpClient::Preconditions.assert_class('key', x, String))
  @fixed = (x = opts.delete(:fixed); x.nil? ? nil : HttpClient::Preconditions.assert_class('fixed', HttpClient::Helper.to_big_decimal(x), BigDecimal))
  @percent = (x = opts.delete(:percent); x.nil? ? nil : HttpClient::Preconditions.assert_class('percent', HttpClient::Helper.to_big_decimal(x), BigDecimal))
  @position = (x = opts.delete(:position); x.nil? ? nil : HttpClient::Preconditions.assert_class('position', x, Integer))
end

Instance Attribute Details

#fixedObject (readonly)

Returns the value of attribute fixed.



34150
34151
34152
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34150

def fixed
  @fixed
end

#keyObject (readonly)

Returns the value of attribute key.



34150
34151
34152
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34150

def key
  @key
end

#nameObject (readonly)

Returns the value of attribute name.



34150
34151
34152
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34150

def name
  @name
end

#percentObject (readonly)

Returns the value of attribute percent.



34150
34151
34152
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34150

def percent
  @percent
end

#positionObject (readonly)

Returns the value of attribute position.



34150
34151
34152
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34150

def position
  @position
end

#qObject (readonly)

Returns the value of attribute q.



34150
34151
34152
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34150

def q
  @q
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



34167
34168
34169
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34167

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

#to_hashObject



34171
34172
34173
34174
34175
34176
34177
34178
34179
34180
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34171

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

#to_jsonObject



34163
34164
34165
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34163

def to_json
  JSON.dump(to_hash)
end