Module: NSConnector::SubList
- Defined in:
- lib/ns_connector/sublist.rb
Overview
Provides a method for grabbing sublists
Class Method Summary collapse
-
.fetch(parent, sublist_id, fields) ⇒ Object
- Grab sublist_id from NetSuite Returns
-
An array of SubListItems.
-
.save!(sublist_items, parent, sublist_id, fields) ⇒ Object
Save our array of SubListItems in the order in which they appear.
Class Method Details
.fetch(parent, sublist_id, fields) ⇒ Object
Grab sublist_id from NetSuite
- Returns
-
An array of SubListItems
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/ns_connector/sublist.rb', line 5 def self.fetch parent, sublist_id, fields NSConnector::Restlet.execute!( :action => 'fetch_sublist', :type_id => parent.type_id, :parent_id => parent.id, :fields => fields, :sublist_id => sublist_id ).map do |upstream_store| NSConnector::SubListItem.new( sublist_id, fields, parent, upstream_store ) end end |
.save!(sublist_items, parent, sublist_id, fields) ⇒ Object
Save our array of SubListItems in the order in which they appear.
- Arguments
-
An array of SubListItem, the parent object and the fields
- Returns
-
An array of SubListItem that have been saved
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/ns_connector/sublist.rb', line 25 def self.save! sublist_items, parent, sublist_id, fields data = sublist_items.uniq.map do |item| item.store end NSConnector::Restlet.execute!( :action => 'update_sublist', :type_id => parent.type_id, :parent_id => parent.id, :fields => fields, :sublist_id => sublist_id, :data => data ) # We have to do this in a second request as NetSuite needs a # short time to think about any added records. return NSConnector::SubList.fetch(parent, sublist_id, fields) end |