New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

smartsheet

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

smartsheet - npm Package Compare versions

Comparing version 0.2.0 to 1.0.0-beta.0

.jshintrc

84

index.js

@@ -0,8 +1,83 @@

var _ = require('underscore');
var winston = require('winston');
var apiUrls = require('./lib/utils/apis.js');
exports.createClient = function(options) {
// Possible TODO: Namespace parameters for different subcomponents
// E.g. clientOptions.requestor.instance OR
// clientOptions.requestor.settings
// w/ sub-paths maxRetryDurationSeconds and calcRetryBackoff
function buildRequestor(clientOptions) {
if(clientOptions.requestor) return clientOptions.requestor;
var requestorConfig =
_.pick(clientOptions, 'maxRetryDurationSeconds', 'calcRetryBackoff');
if(requestorConfig.maxRetryDurationSeconds)
requestorConfig.maxRetryDurationMillis = requestorConfig.maxRetryDurationSeconds * 1000;
requestorConfig.logger = buildLogger(clientOptions);
return require('./lib/utils/httpRequestor.js')
.create(requestorConfig);
};
function buildLogger(clientOptions) {
if(hasMultipleLogOptions(clientOptions)) {
throw new Error(
"Smartsheet client options may specify at most one of " +
"'logger', 'loggerContainer', and 'logLevel'.");
}
if(clientOptions.logger) return clientOptions.logger;
if(clientOptions.logLevel) return buildLoggerFromLevel(clientOptions.logLevel);
if(clientOptions.loggerContainer) return buildLoggerFromContainer(clientOptions.loggerContainer);
return null;
}
function hasMultipleLogOptions(clientOptions) {
return (clientOptions.logger && clientOptions.loggerContainer)
|| (clientOptions.logger && clientOptions.logLevel)
|| (clientOptions.loggerContainer && clientOptions.logLevel);
}
function buildLoggerFromLevel(logLevel) {
if(winston.levels[logLevel] == null) {
throw new Error(
'Smartsheet client received configuration with invalid log level ' +
`'${logLevel}'. Use one of the standard Winston log levels.`);
}
return new (winston.Logger)({
transports: [
new winston.transports.Console({
level: logLevel,
showLevel: false,
label: 'Smartsheet'
})
]
});
}
function buildLoggerFromContainer(container) {
if(container.has('smartsheet'))
return container.get('smartsheet');
else
throw new Error(
"Smartsheet client received a logger container, but could not find a logger named " +
"'smartsheet' inside.");
}
exports.createClient = function(clientOptions) {
var requestor = buildRequestor(clientOptions);
var options = {
accessToken: options.accessToken,
apiUrls: apiUrls
accessToken: clientOptions.accessToken || process.env.SMARTSHEET_ACCESS_TOKEN,
apiUrls: apiUrls,
requestor: requestor
};
return {

@@ -15,2 +90,3 @@ constants : require('./lib/utils/constants.js'),

home : require('./lib/home/').create(options),
images : require('./lib/images/').create(options),
reports : require('./lib/reports/').create(options),

@@ -22,5 +98,7 @@ search : require('./lib/search/').create(options),

templates : require('./lib/templates/').create(options),
tokens : require('./lib/tokens/').create(options),
users : require('./lib/users/').create(options),
webhooks : require('./lib/webhooks/').create(options),
workspaces : require('./lib/workspaces/').create(options)
};
};

31

lib/contacts/index.js

@@ -1,23 +0,18 @@

var utils = require('../utils/httpUtils.js');
var _ = require('underscore');
var constants = require('../utils/constants.js');
exports.create = function(options) {
var optionsToSend = {
url: options.apiUrls.contacts,
accessToken : options.accessToken
};
var requestor = options.requestor;
var getContact = function(getOptions, callback) {
return utils.get(_.extend(optionsToSend, getOptions), callback);
};
var optionsToSend = {
url: options.apiUrls.contacts,
accessToken : options.accessToken
};
var buildContactObject = function() {
var contactObject = {
getContact : getContact,
listContacts : getContact
}
return contactObject;
}
return buildContactObject();
}
var getContact = (getOptions, callback) =>
requestor.get(_.extend({}, optionsToSend, getOptions), callback);
return {
getContact : getContact,
listContacts : getContact
};
};

@@ -1,6 +0,7 @@

var utils = require('../utils/httpUtils.js');
var _ = require('underscore');
var types = require('../utils/constants').types;
exports.create = function(options) {
exports.create = options => {
var requestor = options.requestor;
var optionsToSend = {

@@ -11,73 +12,56 @@ url: options.apiUrls.favorites,

var listFavorites = function(getOptions, callback) {
return utils.get(_.extend(optionsToSend, getOptions), callback);
};
var listFavorites = (getOptions, callback) =>
requestor.get(_.extend({}, optionsToSend, getOptions), callback);
var addItemsToFavorites = function(postOptions, callback) {
return utils.post(_.extend(optionsToSend, postOptions), callback);
};
var addItemsToFavorites = (postOptions, callback) =>
requestor.post(_.extend({}, optionsToSend, postOptions), callback);
var handleFavorites = function(postOptions, callback) {
var body = {
type : postOptions.type,
objectId: postOptions.objectId
};
var handleFavorites = (postOptions, callback) => {
var body = _.pick(postOptions, 'type', 'objectId');
return addItemsToFavorites({body: body}, callback);
};
var addSheetToFavorites = function(postOptions, callback) {
postOptions.type = types.sheet;
return handleFavorites(postOptions, callback);
var buildFavoriteAddition = function(type) {
return (postOptions, callback) => {
postOptions.type = type;
return handleFavorites(postOptions, callback);
};
};
var addFolderToFavorites = function(postOptions, callback) {
postOptions.type = types.folder;
return handleFavorites(postOptions, callback);
};
var addSheetToFavorites = buildFavoriteAddition(types.sheet);
var addReportToFavorites = function(postOptions, callback) {
postOptions.type = types.report;
return handleFavorites(postOptions, callback);
};
var addFolderToFavorites = buildFavoriteAddition(types.folder);
var addTemplateToFavorites = function(postOptions, callback) {
postOptions.type = types.template;
return handleFavorites(postOptions, callback);
};
var addReportToFavorites = buildFavoriteAddition(types.report);
var addWorkspaceToFavorites = function(postOptions, callback) {
postOptions.type = types.workspace;
return handleFavorites(postOptions, callback);
};
var addTemplateToFavorites = buildFavoriteAddition(types.template);
var removeFavorite = function(deleteOptions, callback) {
optionsToSend.url = optionsToSend.url + deleteOptions.type + '/' + (deleteOptions.id || deleteOptions.objectId || '');
return utils.delete(_.extend(optionsToSend, deleteOptions), callback);
};
var addWorkspaceToFavorites = buildFavoriteAddition(types.workspace);
var removeSheetFromFavorites = function(deleteOptions, callback) {
deleteOptions.type = types.sheet;
return removeFavorite(deleteOptions, callback);
};
var addSightToFavorites = buildFavoriteAddition(types.sight);
var removeFolderFromFavorites = function(deleteOptions, callback) {
deleteOptions.type = types.folder;
return removeFavorite(deleteOptions, callback);
var removeFavorite = (deleteOptions, callback) => {
var urlOptions = {url: options.apiUrls.favorites + deleteOptions.type + '/' + (deleteOptions.id || deleteOptions.objectId || '')};
return requestor.delete(_.extend({}, optionsToSend, urlOptions, deleteOptions), callback);
};
var removeReportFromFavorites = function(deleteOptions, callback) {
deleteOptions.type = types.report;
return removeFavorite(deleteOptions, callback);
var buildFavoriteRemoval = function(type) {
return (deleteOptions, callback) => {
deleteOptions.type = type;
return removeFavorite(deleteOptions, callback);
};
};
var removeTemplateFromFavorites = function(deleteOptions, callback) {
deleteOptions.type = types.template;
return removeFavorite(deleteOptions, callback);
};
var removeSheetFromFavorites = buildFavoriteRemoval(types.sheet);
var removeWorkspaceFromFavorites = function(deleteOptions, callback) {
deleteOptions.type = types.workspace;
return removeFavorite(deleteOptions, callback);
};
var removeFolderFromFavorites = buildFavoriteRemoval(types.folder);
var removeReportFromFavorites = buildFavoriteRemoval(types.report);
var removeTemplateFromFavorites = buildFavoriteRemoval(types.template);
var removeWorkspaceFromFavorites = buildFavoriteRemoval(types.workspace);
var removeSightFromFavorites = buildFavoriteRemoval(types.sight);
return {

@@ -87,5 +71,6 @@ listFavorites : listFavorites,

addSheetToFavorites : addSheetToFavorites,
addFolderToFavorites: addFolderToFavorites,
addReportToFavorites: addReportToFavorites,
addFolderToFavorites : addFolderToFavorites,
addReportToFavorites : addReportToFavorites,
addTemplateToFavorites : addTemplateToFavorites,
addSightToFavorites : addSightToFavorites,
addWorkspaceToFavorites : addWorkspaceToFavorites,

@@ -96,2 +81,3 @@ removeSheetFromFavorites : removeSheetFromFavorites,

removeTemplateFromFavorites : removeTemplateFromFavorites,
removeSightFromFavorites : removeSightFromFavorites,
removeWorkspaceFromFavorites : removeWorkspaceFromFavorites,

@@ -104,4 +90,5 @@ //convenience methods to remove multiples.

removeTemplatesFromFavorites : removeTemplateFromFavorites,
removeSightsFromFavorites : removeSightFromFavorites,
removeWorkspacesFromFavorites : removeWorkspaceFromFavorites
};
};

@@ -1,6 +0,6 @@

var utils = require('../utils/httpUtils.js');
var _ = require('underscore');
var constants = require('../utils/constants.js');
exports.create = function(options) {
var requestor = options.requestor;
var optionsToSend = {

@@ -12,22 +12,29 @@ url: options.apiUrls.folders,

var getFolder = function(getOptions, callback) {
return utils.get(_.extend(optionsToSend, getOptions), callback);
};
var getFolder = (getOptions, callback) =>
requestor.get(_.extend({}, optionsToSend, getOptions), callback);
var listChildFolders = function(getOptions, callback) {
optionsToSend.url = options.apiUrls.folders + getOptions.folderId + '/folders';
return utils.get(_.extend(optionsToSend, getOptions), callback);
var listChildFolders = (getOptions, callback) => {
var urlOptions = {url: options.apiUrls.folders + getOptions.folderId + '/folders'};
return requestor.get(_.extend({}, optionsToSend, urlOptions, getOptions), callback);
};
var createChildFolder = function(postOptions, callback) {
optionsToSend.url = options.apiUrls.folders + postOptions.folderId + '/folders';
return utils.post(_.extend(optionsToSend, postOptions), callback);
var createChildFolder = (postOptions, callback) => {
var urlOptions = {url: options.apiUrls.folders + postOptions.folderId + '/folders'};
return requestor.post(_.extend({}, optionsToSend, urlOptions, postOptions), callback);
};
var updateFolder = function(putOptions, callback) {
return utils.put(_.extend(optionsToSend, putOptions), callback);
var updateFolder = (putOptions, callback) =>
requestor.put(_.extend({}, optionsToSend, putOptions), callback);
var deleteFolder = (deleteOptions, callback) =>
requestor.delete(_.extend({}, optionsToSend, deleteOptions), callback);
var copyFolder = (postOptions, callback) => {
var urlOptions = {url: options.apiUrls.folders + postOptions.folderId + '/copy'};
return requestor.post(_.extend({}, optionsToSend, urlOptions, postOptions), callback);
};
var deleteFolder = function(deleteOptions, callback) {
return utils.delete(_.extend(optionsToSend, deleteOptions), callback);
var moveFolder = (postOptions, callback) => {
var urlOptions = {url: options.apiUrls.folders + postOptions.folderId + '/move'};
return requestor.post(_.extend({}, optionsToSend, urlOptions, postOptions), callback);
};

@@ -40,4 +47,6 @@

updateFolder : updateFolder,
deleteFolder : deleteFolder
deleteFolder : deleteFolder,
moveFolder : moveFolder,
copyFolder : copyFolder
};
};

@@ -1,6 +0,6 @@

var utils = require('../utils/httpUtils.js');
var _ = require('underscore');
var constants = require('../utils/constants.js');
exports.create = function(options) {
var requestor = options.requestor;
var optionsToSend = {

@@ -11,26 +11,22 @@ url: options.apiUrls.groups,

var listGroups = function(getOptions, callback) {
return utils.get(_.extend(optionsToSend, getOptions), callback);
};
var listGroups = (getOptions, callback) =>
requestor.get(_.extend({}, optionsToSend, getOptions), callback);
var createGroup = function(postOptions, callback) {
return utils.post(_.extend(optionsToSend, postOptions), callback);
};
var createGroup = (postOptions, callback) =>
requestor.post(_.extend({}, optionsToSend, postOptions), callback);
var addGroupMembers = function(postOptions, callback) {
optionsToSend.url = options.apiUrls.groups + postOptions.groupId + '/members/';
return utils.post(_.extend(optionsToSend, postOptions), callback);
var addGroupMembers = (postOptions, callback) => {
var urlOptions = {url: options.apiUrls.groups + postOptions.groupId + '/members/'};
return requestor.post(_.extend({}, optionsToSend, urlOptions, postOptions), callback);
};
var updateGroup = function(putOptions, callback) {
return utils.put(_.extend(optionsToSend, putOptions), callback);
};
var updateGroup = (putOptions, callback) =>
requestor.put(_.extend({}, optionsToSend, putOptions), callback);
var deleteGroup = function(deleteOptions, callback) {
return utils.delete(_.extend(optionsToSend, deleteOptions), callback);
};
var deleteGroup = (deleteOptions, callback) =>
requestor.delete(_.extend({}, optionsToSend, deleteOptions), callback);
var removeGroupMember = function(deleteOptions, callback) {
optionsToSend.url = options.apiUrls.groups + deleteOptions.groupId + '/members/' + deleteOptions.userId;
return utils.delete(_.extend(optionsToSend, deleteOptions), callback);
var removeGroupMember = (deleteOptions, callback) => {
var urlOptions = {url: options.apiUrls.groups + deleteOptions.groupId + '/members/' + deleteOptions.userId};
return requestor.delete(_.extend({}, optionsToSend, urlOptions, deleteOptions), callback);
};

@@ -37,0 +33,0 @@

@@ -1,21 +0,20 @@

var utils = require('../utils/httpUtils.js');
var _ = require('underscore');
exports.create = function(options) {
var requestor = options.requestor;
var optionsToSend = {
url: options.apiUrls.home,
accessToken : options.accessToken
accessToken : options.accessToken,
};
var listContents = function(getOptions, callback) {
return utils.get(_.extend(optionsToSend, getOptions), callback);
};
var listContents = (getOptions, callback) =>
requestor.get(_.extend({}, optionsToSend, getOptions), callback);
var listFolders = function(getOptions, callback) {
return listContents(_.extend({url: options.apiUrls.home + 'folders'}, getOptions), callback);
};
var listFolders = (getOptions, callback) =>
listContents(_.extend({url: options.apiUrls.home + 'folders'}, getOptions), callback);
var createFolder = function(postOptions, callback) {
optionsToSend.url = options.apiUrls.home + 'folders';
return utils.post(_.extend(optionsToSend, postOptions), callback);
var createFolder = (postOptions, callback) => {
var urlOptions = {url: options.apiUrls.home + 'folders'};
return requestor.post(_.extend({}, optionsToSend, urlOptions, postOptions), callback);
};

@@ -22,0 +21,0 @@

@@ -1,2 +0,1 @@

var utils = require('../utils/httpUtils.js');
var _ = require('underscore');

@@ -7,2 +6,3 @@ var constants = require('../utils/constants.js');

var shares = require('../share/share.js')(options.apiUrls.reports);
var requestor = options.requestor;

@@ -14,35 +14,41 @@ var optionsToSend = {

var getReport = function(getOptions, callback) {
return utils.get(_.extend(optionsToSend, getOptions), callback);
var getReport = (getOptions, callback) =>
requestor.get(_.extend({}, optionsToSend, getOptions), callback);
var sendReportViaEmail = (postOptions, callback) => {
var urlOptions = {url: options.apiUrls.reports + postOptions.reportId + '/emails'};
return requestor.post(_.extend({}, optionsToSend, urlOptions, postOptions), callback);
};
var sendReportViaEmail = function(postOptions, callback) {
optionsToSend.url = options.apiUrls.reports + postOptions.reportId + '/emails';
return utils.post(_.extend(optionsToSend, postOptions), callback);
var getReportAsExcel = (getOptions, callback) => {
var acceptOptions = {accept: constants.acceptHeaders.vndMsExcel};
return requestor.get(_.extend({}, optionsToSend, acceptOptions, getOptions), callback);
};
var getReportAsExcel = function(getOptions, callback) {
optionsToSend.accept = 'application/vnd.ms-excel';
return utils.get(_.extend(optionsToSend, getOptions), callback);
var getReportAsCSV = (getOptions, callback) => {
var acceptOptions = {accept: constants.acceptHeaders.textCsv};
return requestor.get(_.extend({}, optionsToSend, acceptOptions, getOptions), callback);
};
var getReportPublishStatus = (getOptions, callback) => {
var urlOptions = {url: options.apiUrls.reports + getOptions.reportId + '/publish'};
return requestor.get(_.extend({}, optionsToSend, urlOptions, getOptions), callback);
};
var getReportAsCSV = function(getOptions, callback) {
optionsToSend.accept = 'text/csv';
return utils.get(_.extend(optionsToSend, getOptions), callback);
var setReportPublishStatus = (putOptions, callback) => {
var urlOptions = {url: options.apiUrls.reports + putOptions.reportId + '/publish'};
return requestor.put(_.extend({}, optionsToSend, urlOptions, putOptions), callback);
};
var buildReportObject = function() {
var reportObject = {
listReports : getReport,
getReport : getReport,
sendReportViaEmail : sendReportViaEmail,
getReportAsExcel : getReportAsExcel,
getReportAsCSV : getReportAsCSV
};
var reportObject = {
listReports : getReport,
getReport : getReport,
sendReportViaEmail : sendReportViaEmail,
getReportAsExcel : getReportAsExcel,
getReportAsCSV : getReportAsCSV,
getReportPublishStatus : getReportPublishStatus,
setReportPublishStatus : setReportPublishStatus
};
reportObject = _.extend(reportObject, shares.create(options));
return reportObject;
};
return buildReportObject();
return _.extend(reportObject, shares.create(options));
};

@@ -1,5 +0,6 @@

var utils = require('../utils/httpUtils.js');
var _ = require('underscore');
exports.create = function(options) {
var requestor = options.requestor;
var optionsToSend = {

@@ -11,11 +12,10 @@ url: options.apiUrls.search,

var searchAll = function(getOptions, callback) {
optionsToSend.queryParameters = getOptions;
return utils.get(_.extend(optionsToSend, getOptions), callback);
var searchAll = (getOptions, callback) => {
var queryParameters = {query: getOptions.query};
return requestor.get(_.extend({queryParameters: queryParameters}, optionsToSend, getOptions), callback);
};
var searchSheet = function(getOptions, callback) {
optionsToSend.url = options.apiUrls.search + 'sheets/' + getOptions.sheetId;
optionsToSend.queryParameters = getOptions.queryParameters;
return utils.get(_.extend(optionsToSend, getOptions), callback);
var searchSheet = (getOptions, callback) => {
var urlOptions = {url: options.apiUrls.search + 'sheets/' + getOptions.sheetId};
return requestor.get(_.extend({}, optionsToSend, urlOptions, getOptions), callback);
};

@@ -22,0 +22,0 @@

@@ -1,3 +0,1 @@

var utils = require('../utils/httpUtils.js');
exports.create = function(options) {

@@ -10,5 +8,4 @@ var optionsToSend = {

var getInfo = function(getOptions, callback) {
return utils.get(optionsToSend, callback);
};
var getInfo = (getOptions, callback) =>
options.requestor.get(optionsToSend, callback);

@@ -15,0 +12,0 @@ return {

@@ -1,49 +0,45 @@

var utils = require('../utils/httpUtils.js');
var _ = require('underscore');
var constants = require('../utils/constants.js');
module.exports = url => ({
create: function(options) {
var requestor = options.requestor;
module.exports = function(url) {
return {
create : function(options) {
var optionsToSend = {
accessToken: options.accessToken
};
var optionsToSend = {
accessToken: options.accessToken
};
var listShares = function (getOptions, callback) {
optionsToSend.url = buildUrl(getOptions);
return utils.get(_.extend(optionsToSend, getOptions), callback);
};
var listShares = (getOptions, callback) => {
var urlOptions = {url: buildUrl(getOptions)};
return requestor.get(_.extend({}, optionsToSend, urlOptions, getOptions), callback);
};
var share = function (postOptions, callback) {
optionsToSend.url = buildUrl(postOptions);
return utils.post(_.extend(optionsToSend, postOptions), callback);
};
var share = (postOptions, callback) => {
var urlOptions = {url: buildUrl(postOptions)};
return requestor.post(_.extend({}, optionsToSend, urlOptions, postOptions), callback);
};
var deleteShare = function (deleteOptions, callback) {
optionsToSend.url = buildUrl(deleteOptions);
return utils.delete(_.extend(optionsToSend, deleteOptions), callback);
};
var deleteShare = (deleteOptions, callback) => {
var urlOptions = {url: buildUrl(deleteOptions)};
return requestor.delete(_.extend({}, optionsToSend, urlOptions, deleteOptions), callback);
};
var updateShare = function (putOptions, callback) {
optionsToSend.url = buildUrl(putOptions);
return utils.put(_.extend(optionsToSend, putOptions), callback);
};
var updateShare = (putOptions, callback) => {
var urlOptions = {url: buildUrl(putOptions)};
return requestor.put(_.extend({}, optionsToSend, urlOptions, putOptions), callback);
};
var buildUrl = function (urlOptions) {
return url + (urlOptions.sheetId || urlOptions.workspaceId || urlOptions.reportId || urlOptions.sightId) + '/shares/' + (urlOptions.shareId || '');
};
var buildUrl = urlOptions =>
url + (urlOptions.sheetId || urlOptions.workspaceId || urlOptions.reportId || urlOptions.sightId) + '/shares/' + (urlOptions.shareId || '');
return {
getShare: listShares,
listShares: listShares,
share: share,
deleteShare: deleteShare,
updateShare: updateShare
};
}
};
};
return {
getShare: listShares,
listShares: listShares,
share: share,
deleteShare: deleteShare,
updateShare: updateShare
};
}
});

@@ -1,6 +0,6 @@

var utils = require('../utils/httpUtils.js');
var _ = require('underscore');
var constants = require('../utils/constants.js');
exports.create = function(options) {
var requestor = options.requestor;
var optionsToSend = {

@@ -10,36 +10,40 @@ accessToken : options.accessToken

var listAttachments = function(getOptions, callback) {
optionsToSend.url = buildUrl(getOptions);
return utils.get(_.extend(optionsToSend, getOptions), callback);
var listAttachments = (getOptions, callback) => {
var urlOptions = {url: buildUrl(getOptions)};
return requestor.get(_.extend({}, optionsToSend, urlOptions, getOptions), callback);
};
var listAttachmentVersions = function(getOptions, callback) {
optionsToSend.url = buildUrl(getOptions) + '/versions';
return utils.get(_.extend(optionsToSend, getOptions), callback);
var listAttachmentVersions = (getOptions, callback) => {
var urlOptions = {url: buildUrl(getOptions) + '/versions'};
return requestor.get(_.extend({}, optionsToSend, urlOptions, getOptions), callback);
};
var addAttachment = function(postOptions, callback) {
optionsToSend.url = buildUrl(postOptions);
return utils.post(_.extend(optionsToSend, postOptions), callback);
var addUrlAttachment = (postOptions, callback) => {
var urlOptions = {url: buildUrl(postOptions)};
return requestor.post(_.extend({}, optionsToSend, urlOptions, postOptions), callback);
};
var attachNewVersion = function(postOptions, callback) {
optionsToSend.url = buildUrl(postOptions) + '/versions';
return utils.post(_.extend(optionsToSend, postOptions), callback);
var addFileAttachment = (postOptions, callback) => {
var urlOptions = {url: buildUrl(postOptions)};
return requestor.postFile(_.extend({}, optionsToSend, urlOptions, postOptions), callback);
};
var deleteAttachment = function(deleteOptions, callback) {
optionsToSend.url = buildUrl(deleteOptions);
return utils.delete(_.extend(optionsToSend, deleteOptions), callback);
var attachNewVersion = (postOptions, callback) => {
var urlOptions = {url: buildUrl(postOptions) + '/versions'};
return requestor.postFile(_.extend({}, optionsToSend, urlOptions, postOptions), callback);
};
var deleteAllAttachmentVersions = function(deleteOptions, callback) {
optionsToSend.url = buildUrl(deleteOptions) + '/versions';
return utils.delete(_.extend(optionsToSend, deleteOptions), callback);
var deleteAttachment = (deleteOptions, callback) => {
var urlOptions = {url: buildUrl(deleteOptions)};
return requestor.delete(_.extend({}, optionsToSend, urlOptions, deleteOptions), callback);
};
var buildUrl = function(urlOptions) {
return options.apiUrls.sheets + urlOptions.sheetId + '/attachments/' + (urlOptions.attachmentId || '');
var deleteAllAttachmentVersions = (deleteOptions, callback) => {
var urlOptions = {url: buildUrl(deleteOptions) + '/versions'};
return requestor.delete(_.extend({}, optionsToSend, urlOptions, deleteOptions), callback);
};
var buildUrl = urlOptions =>
options.apiUrls.sheets + urlOptions.sheetId + '/attachments/' + (urlOptions.attachmentId || '');
return {

@@ -49,8 +53,8 @@ getAttachment : listAttachments,

listAttachmentVersions : listAttachmentVersions,
addAttachment : addAttachment,
addUrlAttachment : addUrlAttachment,
addFileAttachment : addFileAttachment,
attachNewVersion : attachNewVersion,
deleteAttachment : deleteAttachment,
deleteAllAttachmentVersions : deleteAllAttachmentVersions
};
};

@@ -1,6 +0,6 @@

var utils = require('../utils/httpUtils.js');
var _ = require('underscore');
var constants = require('../utils/constants.js');
exports.create = function(options) {
var requestor = options.requestor;
var optionsToSend = {

@@ -10,25 +10,24 @@ accessToken : options.accessToken

var getColumns = function(getOptions, callback) {
optionsToSend.url = buildUrl(getOptions);
return utils.get(_.extend(optionsToSend, getOptions), callback);
var getColumns = (getOptions, callback) => {
var urlOptions = {url: buildUrl(getOptions)};
return requestor.get(_.extend({}, optionsToSend, urlOptions, getOptions), callback);
};
var addColumn = function(postOptions, callback) {
optionsToSend.url = buildUrl(postOptions);
return utils.post(_.extend(optionsToSend, postOptions), callback);
var addColumn = (postOptions, callback) => {
var urlOptions = {url: buildUrl(postOptions)};
return requestor.post(_.extend({}, optionsToSend, urlOptions, postOptions), callback);
};
var updateColumn = function(putOptions, callback) {
optionsToSend.url = buildUrl(putOptions);
return utils.put(_.extend(optionsToSend, putOptions), callback);
var updateColumn = (putOptions, callback) => {
var urlOptions = {url: buildUrl(putOptions)};
return requestor.put(_.extend({}, optionsToSend, urlOptions, putOptions), callback);
};
var deleteColumn = function(deleteOptions, callback) {
optionsToSend.url = buildUrl(deleteOptions);
return utils.delete(_.extend(optionsToSend, deleteOptions), callback);
var deleteColumn = (deleteOptions, callback) => {
var urlOptions = {url: buildUrl(deleteOptions)};
return requestor.delete(_.extend({}, optionsToSend, urlOptions, deleteOptions), callback);
};
var buildUrl = function(urlOptions) {
return options.apiUrls.sheets + urlOptions.sheetId + '/columns/' + (urlOptions.columnId || '');
};
var buildUrl = urlOptions =>
options.apiUrls.sheets + urlOptions.sheetId + '/columns/' + (urlOptions.columnId || '');

@@ -35,0 +34,0 @@ return {

@@ -1,6 +0,6 @@

var utils = require('../utils/httpUtils.js');
var _ = require('underscore');
var constants = require('../utils/constants.js');
exports.create = function(options) {
var requestor = options.requestor;
var optionsToSend = {

@@ -10,26 +10,37 @@ accessToken : options.accessToken

var getComment = function(getOptions, callback) {
optionsToSend.url = buildUrl(getOptions);
return utils.get(_.extend(optionsToSend, getOptions), callback);
var getComment = (getOptions, callback) => {
var urlOptions = {url: buildUrl(getOptions)};
return requestor.get(_.extend({}, optionsToSend, urlOptions, getOptions), callback);
};
var deleteComment = function(getOptions, callback) {
optionsToSend.url = buildUrl(getOptions);
return utils.delete(_.extend(optionsToSend, getOptions), callback);
var deleteComment = (deleteOptions, callback) => {
var urlOptions = {url: buildUrl(deleteOptions)};
return requestor.delete(_.extend({}, optionsToSend, urlOptions, deleteOptions), callback);
};
var addCommentAttachment = function(getOptions, callback) {
optionsToSend.url = buildUrl(getOptions) + '/attachments';
return utils.post(_.extend(optionsToSend, getOptions), callback);
var addCommentUrlAttachment = (postOptions, callback) => {
var urlOptions = {url: buildUrl(postOptions) + '/attachments'};
return requestor.post(_.extend({}, optionsToSend, urlOptions, postOptions), callback);
};
var addCommentFileAttachment = (postOptions, callback) => {
var urlOptions = {url: buildUrl(postOptions) + '/attachments'};
return requestor.postFile(_.extend({}, optionsToSend, urlOptions, postOptions), callback);
};
var buildUrl = function(urlOptions) {
return options.apiUrls.sheets + urlOptions.sheetId + '/comments/' + (urlOptions.commentId || '');
var editComment = (putOptions, callback) => {
var urlOptions = {url: buildUrl(putOptions)};
return requestor.put(_.extend({}, optionsToSend, urlOptions, putOptions), callback);
};
var buildUrl = urlOptions =>
options.apiUrls.sheets + urlOptions.sheetId + '/comments/' + (urlOptions.commentId || '');
return {
getComment : getComment,
deleteComment : deleteComment,
addCommentAttachment : addCommentAttachment
addCommentUrlAttachment : addCommentUrlAttachment,
addCommentFileAttachment : addCommentFileAttachment,
editComment : editComment
};
};

@@ -1,5 +0,6 @@

var utils = require('../utils/httpUtils.js');
var _ = require('underscore');
exports.create = function(options) {
var requestor = options.requestor;
var optionsToSend = {

@@ -10,7 +11,6 @@ url: options.apiUrls.sheets,

var createSheet = function(postOptions, callback) {
return utils.post(_.extend(optionsToSend, postOptions), callback);
};
var createSheet = (postOptions, callback) =>
requestor.post(_.extend({}, optionsToSend, postOptions), callback);
var createSheetFromExisting = function(postOptions, callback) {
var createSheetFromExisting = (postOptions, callback) => {
if (postOptions.workspaceId) {

@@ -25,20 +25,17 @@ return createSheetInWorkspace(postOptions, callback);

var createSheetInFolderFromExisting = function(postOptions, callback) {
return createSheetInFolder(postOptions, callback);
var createSheetInFolder = (postOptions, callback) => {
var urlOptions = {url: options.apiUrls.folders + postOptions.folderId + '/sheets'};
return requestor.post(_.extend({}, optionsToSend, urlOptions, postOptions), callback);
};
var createSheetInFolder = function(postOptions, callback) {
optionsToSend.url = options.apiUrls.folders + postOptions.folderId + '/sheets';
return utils.post(_.extend(optionsToSend, postOptions), callback);
var createSheetInWorkspace = (postOptions, callback) => {
var urlOptions = {url: options.apiUrls.workspaces + postOptions.workspaceId + '/sheets'};
return requestor.post(_.extend({}, optionsToSend, urlOptions, postOptions), callback);
};
var createSheetInWorkspace = function(postOptions, callback) {
optionsToSend.url = options.apiUrls.workspaces + postOptions.workspaceId + '/sheets';
return utils.post(_.extend(optionsToSend, postOptions), callback);
var copySheet = (postOptions, callback) => {
var urlOptions = {url: options.apiUrls.sheets + postOptions.sheetId + '/copy'};
return requestor.post(_.extend({}, optionsToSend, urlOptions, postOptions), callback);
};
var createSheetInWorkspaceFromExisting = function(postOptions, callback) {
return createSheetInWorkspace(postOptions, callback);
};
return {

@@ -48,4 +45,5 @@ createSheet : createSheet,

createSheetInFolder : createSheetInFolder,
createSheetInWorkspace : createSheetInWorkspace
createSheetInWorkspace : createSheetInWorkspace,
copySheet : copySheet
};
};

@@ -1,6 +0,6 @@

var utils = require('../utils/httpUtils.js');
var _ = require('underscore');
var constants = require('../utils/constants.js');
exports.create = function(options) {
var requestor = options.requestor;
var optionsToSend = {

@@ -10,30 +10,29 @@ accessToken : options.accessToken

var getDiscussions = function(getOptions, callback) {
optionsToSend.url = buildUrl(getOptions);
return utils.get(_.extend(optionsToSend, getOptions), callback);
var getDiscussions = (getOptions, callback) => {
var urlOptions = {url: buildUrl(getOptions)};
return requestor.get(_.extend({}, optionsToSend, urlOptions, getOptions), callback);
};
var listDiscussionAttachments = function(getOptions, callback) {
optionsToSend.url = buildUrl(getOptions) + '/attachments';
return utils.get(_.extend(optionsToSend, getOptions), callback);
var listDiscussionAttachments = (getOptions, callback) => {
var urlOptions = {url: buildUrl(getOptions) + '/attachments'};
return requestor.get(_.extend({}, optionsToSend, urlOptions, getOptions), callback);
};
var createDiscussion = function(postOptions, callback) {
optionsToSend.url = buildUrl(postOptions);
return utils.post(_.extend(optionsToSend, postOptions), callback);
var createDiscussion = (postOptions, callback) => {
var urlOptions = {url: buildUrl(postOptions)};
return requestor.post(_.extend({}, optionsToSend, urlOptions, postOptions), callback);
};
var addDiscussionComment = function(postOptions, callback) {
optionsToSend.url = buildUrl(postOptions) + '/comments';
return utils.post(_.extend(optionsToSend, postOptions), callback);
var addDiscussionComment = (postOptions, callback) => {
var urlOptions = {url: buildUrl(postOptions) + '/comments'};
return requestor.post(_.extend({}, optionsToSend, urlOptions, postOptions), callback);
};
var deleteDiscussion = function(deleteOptions, callback) {
optionsToSend.url = buildUrl(deleteOptions);
return utils.delete(_.extend(optionsToSend, deleteOptions), callback);
var deleteDiscussion = (deleteOptions, callback) => {
var urlOptions = {url: buildUrl(deleteOptions)};
return requestor.delete(_.extend({}, optionsToSend, urlOptions, deleteOptions), callback);
};
var buildUrl = function(urlOptions) {
return options.apiUrls.sheets + urlOptions.sheetId + '/discussions/' + (urlOptions.discussionId || '');
};
var buildUrl = (urlOptions) =>
options.apiUrls.sheets + urlOptions.sheetId + '/discussions/' + (urlOptions.discussionId || '');

@@ -40,0 +39,0 @@ return {

@@ -1,2 +0,1 @@

var utils = require('../utils/httpUtils.js');
var _ = require('underscore');

@@ -6,2 +5,4 @@ var headers = require('../utils/constants.js').acceptHeaders;

exports.create = function(options) {
var requestor = options.requestor;
var optionsToSend = {

@@ -12,27 +13,22 @@ url: options.apiUrls.sheets,

var listSheets = function(getOptions, callback) {
return utils.get(_.extend({}, optionsToSend, getOptions), callback);
};
var listSheets = (getOptions, callback) =>
requestor.get(_.extend({}, optionsToSend, getOptions), callback);
var getSheetAsCSV = function(getOptions, callback) {
return listSheets(_.extend(getOptions, {accept:headers.textCsv}), callback);
};
var getSheetAsCSV = (getOptions, callback) =>
listSheets(_.extend({}, getOptions, {accept:headers.textCsv}), callback);
var getSheetAsPDF = function(getOptions, callback) {
return listSheets(_.extend(getOptions, {accept:headers.applicationPdf}), callback);
};
var getSheetAsPDF = (getOptions, callback) =>
listSheets(_.extend({}, getOptions, {accept:headers.applicationPdf}), callback);
var getSheetAsExcel = function(getOptions, callback) {
return listSheets(_.extend(getOptions, {accept:headers.vndMsExcel}), callback);
};
var getSheetAsExcel = (getOptions, callback) =>
listSheets(_.extend({}, getOptions, {accept:headers.vndMsExcel}), callback);
var getSheetVersion = function(getOptions, callback) {
getOptions.url = options.apiUrls.sheets + getOptions.sheetId + '/version';
return listSheets(_.extend({}, optionsToSend, getOptions), callback);
var getSheetVersion = (getOptions, callback) => {
var urlOptions = {url: options.apiUrls.sheets + getOptions.sheetId + '/version'};
return listSheets(_.extend({}, optionsToSend, urlOptions, getOptions), callback);
};
var listOrganizationSheets = function(getOptions, callback) {
getOptions = getOptions || {};
getOptions.url = options.apiUrls.users + 'sheets';
return utils.get(_.extend({}, optionsToSend, getOptions), callback);
var listOrganizationSheets = (getOptions, callback) => {
var urlOptions = {url: options.apiUrls.users + 'sheets'};
return requestor.get(_.extend({}, optionsToSend, urlOptions, getOptions), callback);
};

@@ -39,0 +35,0 @@

@@ -1,2 +0,1 @@

var utils = require('../utils/httpUtils.js');
var _ = require('underscore');

@@ -10,8 +9,10 @@ var attachments = require('./attachments.js');

var rows = require('./rows.js');
var sentUpdateRequests = require('./sentupdaterequests.js');
var updateRequests = require('./updaterequests.js');
exports.create = function(options) {
var requestor = options.requestor;
var shares = require('../share/share.js')(options.apiUrls.sheets);
var optionsToSend = {
//url: ,
urls : options.apiUrls,

@@ -21,48 +22,53 @@ accessToken : options.accessToken

var updateSheet = function(putOptions, callback) {
optionsToSend.url = options.apiUrls.sheets;
return utils.put(_.extend(optionsToSend, putOptions), callback);
var updateSheet = (putOptions, callback) => {
var urlOptions = {url: options.apiUrls.sheets};
return requestor.put(_.extend({}, optionsToSend, urlOptions, putOptions), callback);
};
var deleteSheet = function(deleteOptions, callback) {
optionsToSend.url = options.apiUrls.sheets;
return utils.delete(_.extend(optionsToSend, deleteOptions), callback);
var deleteSheet = (deleteOptions, callback) => {
var urlOptions = {url: options.apiUrls.sheets};
return requestor.delete(_.extend({}, optionsToSend, urlOptions, deleteOptions), callback);
};
var sendSheetViaEmail = function(postOptions, callback) {
optionsToSend.url = options.apiUrls.sheets + postOptions.sheetId + '/emails';
return utils.post(_.extend(optionsToSend, postOptions), callback);
var sendSheetViaEmail = (postOptions, callback) => {
var urlOptions = {url: options.apiUrls.sheets + postOptions.sheetId + '/emails'};
return requestor.post(_.extend({}, optionsToSend, urlOptions, postOptions), callback);
};
var getPublishStatus = function(getOptions, callback) {
optionsToSend.url = options.apiUrls.sheets + getOptions.sheetId + '/publish';
return utils.get(_.extend(optionsToSend, getOptions), callback);
var moveSheet = (postOptions, callback) => {
var urlOptions = {url: options.apiUrls.sheets + postOptions.sheetId + '/move'};
return requestor.post(_.extend({}, optionsToSend, urlOptions, postOptions), callback);
};
var setPublishStatus = function(putOptions, callback) {
optionsToSend.url = options.apiUrls.sheets + putOptions.sheetId + '/publish';
return utils.put(_.extend(optionsToSend, putOptions), callback);
var getPublishStatus = (getOptions, callback) => {
var urlOptions = {url: options.apiUrls.sheets + getOptions.sheetId + '/publish'};
return requestor.get(_.extend({}, optionsToSend, urlOptions, getOptions), callback);
};
var buildSheetObject = function() {
var sheetObject = {
sendSheetViaEmail : sendSheetViaEmail,
getPublishStatus : getPublishStatus,
setPublishStatus : setPublishStatus,
updateSheet : updateSheet,
deleteSheet : deleteSheet
};
var setPublishStatus = (putOptions, callback) => {
var urlOptions = {url: options.apiUrls.sheets + putOptions.sheetId + '/publish'};
return requestor.put(_.extend({}, optionsToSend, urlOptions, putOptions), callback);
};
sheetObject = _.extend(sheetObject, attachments.create(options));
sheetObject = _.extend(sheetObject, columns.create(options));
sheetObject = _.extend(sheetObject, comments.create(options));
sheetObject = _.extend(sheetObject, createSheets.create(options));
sheetObject = _.extend(sheetObject, discussions.create(options));
sheetObject = _.extend(sheetObject, getSheets.create(options));
sheetObject = _.extend(sheetObject, rows.create(options));
sheetObject = _.extend(sheetObject, shares.create(options));
return sheetObject;
var sheetObject = {
sendSheetViaEmail : sendSheetViaEmail,
getPublishStatus : getPublishStatus,
setPublishStatus : setPublishStatus,
updateSheet : updateSheet,
deleteSheet : deleteSheet,
moveSheet : moveSheet
};
return buildSheetObject();
_.extend(sheetObject, attachments.create(options));
_.extend(sheetObject, columns.create(options));
_.extend(sheetObject, comments.create(options));
_.extend(sheetObject, createSheets.create(options));
_.extend(sheetObject, discussions.create(options));
_.extend(sheetObject, getSheets.create(options));
_.extend(sheetObject, rows.create(options));
_.extend(sheetObject, sentUpdateRequests.create(options));
_.extend(sheetObject, shares.create(options));
_.extend(sheetObject, updateRequests.create(options));
return sheetObject;
};

@@ -1,6 +0,6 @@

var utils = require('../utils/httpUtils.js');
var _ = require('underscore');
var constants = require('../utils/constants.js');
exports.create = function(options) {
var requestor = options.requestor;
var optionsToSend = {

@@ -10,66 +10,75 @@ accessToken : options.accessToken

var getRow = function(getOptions, callback) {
optionsToSend.url = buildUrl(getOptions);
return utils.get(_.extend(optionsToSend, getOptions), callback);
var getRow = (getOptions, callback) => {
var urlOptions = {url: buildUrl(getOptions)};
return requestor.get(_.extend({}, optionsToSend, urlOptions, getOptions), callback);
};
var getRowAttachments = function(getOptions, callback) {
optionsToSend.url = buildUrl(getOptions) + '/attachments';
return utils.get(_.extend(optionsToSend, getOptions), callback);
var getRowAttachments = (getOptions, callback) => {
var urlOptions = {url: buildUrl(getOptions) + '/attachments'};
return requestor.get(_.extend({}, optionsToSend, urlOptions, getOptions), callback);
};
var getRowDiscussions = function(getOptions, callback) {
optionsToSend.url = buildUrl(getOptions) + '/discussions';
return utils.get(_.extend(optionsToSend, getOptions), callback);
var getRowDiscussions = (getOptions, callback) => {
var urlOptions = {url: buildUrl(getOptions) + '/discussions'};
return requestor.get(_.extend({}, optionsToSend, urlOptions, getOptions), callback);
};
var getCellHistory = function(getOptions, callback) {
optionsToSend.url = buildUrl(getOptions) + '/columns/' + getOptions.columnId + '/history';
return utils.get(_.extend(optionsToSend, getOptions), callback);
var getCellHistory = (getOptions, callback) => {
var urlOptions = {url: buildUrl(getOptions) + '/columns/' + getOptions.columnId + '/history'};
return requestor.get(_.extend({}, optionsToSend, urlOptions, getOptions), callback);
};
var copyRowToAnotherSheet = function(postOptions, callback) {
optionsToSend.url = buildUrl(postOptions) + 'copy';
return utils.post(_.extend(optionsToSend, postOptions), callback);
var copyRowToAnotherSheet = (postOptions, callback) => {
var urlOptions = {url: buildUrl(postOptions) + '/copy'};
return requestor.post(_.extend({}, optionsToSend, urlOptions, postOptions), callback);
};
var moveRowToAnotherSheet = function(postOptions, callback) {
optionsToSend.url = buildUrl(postOptions) + 'move';
return utils.post(_.extend(optionsToSend, postOptions), callback);
var moveRowToAnotherSheet = (postOptions, callback) => {
var urlOptions = {url: buildUrl(postOptions) + '/move'};
return requestor.post(_.extend({}, optionsToSend, urlOptions, postOptions), callback);
};
var addRow = function(postOptions, callback) {
optionsToSend.url = buildUrl(postOptions);
return utils.post(_.extend(optionsToSend, postOptions), callback);
var addRow = (postOptions, callback) => {
var urlOptions = {url: buildUrl(postOptions)};
return requestor.post(_.extend({}, optionsToSend, urlOptions, postOptions), callback);
};
var addRowAttachment = function(postOptions, callback) {
optionsToSend.url = buildUrl(postOptions) + '/attachments';
return utils.post(_.extend(optionsToSend, postOptions), callback);
var addRowUrlAttachment = (postOptions, callback) => {
var urlOptions = {url: buildUrl(postOptions) + '/attachments'};
return requestor.post(_.extend({}, optionsToSend, urlOptions, postOptions), callback);
};
var addRowFileAttachment = (postOptions, callback) => {
var urlOptions = {url: buildUrl(postOptions) + '/attachments'};
return requestor.postFile(_.extend({}, optionsToSend, urlOptions, postOptions), callback);
};
var createRowDiscussion = function(postOptions, callback) {
optionsToSend.url = buildUrl(postOptions) + '/discussions';
return utils.post(_.extend(optionsToSend, postOptions), callback);
var createRowDiscussion = (postOptions, callback) => {
var urlOptions = {url: buildUrl(postOptions) + '/discussions'};
return requestor.post(_.extend({}, optionsToSend, urlOptions, postOptions), callback);
};
var sendRow = function(postOptions, callback) {
optionsToSend.url = buildUrl(postOptions) + '/emails';
return utils.post(_.extend(optionsToSend, postOptions), callback);
var sendRow = (postOptions, callback) => {
var urlOptions = {url: buildUrl(postOptions) + '/emails'};
return requestor.post(_.extend({}, optionsToSend, urlOptions, postOptions), callback);
};
var updateRow = function(putOptions, callback) {
optionsToSend.url = buildUrl(putOptions);
return utils.put(_.extend(optionsToSend, putOptions), callback);
var updateRow = (putOptions, callback) => {
var urlOptions = {url: buildUrl(putOptions)};
return requestor.put(_.extend({}, optionsToSend, urlOptions, putOptions), callback);
};
var deleteRow = function(deleteOptions, callback) {
optionsToSend.url = options.apiUrls.sheets + deleteOptions.sheetId + '/rows?ids=' + (deleteOptions.rowId || '');
return utils.delete(_.extend(optionsToSend, deleteOptions), callback);
var deleteRow = (deleteOptions, callback) => {
var urlOptions = {url: options.apiUrls.sheets + deleteOptions.sheetId + '/rows?ids=' + (deleteOptions.rowId || '')};
return requestor.delete(_.extend({}, optionsToSend, urlOptions, deleteOptions), callback);
};
var buildUrl = function(urlOptions) {
return options.apiUrls.sheets + urlOptions.sheetId + '/rows/' + (urlOptions.rowId || '');
var addImageToCell = (postOptions, callback) => {
var urlOptions = {url: buildUrl(postOptions) + '/columns/' + postOptions.columnId + '/cellimages'};
return requestor.postFile(_.extend({}, optionsToSend, urlOptions, postOptions), callback);
};
var buildUrl = urlOptions =>
options.apiUrls.sheets + urlOptions.sheetId + '/rows/' + (urlOptions.rowId || '');
return {

@@ -84,8 +93,10 @@ getRow : getRow,

addRows : addRow,
addRowAttachment : addRowAttachment,
addRowUrlAttachment : addRowUrlAttachment,
addRowFileAttachment : addRowFileAttachment,
createRowDiscussion : createRowDiscussion,
sendRow : sendRow,
deleteRow : deleteRow,
updateRow : updateRow
updateRow : updateRow,
addImageToCell : addImageToCell
};
};

@@ -1,34 +0,63 @@

var utils = require('../utils/httpUtils.js');
var _ = require('underscore');
var constants = require('../utils/constants.js');
exports.create = function(options) {
var requestor = options.requestor;
var shares = require('../share/share.js')(options.apiUrls.sights);
var optionsToSend = {
url: options.apiUrls.sights,
accessToken : options.accessToken
};
var getSight = function(getOptions, callback) {
return utils.get(_.extend(optionsToSend, getOptions), callback);
var getSight = (getOptions, callback) => {
var urlOptions = {url: buildUrl(getOptions)};
return requestor.get(_.extend({}, optionsToSend, urlOptions, getOptions), callback);
};
var deleteSight = function(deleteOptions, callback) {
optionsToSend.url = options.apiUrls.sights;
return utils.delete(_.extend(optionsToSend, deleteOptions), callback);
var deleteSight = (deleteOptions, callback) => {
var urlOptions = {url: buildUrl(deleteOptions)};
return requestor.delete(_.extend({}, optionsToSend, urlOptions, deleteOptions), callback);
};
var buildSightObject = function() {
var sightObject = {
listSights : getSight,
getSight : getSight,
deleteSight : deleteSight
};
sightObject = _.extend(sightObject, shares.create(options));
return sightObject;
var updateSight = (putOptions, callback) => {
var urlOptions = {url: buildUrl(putOptions)};
return requestor.put(_.extend({}, optionsToSend, urlOptions, putOptions), callback);
};
return buildSightObject();
var copySight = (postOptions, callback) => {
var urlOptions = {url: buildUrl(postOptions) + '/copy'};
return requestor.post(_.extend({}, optionsToSend, urlOptions, postOptions), callback);
};
var moveSight = (postOptions, callback) => {
var urlOptions = {url: buildUrl(postOptions) + '/move'};
return requestor.post(_.extend({}, optionsToSend, urlOptions, postOptions), callback);
};
var getSightPublishStatus = (getOptions, callback) => {
var urlOptions = {url: buildUrl(getOptions) + '/publish'};
return requestor.get(_.extend({}, optionsToSend, urlOptions, getOptions), callback);
};
var setSightPublishStatus = (putOptions, callback) => {
var urlOptions = {url: buildUrl(putOptions) + '/publish'};
return requestor.put(_.extend({}, optionsToSend, urlOptions, putOptions), callback);
};
var buildUrl = urlOptions =>
options.apiUrls.sights + (urlOptions.sightId || '');
var sightObject = {
listSights : getSight,
getSight : getSight,
deleteSight : deleteSight,
updateSight: updateSight,
copySight: copySight,
moveSight: moveSight,
getSightPublishStatus: getSightPublishStatus,
setSightPublishStatus: setSightPublishStatus
};
_.extend(sightObject, shares.create(options));
return sightObject;
};

@@ -1,6 +0,6 @@

var utils = require('../utils/httpUtils.js');
var _ = require('underscore');
var constants = require('../utils/constants.js');
exports.create = function(options) {
var requestor = options.requestor;
var optionsToSend = {

@@ -11,9 +11,8 @@ url: options.apiUrls.templates,

var listUserCreatedTemplates = function(getOptions, callback) {
return utils.get(_.extend(optionsToSend, getOptions), callback);
};
var listUserCreatedTemplates = (getOptions, callback) =>
requestor.get(_.extend({}, optionsToSend, getOptions), callback);
var listPublicTemplates = function(getOptions, callback) {
optionsToSend.url = options.apiUrls.templatesPublic;
return utils.get(_.extend(optionsToSend, getOptions), callback);
var listPublicTemplates = (getOptions, callback) => {
var urlOptions = {url: options.apiUrls.templatesPublic};
return requestor.get(_.extend({}, optionsToSend, urlOptions, getOptions), callback);
};

@@ -20,0 +19,0 @@

@@ -1,6 +0,7 @@

var utils = require('../utils/httpUtils.js');
var _ = require('underscore');
var constants = require('../utils/constants.js');
var alternateEmails = require('./alternateemails.js');
exports.create = function(options) {
var requestor = options.requestor;
var optionsToSend = {

@@ -11,28 +12,23 @@ url: options.apiUrls.users,

var listAllUsers = function(getOptions, callback) {
return utils.get(_.extend(optionsToSend, getOptions), callback);
};
var listAllUsers = (getOptions, callback) =>
requestor.get(_.extend({}, optionsToSend, getOptions), callback);
var getCurrentUser = function(getOptions, callback) {
optionsToSend.url = options.apiUrls.users + 'me';
return utils.get(_.extend(optionsToSend, getOptions), callback);
var getCurrentUser = (getOptions, callback) => {
var urlOptions = {url: options.apiUrls.users + 'me'};
return requestor.get(_.extend({}, optionsToSend, urlOptions, getOptions), callback);
};
var addUser = function(postOptions, callback) {
return utils.post(_.extend(optionsToSend, postOptions), callback);
};
var addUser = (postOptions, callback) =>
requestor.post(_.extend({}, optionsToSend, postOptions), callback);
var addUserAndSendEmail = function(postOptions, callback) {
return addUser(_.extend(postOptions, {queryParameters:{sendEmail:true}}), callback);
};
var addUserAndSendEmail = (postOptions, callback) =>
addUser(_.extend({}, postOptions, {queryParameters:{sendEmail:true}}), callback);
var updateUser = function(putOptions, callback) {
return utils.put(_.extend(optionsToSend, putOptions), callback);
};
var updateUser = (putOptions, callback) =>
requestor.put(_.extend({}, optionsToSend, putOptions), callback);
var removeUser = function(deleteOptions, callback) {
return utils.delete(_.extend(optionsToSend, deleteOptions), callback);
};
var removeUser = (deleteOptions, callback) =>
requestor.delete(_.extend({}, optionsToSend, deleteOptions), callback);
return {
var userObject = {
getUser : listAllUsers,

@@ -46,2 +42,6 @@ listAllUsers : listAllUsers,

};
_.extend(userObject, alternateEmails.create(options));
return userObject;
};

@@ -7,2 +7,3 @@ module.exports = {

home : '2.0/home/',
imageUrls : '2.0/imageurls/',
reports : '2.0/reports/',

@@ -15,4 +16,6 @@ search : '2.0/search/',

templatesPublic : '2.0/templates/public',
token : '2.0/token',
users : '2.0/users/',
webhooks : '2.0/webhooks/',
workspaces : '2.0/workspaces/'
};

@@ -0,1 +1,3 @@

exports.maxRetryDurationMillis = 15000;
exports.accessLevel = {

@@ -25,3 +27,4 @@ admin : 'ADMIN',

template : 'template',
workspace : 'workspace'
workspace : 'workspace',
sight : 'sight'
};

@@ -28,0 +31,0 @@

@@ -1,5 +0,5 @@

var utils = require('../utils/httpUtils.js');
var _ = require('underscore');
exports.create = function(options) {
var requestor = options.requestor;
var shares = require('../share/share.js')(options.apiUrls.workspaces);

@@ -12,33 +12,38 @@

var listWorkspaces = function(getOptions, callback) {
optionsToSend.url = buildUrl(getOptions);
return utils.get(_.extend(optionsToSend, getOptions), callback);
var listWorkspaces = (getOptions, callback) => {
var urlOptions = {url: buildUrl(getOptions)};
return requestor.get(_.extend({}, optionsToSend, urlOptions, getOptions), callback);
};
var listWorkspaceFolders = function(getOptions, callback) {
optionsToSend.url = buildUrl(getOptions) + '/folders';
return utils.get(_.extend(optionsToSend, getOptions), callback);
var listWorkspaceFolders = (getOptions, callback) => {
var urlOptions = {url: buildUrl(getOptions) + '/folders'};
return requestor.get(_.extend({}, optionsToSend, urlOptions, getOptions), callback);
};
var createWorkspace = function(postOptions, callback) {
optionsToSend.url = buildUrl(postOptions);
return utils.post(_.extend(optionsToSend, postOptions), callback);
var createWorkspace = (postOptions, callback) => {
var urlOptions = {url: buildUrl(postOptions)};
return requestor.post(_.extend({}, optionsToSend, urlOptions, postOptions), callback);
};
var createFolder = function(postOptions, callback) {
optionsToSend.url = buildUrl(postOptions) + '/folders';
return utils.post(_.extend(optionsToSend, postOptions), callback);
var createFolder = (postOptions, callback) => {
var urlOptions = {url: buildUrl(postOptions) + '/folders'};
return requestor.post(_.extend({}, optionsToSend, urlOptions, postOptions), callback);
};
var updateWorkspace = function(putOptions, callback) {
optionsToSend.url = buildUrl(putOptions);
return utils.put(_.extend(optionsToSend, putOptions), callback);
var updateWorkspace = (putOptions, callback) => {
var urlOptions = {url: buildUrl(putOptions)};
return requestor.put(_.extend({}, optionsToSend, urlOptions, putOptions), callback);
};
var deleteWorkspace = function(deleteOptions, callback) {
optionsToSend.url = buildUrl(deleteOptions);
return utils.delete(_.extend(optionsToSend, deleteOptions), callback);
var deleteWorkspace = (deleteOptions, callback) => {
var urlOptions = {url: buildUrl(deleteOptions)};
return requestor.delete(_.extend({}, optionsToSend, urlOptions, deleteOptions), callback);
};
var buildUrl = function(urlOptions) {
var copyWorkspace = (postOptions, callback) => {
var urlOptions = {url: buildUrl(postOptions) + '/copy'};
return requestor.post(_.extend({}, optionsToSend, urlOptions, postOptions), callback);
};
var buildUrl = urlOptions => {
var id ='';

@@ -51,18 +56,16 @@ if(urlOptions && urlOptions.workspaceId){

var buildWorkspaceObject = function() {
var workspaceObject = {
listWorkspaces : listWorkspaces,
getWorkspace : listWorkspaces,
listWorkspaceFolders : listWorkspaceFolders,
createWorkspace : createWorkspace,
createFolder : createFolder,
deleteWorkspace : deleteWorkspace,
updateWorkspace : updateWorkspace
};
workspaceObject = _.extend(workspaceObject, shares.create(options));
return workspaceObject;
var workspaceObject = {
listWorkspaces : listWorkspaces,
getWorkspace : listWorkspaces,
listWorkspaceFolders : listWorkspaceFolders,
createWorkspace : createWorkspace,
createFolder : createFolder,
deleteWorkspace : deleteWorkspace,
updateWorkspace : updateWorkspace,
copyWorkspace : copyWorkspace
};
return buildWorkspaceObject();
_.extend(workspaceObject, shares.create(options));
return workspaceObject;
};
{
"name": "smartsheet",
"version": "0.2.0",
"description": "Smartsheet JavaScript SDK",
"version": "1.0.0-beta.0",
"description": "Smartsheet JavaScript client SDK",
"main": "index.js",
"scripts": {
"test": "istanbul cover _mocha -- -u exports -R spec"
"test": "mocha \"test/**/*.js\"",
"test-functional": "mocha \"test/functional/**/*.js\"",
"coverage": "istanbul cover _mocha -- -u exports -R spec \"test/functional/**/*.js\"",
"report-coverage": "cat ./coverage/lcov.info | coveralls"
},
"repository": {
"type": "git",
"url": "https://github.com/smartsheet-platform/smartsheet-javascript-sdk.git"
"url": "github:smartsheet-platform/smartsheet-javascript-sdk"
},

@@ -19,10 +22,6 @@ "keywords": [

"author": "Smartsheet",
"licenses": [
{
"type": "Apache-2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0"
}
],
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/smartsheet-platform/smartsheet-javascript-sdk/issues"
"url": "https://github.com/smartsheet-platform/smartsheet-javascript-sdk/issues",
"email": "api@smartsheet.com"
},

@@ -32,9 +31,11 @@ "browser": {

},
"homepage": "http://smartsheet.com/developers",
"homepage": "http://developers.smartsheet.com",
"dependencies": {
"bluebird": "^2.9.24",
"bluebird": "^3.5.0",
"request": "^2.54.0",
"underscore": "^1.8.2"
"underscore": "^1.8.2",
"winston": "^2.3.1"
},
"devDependencies": {
"coveralls": "^2.13.1",
"gulp": "^3.8.11",

@@ -44,8 +45,13 @@ "gulp-jshint": "^1.10.0",

"gulp-util": "^3.0.4",
"istanbul": "^0.4.5",
"jshint-stylish": "^1.0.1",
"mocha": "^2.2.1",
"mock": "^0.1.1",
"should": "^5.2.0",
"should": "^13.0.1",
"sinon": "^1.14.1"
},
"directories": {
"lib": "lib",
"test": "test"
}
}

@@ -1,7 +0,9 @@

# Smartsheet SDK for JavaScript
# Smartsheet SDK for JavaScript [![Build Status](https://travis-ci.org/armstnp/smartsheet-javascript-sdk.svg?branch=master)](https://travis-ci.org/armstnp/smartsheet-javascript-sdk) [![Coverage Status](https://coveralls.io/repos/github/armstnp/smartsheet-javascript-sdk/badge.svg?branch=master)](https://coveralls.io/github/armstnp/smartsheet-javascript-sdk?branch=master)
This is an SDK to simplify connecting to the [Smartsheet API](http://www.smartsheet.com/developers/api-documentation) from Node.js applications.
This is a client SDK to simplify connecting to the [Smartsheet API](http://www.smartsheet.com/developers/api-documentation) from Node.js applications.
**Please note that this SDK is beta and may change significantly in the future.**
## System Requirements
The SDK supports Node.js versions 6.x or later.
## Installation

@@ -11,10 +13,106 @@

npm install smartsheet
```bash
npm install smartsheet
```
## Documentation
The Smartsheet API documentation can be found [here](http://www.smartsheet.com/developers/api-documentation).
The Smartsheet API documentation with corresponding SDK example code can be found [here](http://www.smartsheet.com/developers/api-documentation).
See [this page](https://github.com/smartsheet-platform/smartsheet-javascript-sdk/blob/master/ExampleUsage.md) for code examples that show how to use this SDK.
## Example Usage
To call the API, you must have an access token, which looks something like this example: ll352u9jujauoqz4gstvsae05. You can find the access token in the Smartsheet UI at Account > Personal Settings > API Access.
The following is a brief sample using promises that shows you how to:
* Initialize the client
* List all sheets
* Load one sheet
```javascript
// Initialize the client
var client = require('smartsheet');
var smartsheet = client.createClient({
accessToken: 'll352u9jujauoqz4gstvsae05',
logLevel: 'info'
});
// The `smartsheet` variable now contains access to all of the APIs
// List all sheets
smartsheet.sheets.listSheets()
.then(function (result) {
var sheetId = result.data[0].id; // Choose the first sheet
// Load one sheet
smartsheet.sheets.getSheet({id: sheetId})
.then(function(sheetInfo) {
console.log(sheetInfo);
})
.catch(function(error) {
console.log(error);
});
})
.catch(function(error) {
console.log(error);
});
```
Although the example above is using promises and the API documentation samples use promises, you could also access the APIs in this SDK by using callbacks.
```javascript
// List all sheets using callbacks
smartsheet.sheets.listSheets({}, function(error, data) {
if (error) {
console.log(error);
} else {
console.log(data);
}
});
```
See the [node-read-write-sheet](https://github.com/smartsheet-samples/node-read-write-sheet) project for a code example that shows how to call methods to read and write to a sheet using this SDK.
## Basic Configuration
When creating the client object, pass an object with any of the following properties to tune its behavior.
* `maxRetryDurationSeconds` - The maximum time in seconds to retry intermittent errors. (Defaults to 15 seconds.)
* `logLevel` - Set to `'info'` to log each call and return value to the console.
## Advanced Configuration Options
### Logging Configuration
This library leverages [**winston**](https://github.com/winstonjs/winston) for logging.
Supported log levels are:
|Level|What is logged|
|---|---|
|`'error'`|Failures only|
|`'warn'`|Failures and retries|
|`'info'`|Each call URL and response code|
|`'verbose'`|Payloads, truncated to 1024 characters|
|`'debug'`|Full payloads|
|`'silly'`|Full payloads and HTTP headers|
You may create your own **winston** container or configure the default `winston.loggers` container, adding a logger named 'smartsheet'. Specify this container using the configuration option `loggerContainer`. ([winston documentation on configuring loggers](https://github.com/winstonjs/winston#working-with-multiple-loggers-in-winston).)
If you want to use your own logger, pass a logger object as the configuration option `logger` that implements the following methods:
* `silly`, `verbose`, `debug`, `info`, `warn`, `error` - Standard logging methods
* `log` - Similar to the above, but accepting the logging level string as its initial parameter; the log level is guaranteed be one of the above options.
### Retry Configuration
For additional customization, you can specify a `calcRetryBackoff` function. This function is called with two arguments:
* The first accepts the index of the retry being attempted (0 for the first retry, 1 for the second, etc.)
* The second accepts the Error Object that caused the retry.
The function must return the number of milliseconds to wait before making the subsequent retry call, or a negative number if no more retries should be made.
The default implementation performs exponential backoff with jitter.
## Contributing

@@ -27,21 +125,14 @@

If you have any questions or issues with this SDK please post on [StackOverflow using the tag "smartsheet-api"](http://stackoverflow.com/questions/tagged/smartsheet-api) or contact us directly at api@smartsheet.com.
If you have any questions or issues with this SDK please post on [Stack Overflow using the tag "smartsheet-api"](http://stackoverflow.com/questions/tagged/smartsheet-api) or contact us directly at api@smartsheet.com.
## Example Usage
## Release Notes
All APIs are exposed inside the root module that is created using the following:
Each specific release is available for download via [GitHub](https://github.com/smartsheet-platform/smartsheet-javascript-sdk/tags).
var client = require('smartsheet');
var smartsheet = client.createClient({accessToken:'ACCESSTOKEN'});
**v1.0.0-beta.0 (October 2017)**
Beta release of the Smartsheet SDK for JavaScript
The **smartsheet** variable now contains access to all of the APIs [documented here](http://www.smartsheet.com/developers/api-documentation).
See [this page](https://github.com/smartsheet-platform/smartsheet-javascript-sdk/blob/master/ExampleUsage.md) for code examples that show how to call various methods using this SDK.
## Release Notes
Each specific release is available for download via [Github](https://github.com/smartsheet-platform/smartsheet-javascript-sdk/tags).
**v0.0.1-beta (Aug 12, 2015)**
* Initial Release of the Smartsheet SDK for JavaScript
Initial Release of the Smartsheet SDK for JavaScript
*Note*: Minor changes that result in a patch version increment in NPM (such as updates to the README) will not be tagged as a Release in GitHub.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc