-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathapps.js
55 lines (51 loc) · 1.59 KB
/
apps.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
* robin-js-sdk
* http://getrobin.com/
*
* Copyright (c) 2014 Robin Powered Inc.
* Licensed under the Apache v2 license.
* https://github.com/robinpowered/robin-js-sdk/blob/master/LICENSE
*
*/
var constants = require('../../util').constants;
module.exports = {
/**
* Get an app
* @param {String|Integer|undefined} appIdOrSlug A Robin app identifier or slug
* @param {Object|undefnied} params A querystring object
* @return {Function} A Promise
*/
get: function (appIdOrSlug, params) {
var path = this.constructPath(constants.APPS, appIdOrSlug);
return this.Core.GET(path, params);
},
/**
* Update an app
* @param {String|Integer} appIdOrSlug A Robin app identifier or slug
* @param {Object} data A data object
* @return {Function} A Promise
*/
update: function (appIdOrSlug, data) {
var path;
if (appIdOrSlug && data) {
path = this.constructPath(constants.APPS, appIdOrSlug);
return this.Core.POST(path, data);
} else {
return this.rejectRequest('Bad Request: An app id or slug and a data object are required.');
}
},
/**
* Delete an app
* @param {String|Integer} appIdOrSlug A Robin app identifier or slug
* @return {Function} A Promise
*/
delete: function (appIdOrSlug) {
var path;
if (appIdOrSlug) {
path = this.constructPath(constants.APPS, appIdOrSlug);
return this.Core.DELETE(path);
} else {
return this.rejectRequest('Bad Request: An app id or slug is required.');
}
}
};