Class: MoySklad::Model::Demand

Inherits:
Client::Base show all
Defined in:
lib/moy_sklad/model/demand.rb

Instance Method Summary collapse

Methods inherited from Client::Base

#applicable?, collection_name, #create, #destroy, element_path, find, new_element_path, #save

Methods inherited from ActiveResource::Base

#find_object

Constructor Details

#initialize(*args) ⇒ Demand

Returns a new instance of Demand.



3
4
5
6
7
8
# File 'lib/moy_sklad/model/demand.rb', line 3

def initialize(*args)
  super(*args)
  create_nested_collection(:attribute)
  create_nested_resource(:sum)
  create_nested_collection(:shipmentOut)
end

Instance Method Details

#add_item(id, options) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/moy_sklad/model/demand.rb', line 10

def add_item(id, options)
  item = create_and_load_resource("shipmentOut",
                                  { goodUuid: id }.merge!(options))
  if to_a(:shipmentOut).empty?
    self.shipmentOut = [item]
  else
    self.shipmentOut << item
  end
end