module NSConnector::SubList

Provides a method for grabbing sublists

Public Class Methods

fetch(parent, sublist_id, fields) click to toggle source

Grab sublist_id from NetSuite

Returns

An array of SubListItems

# 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) click to toggle source

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

# 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