ellipsis-default-storage
Advanced tools
Comparing version 0.1.4 to 0.1.5
74
index.js
var request = require('request'); | ||
function findMissingArgs(keysToEnsure, args) { | ||
var missing = []; | ||
keysToEnsure.forEach(function(key) { | ||
if (args[key] === undefined) { | ||
missing.push(key) | ||
} | ||
}); | ||
return missing; | ||
} | ||
module.exports = { | ||
putItem: function (itemId, itemType, item, onSuccess, onError, context) { | ||
request. | ||
post({ | ||
url: context.apiBaseUrl + "/put_item", | ||
form: {itemId: itemId, itemType: itemType, token: context.token, item: item} | ||
}, function (error, response, body) { | ||
if (!error && response.statusCode == 200) { | ||
onSuccess(response, body); | ||
} else { | ||
onError(error); | ||
putItem: function (args) { | ||
var missing = findMissingArgs(["itemId", "itemType", "item", "context"], args); | ||
if (missing.length > 0) { | ||
onError("Missing values for: " + missing.join(", ")); | ||
} else { | ||
request. | ||
post({ | ||
url: args.context.apiBaseUrl + "/put_item", | ||
form: {itemId: args.itemId, itemType: args.itemType, token: args.context.token, item: args.item} | ||
}, function (error, response, body) { | ||
if (!error && response.statusCode == 200) { | ||
if (args.onSuccess) { | ||
args.onSuccess(response, body); | ||
} | ||
} else { | ||
if (args.onError) { | ||
args.onError(error); | ||
} | ||
} | ||
} | ||
} | ||
); | ||
); | ||
} | ||
}, | ||
getItem: function (itemId, itemType, onSuccess, onError, context) { | ||
request. | ||
get( | ||
context.apiBaseUrl + "/get_item/" + itemId + "/" + itemType + "/" + context.token, | ||
function (error, response, body) { | ||
if (!error && response.statusCode == 200) { | ||
onSuccess(response, body); | ||
} else { | ||
onError(error); | ||
getItem: function (args) { | ||
var missing = findMissingArgs(["itemId", "itemType", "context"], args); | ||
if (missing.length > 0) { | ||
onError("Missing values for: " + missing.join(", ")); | ||
} else { | ||
request. | ||
get( | ||
args.context.apiBaseUrl + "/get_item/" + args.itemId + "/" + args.itemType + "/" + args.context.token, | ||
function (error, response, body) { | ||
if (!error && response.statusCode == 200) { | ||
if (args.onSuccess) { | ||
args.onSuccess(response, body); | ||
} | ||
} else { | ||
if (args.onError) { | ||
args.onError(error); | ||
} | ||
} | ||
} | ||
} | ||
); | ||
); | ||
} | ||
} | ||
}; |
{ | ||
"name": "ellipsis-default-storage", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "Interface to the default storage for Ellipsis behaviors", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2438
57