Skip to content

Instantly share code, notes, and snippets.

@cafeasp
Created May 19, 2019 16:21
Show Gist options
  • Save cafeasp/dc498e4ce7be02d195cfa779070bf020 to your computer and use it in GitHub Desktop.
Save cafeasp/dc498e4ce7be02d195cfa779070bf020 to your computer and use it in GitHub Desktop.
NetSuite Restlet Template
/**
* @NApiVersion 2.x
* @NScriptType Restlet
* @NModuleScope SameAccount
*/
define(['N/search', 'N/record'],
/**
* @param {search} search
* @param {record} record
*/
function (search, record) {
/**
* Function called upon sending a GET request to the RESTlet.
*
* @param {Object} requestParams - Parameters from HTTP request URL; parameters will be passed into function as an Object (for all supported content types)
* @returns {string | Object} HTTP response body; return string when request Content-Type is 'text/plain'; return Object when request Content-Type is 'application/json'
* @since 2015.1
*/
function doGet() {
}
/**
* Function called upon sending a PUT request to the RESTlet.
* @param {string | Object} requestBody - The HTTP request body; request body will be passed into function as a string when request Content-Type is 'text/plain'
* or parsed into an Object when request Content-Type is 'application/json' (in which case the body must be a valid JSON)
* @returns {string | Object} HTTP response body; return string when request Content-Type is 'text/plain'; return Object when request Content-Type is 'application/json'
* @since 2015.2
*/
function doPut(requestBody) {
}
/**
* Function called upon sending a POST request to the RESTlet.
*
* @param {string | Object} requestBody - The HTTP request body; request body will be passed into function as a string when request Content-Type is 'text/plain'
* or parsed into an Object when request Content-Type is 'application/json' (in which case the body must be a valid JSON)
* @returns {string | Object} HTTP response body; return string when request Content-Type is 'text/plain'; return Object when request Content-Type is 'application/json'
* @since 2015.2
*/
function doPost(requestBody) {
}
/**
* Function called upon sending a DELETE request to the RESTlet.
*
* @param {Object} requestParams - Parameters from HTTP request URL; parameters will be passed into function as an Object (for all supported content types)
* @returns {string | Object} HTTP response body; return string when request Content-Type is 'text/plain'; return Object when request Content-Type is 'application/json'
* @since 2015.2
*/
function doDelete(requestParams) {
}
return {
'get': doGet,
put: doPut,
post: doPost,
'delete': doDelete
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment