A set of NetSuite RESTlets and a REST client for interacting with them.
All RESTlets are designed to be used by bang.
npm install --save rbwsam/bang-netsuite
- Login to your NetSuite account
- Upload the files in
./restlets
- Create and deploy RESTlet scripts for each file
- Update
SCRIPT
andDEPLOY
for each class in./lib/resources
var NetSuite = require('bang-netsuite');
var ns = new NetSuite({
email: 'YOUR NS EMAIL',
password: 'YOUR NS PASSWORD',
company: 'YOUR NS COMPANY ID'
});
// Find customer
ns.Customers.find(42).then(function(result) {
console.log(result); The customer
}, function(err) {
console.log(err);
});
// Create a customer
var han = { firstname: 'Han', lastname: 'Solo' }
ns.Customers.create(han).then(function(result) {
console.log(result); // The persisted customer
}, function(err) {
console.log(err);
});
// Get all Inventory Items (API limited to 1000)
ns.InventoryItems.find().then(function(result) {
console.log(result); // Array of inventory items
}, function(err) {
console.log(err);
});
// Create a Sales Order
var salesOrder = {
customerId: 42,
items: [
{
id: 99,
quantity: 1,
amount: 1.99 // The total (quantity * item price)
},
{
id: 203,
quantity: 3,
amount: 5.97 // The total (quantity * item price)
}
]
};
ns.SalesOrders.create(salesOrder).then(function(result) {
console.log(result); // The persisted sales order
}, function(err) {
console.log(err);
});
npm test