@veritree/services 1.5.0-4 → 1.5.0-7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/endpoints/orgs.js +7 -0
- package/src/helpers/api.js +2 -2
- package/src/helpers/team.js +46 -0
package/package.json
CHANGED
package/src/endpoints/orgs.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import Api from "../helpers/api";
|
|
2
|
+
import Team from "../helpers/team";
|
|
3
|
+
import { getSession } from "../helpers/session";
|
|
2
4
|
|
|
3
5
|
class OrgsApi extends Api {
|
|
4
6
|
constructor(resource) {
|
|
@@ -6,6 +8,11 @@ class OrgsApi extends Api {
|
|
|
6
8
|
this.resource = "orgs";
|
|
7
9
|
}
|
|
8
10
|
|
|
11
|
+
users() {
|
|
12
|
+
const { orgId } = getSession();
|
|
13
|
+
return Team(this, orgId);
|
|
14
|
+
}
|
|
15
|
+
|
|
9
16
|
async roles(orgId, params) {
|
|
10
17
|
const url = `${this.getUrl()}/${orgId}/roles${this.getUrlParams(params)}`;
|
|
11
18
|
return await this.get(url);
|
package/src/helpers/api.js
CHANGED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates an abstract team object that can be used
|
|
3
|
+
* for CRUD operations related to an org users.
|
|
4
|
+
*
|
|
5
|
+
* @param {object} api
|
|
6
|
+
* @param {number} id
|
|
7
|
+
* @returns {object}
|
|
8
|
+
*/
|
|
9
|
+
const Team = (api, id) => {
|
|
10
|
+
let url = `${api.baseUrl}/${api.resource}/${id}/users`;
|
|
11
|
+
|
|
12
|
+
const all = async (args) => {
|
|
13
|
+
url = `${url}${api.getUrlParams(args)}`;
|
|
14
|
+
return await api.get(url);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const single = async (userId, args) => {
|
|
18
|
+
url = `${url}/${userId}${api.getUrlParams(args)}`;
|
|
19
|
+
return await api.get(url);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const create = async (data) => {
|
|
23
|
+
url = `${url}${api.getUrlParams()}`;
|
|
24
|
+
return await api.post(url, data);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const update = async (userId, data) => {
|
|
28
|
+
url = `${url}/${userId}${api.getUrlParams()}`;
|
|
29
|
+
return await api.update(url, data, 'patch');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const remove = async (userId) => {
|
|
33
|
+
url = `${url}/${userId}${api.getUrlParams()}`;
|
|
34
|
+
return await api.delete(url);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
all,
|
|
39
|
+
single,
|
|
40
|
+
create,
|
|
41
|
+
update,
|
|
42
|
+
delete: remove
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export default Team;
|