Class: Io::Flow::V0::Models::ItemMarginPutForm

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 = {}) ⇒ ItemMarginPutForm

Returns a new instance of ItemMarginPutForm.



42043
42044
42045
42046
42047
42048
42049
42050
42051
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42043

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



42041
42042
42043
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42041

def fixed
  @fixed
end

#nameObject (readonly)

Returns the value of attribute name.



42041
42042
42043
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42041

def name
  @name
end

#percentObject (readonly)

Returns the value of attribute percent.



42041
42042
42043
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42041

def percent
  @percent
end

#positionObject (readonly)

Returns the value of attribute position.



42041
42042
42043
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42041

def position
  @position
end

#qObject (readonly)

Returns the value of attribute q.



42041
42042
42043
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42041

def q
  @q
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



42057
42058
42059
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42057

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

#to_hashObject



42061
42062
42063
42064
42065
42066
42067
42068
42069
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42061

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

#to_jsonObject



42053
42054
42055
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 42053

def to_json
  JSON.dump(to_hash)
end