Skip to content
RESTlet-based client for Netsuite
JavaScript Ruby
Find file
Latest commit b66bc33 @fastjames fastjames Use new method for handling large saved searches
The method we have used up til now is deficient when handling a large
saved search containing a large number of rows with the same internal ID
(!). The new method needs testing before it's used everywhere.

README.rdoc

Netsuite Rest Client

NOTE: This project is being replaced by rest_suite. If you're starting a new system, please use that codebase. We will keep netsuite-rest-client on life support for the time being.

This is intended to be a RESTlet-based client for Netsuite. It should offer a significant speed advantage over the normal SOAP-based connection scheme (and it should cost less to operate since it allows 50 simultaneous connections on an ordinary license).

Contributing to netsuite-rest-client

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet

  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it

  • Fork the project

  • Start a feature/bugfix branch

  • Commit and push until you are happy with your contribution

  • Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.

  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

  • If you're interested in the future of netsuite-rest-client, take a look at the rest_suite.

Copyright

Copyright © 2012 Acumen Brands, Inc. See LICENSE.txt for further details.

Method Documentation

Generally, all arguments are ultimately strings as they are placed into JSON or URI requests. However, the client is capable of accepting Fixnum objects and others, so long as the data type includes a to_s method. If a specific data type is expected, it will be declared in the params section.

Returns are almost always a hash parsed from a JSON casting of the server-side object.

initialize

Params: account_id: business account id login: account login associated with the business id password: password for the login role_id: id of the role for the client to assume

Return: A new client object with the given parameters

Example: Netsuite::Client.new('123456', 'email@domain.suffix', 'passw0rd', '17')

initialize_record

Params: record_type: name of the record type

Return: A hash of field names with default values for a Netsuite record of the given type

Example: initialize_record('InventoryItem')

get_record

Params: record_type: name of the record type internal_id: the internal id of the Netsuite record

Return: A hash of field names populated with values from the record matching the internal id

Example: get_record('InventoryItem', '233')

search_records

Params: record_type: name of the record type search_filters: a hash of fields associated to a hash of the desire value and operator for comparison return_columns: a hash of field names associated with field JOIN requests options: :search_batch_size - (String/Fixnum) set a max size of record to fetch in a single request :verbose - (Boolean) prints status of search after each execution while fetching records

Return: An array of record hashes

Example: search_records('InventoryItem', {'displayName' => {'value'=>'PRODUCTSKU', 'operator'=>'is'}}, {'displayName' => nil, 'custitem22' => nil})

upsert

Params: record_type: name of the record type record_data: a hash of fields associated with the desired values options: :batch_size - (String/Fixnum) size of batch to be written in a single request :do_sourcing - (Boolean) enables or disabled sourcing in nlapiSubmitRecord calls :ignore_mandatory - (Boolean) ignore mandatory feilds

** If an id is provided as a field, it will updated a record with the given id or fail to write, ** otherwise it creates a new record with the given values.

Return: An array of responses for each requested write. It will be an internal id for the newly created or updated record paired with the parameters hash used to create or update the record. In the vent of an error, the id will be replaced by the exception caught upon write.

Example: upsert('InventoryItem', [{'id' => {'value'=>'1234567', 'operator=>'is'}, 'displayName' => {'value'=>'PRODUCTSKU', 'operator'=>'is'}}])

delete

Params: record_type: name of the record type internal_ids: an array of internal record ids options: :batch_size - (String/Fixnum) size of batch to be written in a single request

Return: An array of response lists. Each record response will be the internal id paired with false in the event of success, or an exception in the event of a deletion failure.

Example: delete('InventoryItem', ['1', '2356', '584309'])

get_saved_search

Params: record_type: name of the record type the search will return search_id: id of the saved search options: :search_batch_size - (String/Fixnum) set a max size of record to fetch in a single request :verbose - (Boolean) prints status of search after each execution while fetching records

Return: A list of record hashes corresponding to each row of the search results.

Example: get_saved_search('InventoryItem', '726')

Something went wrong with that request. Please try again.