@veritree/services 1.5.0-2 → 1.5.0-5
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/images.js +6 -0
- package/src/endpoints/orgs.js +12 -0
- package/src/helpers/api.js +2 -2
- package/src/helpers/team.js +40 -0
package/package.json
CHANGED
package/src/endpoints/images.js
CHANGED
|
@@ -6,6 +6,12 @@ class ImagesApi extends Api {
|
|
|
6
6
|
this.resource = "images";
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
rotate(id, data) {
|
|
10
|
+
const url = `${id}/rotate${this.getUrlParams()}`;
|
|
11
|
+
|
|
12
|
+
return this.update(url, data, 'patch');
|
|
13
|
+
}
|
|
14
|
+
|
|
9
15
|
relation(prefix, id) {
|
|
10
16
|
return Relations(this, prefix, id);
|
|
11
17
|
}
|
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,16 @@ 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
|
+
|
|
16
|
+
async roles(orgId, params) {
|
|
17
|
+
const url = `${this.getUrl()}/${orgId}/roles${this.getUrlParams(params)}`;
|
|
18
|
+
return await this.get(url);
|
|
19
|
+
}
|
|
20
|
+
|
|
9
21
|
async stats() {
|
|
10
22
|
const url = `${this._geStatstUrl()}`;
|
|
11
23
|
return await this.get(url);
|
package/src/helpers/api.js
CHANGED
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
return {
|
|
33
|
+
all,
|
|
34
|
+
single,
|
|
35
|
+
create,
|
|
36
|
+
update,
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export default Team;
|