dtable-web-api
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -452,2 +452,8 @@ "use strict"; | ||
}, { | ||
key: "getGroup", | ||
value: function getGroup(groupID) { | ||
var url = this.server + '/api/v2.1/groups/' + groupID + '/'; | ||
return this.req.get(url); | ||
} | ||
}, { | ||
key: "createGroup", | ||
@@ -460,2 +466,63 @@ value: function createGroup(name) { | ||
} | ||
}, { | ||
key: "renameGroup", | ||
value: function renameGroup(groupID, name) { | ||
var url = this.server + '/api/v2.1/groups/' + groupID + '/'; | ||
var params = { | ||
name: name | ||
}; | ||
return this.req.put(url, params); | ||
} | ||
}, { | ||
key: "addGroupMembers", | ||
value: function addGroupMembers(groupID, userNames) { | ||
var url = this.server + '/api/v2.1/groups/' + groupID + '/members/bulk/'; | ||
var form = new _formData["default"](); | ||
form.append('emails', userNames.join(',')); | ||
return this._sendPostRequest(url, form); | ||
} | ||
}, { | ||
key: "listGroupMembers", | ||
value: function listGroupMembers(groupID) { | ||
var isAdmin = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; | ||
var avatarSize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 64; | ||
var url = this.server + '/api/v2.1/groups/' + groupID + '/members/?avatar_size=' + avatarSize + '&is_admin=' + isAdmin; | ||
return this.req.get(url); | ||
} | ||
}, { | ||
key: "setGroupAdmin", | ||
value: function setGroupAdmin(groupID, userName, isAdmin) { | ||
var name = encodeURIComponent(userName); | ||
var url = this.server + '/api/v2.1/groups/' + groupID + '/members/' + name + '/'; | ||
var params = { | ||
is_admin: isAdmin | ||
}; | ||
return this.req.put(url, params); | ||
} | ||
}, { | ||
key: "deleteGroupMember", | ||
value: function deleteGroupMember(groupID, userName) { | ||
var name = encodeURIComponent(userName); | ||
var url = this.server + '/api/v2.1/groups/' + groupID + '/members/' + name + '/'; | ||
return this.req["delete"](url); | ||
} //account api | ||
}, { | ||
key: "getAccountInfo", | ||
value: function getAccountInfo() { | ||
var url = this.server + '/api2/account/info/'; | ||
return this.req.get(url); | ||
} | ||
}, { | ||
key: "listGroups", | ||
value: function listGroups() { | ||
var withRepos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; | ||
var options = { | ||
with_repos: withRepos ? 1 : 0 | ||
}; | ||
var url = this.server + '/api/v2.1/groups/'; | ||
return this.req.get(url, { | ||
params: options | ||
}); | ||
} | ||
}]); | ||
@@ -462,0 +529,0 @@ |
{ | ||
"name": "dtable-web-api", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "an interface for dtable-web", | ||
@@ -5,0 +5,0 @@ "main": "lib/dtable-web-api.js", |
@@ -350,2 +350,7 @@ import axios from 'axios'; | ||
getGroup(groupID) { | ||
const url = this.server + '/api/v2.1/groups/' + groupID + '/'; | ||
return this.req.get(url); | ||
} | ||
createGroup(name) { | ||
@@ -358,4 +363,52 @@ const url = this.server + '/api/v2.1/groups/'; | ||
renameGroup(groupID, name) { | ||
const url = this.server + '/api/v2.1/groups/' + groupID + '/'; | ||
const params = { | ||
name: name | ||
} | ||
return this.req.put(url, params); | ||
} | ||
addGroupMembers(groupID, userNames) { | ||
const url = this.server + '/api/v2.1/groups/' + groupID + '/members/bulk/'; | ||
let form = new FormData(); | ||
form.append('emails', userNames.join(',')); | ||
return this._sendPostRequest(url, form); | ||
} | ||
listGroupMembers(groupID, isAdmin=false, avatarSize=64) { | ||
let url = this.server + '/api/v2.1/groups/' + groupID + '/members/?avatar_size=' + avatarSize + '&is_admin=' + isAdmin; | ||
return this.req.get(url); | ||
} | ||
setGroupAdmin(groupID, userName, isAdmin) { | ||
let name = encodeURIComponent(userName); | ||
let url = this.server + '/api/v2.1/groups/' + groupID + '/members/' + name + '/'; | ||
const params = { | ||
is_admin: isAdmin | ||
} | ||
return this.req.put(url, params); | ||
} | ||
deleteGroupMember(groupID, userName) { | ||
const name = encodeURIComponent(userName); | ||
const url = this.server + '/api/v2.1/groups/' + groupID + '/members/' + name + '/'; | ||
return this.req.delete(url); | ||
} | ||
//account api | ||
getAccountInfo() { | ||
const url = this.server + '/api2/account/info/'; | ||
return this.req.get(url); | ||
} | ||
listGroups(withRepos = false) { | ||
let options = {with_repos: withRepos ? 1 : 0}; | ||
const url = this.server + '/api/v2.1/groups/'; | ||
return this.req.get(url, {params: options}); | ||
} | ||
} | ||
export default DTableWebAPI; |
32835
847