1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | const BaseService = require('./BaseService');
|
17 | const RolesService = require('./RolesService');
|
18 | const { HTTPMethod } = require('./Constants');
|
19 |
|
20 | class GroupsService extends BaseService {
|
21 | getAll(env, done) {
|
22 | const endpoint = `group/${env.id}`;
|
23 | const options = {
|
24 | endpoint,
|
25 | isBaas: true,
|
26 | headers: {
|
27 | Authorization: RolesService.getAuthorizationHeaderValue(env)
|
28 | }
|
29 | };
|
30 | this.cliManager.sendRequest(options, done);
|
31 | }
|
32 |
|
33 | create(data, env, done) {
|
34 | const endpoint = `group/${env.id}`;
|
35 | const options = {
|
36 | endpoint,
|
37 | data,
|
38 | method: HTTPMethod.POST,
|
39 | isBaas: true,
|
40 | headers: {
|
41 | Authorization: RolesService.getAuthorizationHeaderValue(env)
|
42 | }
|
43 | };
|
44 | this.cliManager.sendRequest(options, done);
|
45 | }
|
46 |
|
47 | update(id, data, env, done) {
|
48 | const endpoint = `group/${env.id}/${id}`;
|
49 | const options = {
|
50 | endpoint,
|
51 | data,
|
52 | method: HTTPMethod.PUT,
|
53 | isBaas: true,
|
54 | headers: {
|
55 | Authorization: RolesService.getAuthorizationHeaderValue(env)
|
56 | }
|
57 | };
|
58 | this.cliManager.sendRequest(options, done);
|
59 | }
|
60 | }
|
61 |
|
62 | module.exports = GroupsService;
|