Skip to content

Commit 7f33a3e

Browse files
committed
Added support for querying the version of the required RESTlet script.
1 parent c7f2646 commit 7f33a3e

File tree

5 files changed

+39
-4
lines changed

5 files changed

+39
-4
lines changed

bl/netSuiteBl.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ let uiHelper = require('../helpers/uiHelper');
77
let netsuiteList = require('../helpers/netsuiteList');
88
let _ = require('underscore');
99

10+
function getRestletVersion() {
11+
nsRestClient.getRestletVersion(function (err, res) {
12+
if (hasNetSuiteError("Could not determine the version of the RESTlet deployed to NetSuite. Are you sure you have uploaded the most recent version of the RESTlet 'vscodeExtensionRestlet.js'?", err, res)) {
13+
return;
14+
}
15+
vscode.window.showInformationMessage('RESTlet version is ' + res.body.restletVersion);
16+
});
17+
}
18+
1019
function downloadFileFromNetSuite(file) {
1120
nsRestClient.getFile(file, function (err, res) {
1221
if (hasNetSuiteError("ERROR downloading file", err, res)) {
@@ -171,4 +180,5 @@ exports.downloadDirectoryFromNetSuite = downloadDirectoryFromNetSuite;
171180
exports.uploadFileToNetSuite = uploadFileToNetSuite;
172181
exports.deleteFileInNetSuite = deleteFileInNetSuite;
173182
exports.addCustomDependencyToActiveFile = addCustomDependencyToActiveFile;
174-
exports.addNetSuiteDependencyToActiveFile = addNetSuiteDependencyToActiveFile;
183+
exports.addNetSuiteDependencyToActiveFile = addNetSuiteDependencyToActiveFile;
184+
exports.getRestletVersion = getRestletVersion;

extension.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ function activate(context) {
113113
netSuiteBl.addNetSuiteDependencyToActiveFile(editor);
114114
});
115115
context.subscriptions.push(addNSDependencyDisposable);
116+
117+
let getRestletVersion = vscode.commands.registerCommand('netsuite-upload.getRestletVersion', () => {
118+
netSuiteBl.getRestletVersion();
119+
});
120+
context.subscriptions.push(getRestletVersion);
116121
}
117122
exports.activate = activate;
118123

helpers/netSuiteRestClient.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,18 @@ function getData(type, objectPath, callback) {
7474
});
7575
}
7676

77+
function getRestletVersion(callback) {
78+
superagent.get(vscode.workspace.getConfiguration('netSuiteUpload').restlet)
79+
.set("Content-Type", "application/json")
80+
.set("Authorization", getAuthHeader())
81+
.query({
82+
type: "version"
83+
})
84+
.end((err, res) => {
85+
callback(err, res);
86+
});
87+
}
88+
7789
function postFile(file, content, callback) {
7890
postData('file', file.fsPath, content, callback);
7991
}
@@ -113,8 +125,10 @@ function deleteData(type, objectPath, callback) {
113125
});
114126
}
115127

128+
116129
exports.getRelativePath = getRelativePath;
117130
exports.getFile = getFile;
118131
exports.postFile = postFile;
119132
exports.deleteFile = deleteFile;
120-
exports.getDirectory = getDirectory;
133+
exports.getDirectory = getDirectory;
134+
exports.getRestletVersion = getRestletVersion;

netSuiteRestlet/vscodeExtensionRestlet.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ define(['N/file', 'N/search', 'N/record', 'N/log', 'N/error'], function (
1111
error
1212
) {
1313

14-
const RESTLET_VERSION = '1.0.1';
14+
const RESTLET_VERSION = '1.0.2';
1515
const RESTLET_NAME = 'vscodeExtensionRestlet.js';
1616

1717

package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
"onCommand:netsuite-upload.previewFile",
2828
"onCommand:netsuite-upload.downloadFolder",
2929
"onCommand:netsuite-upload.addCustomDependency",
30-
"onCommand:netsuite-upload.addNSDependency"
30+
"onCommand:netsuite-upload.addNSDependency",
31+
"onCommand:netsuite-upload.getRestletVersion"
3132
],
3233
"main": "./extension",
3334
"contributes": {
@@ -108,6 +109,11 @@
108109
"command": "netsuite-upload.addNSDependency",
109110
"title": "Add NetSuite Dependency",
110111
"category": "NSUpload"
112+
},
113+
{
114+
"command": "netsuite-upload.getRestletVersion",
115+
"title": "Get version of associated NSUpload RESTlet",
116+
"category": "NSUpload"
111117
}
112118
],
113119
"menus": {

0 commit comments

Comments
 (0)