UNPKG

1.96 kBJavaScriptView Raw
1/**
2 * Copyright (c) 2018, Kinvey, Inc. All rights reserved.
3 *
4 * This software is licensed to you under the Kinvey terms of service located at
5 * http://www.kinvey.com/terms-of-use. By downloading, accessing and/or using this
6 * software, you hereby accept such terms of service (and any agreement referenced
7 * therein) and agree that you have read, understand and agree to be bound by such
8 * terms of service and are of legal age to agree to such terms with Kinvey.
9 *
10 * This software contains valuable confidential and proprietary information of
11 * KINVEY, INC and is subject to applicable licensing agreements.
12 * Unauthorized reproduction, transmission or distribution of this file and its
13 * contents is a violation of applicable laws.
14 */
15
16const BaseService = require('./BaseService');
17const RolesService = require('./RolesService');
18const { HTTPMethod } = require('./Constants');
19
20class 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
62module.exports = GroupsService;