-
Notifications
You must be signed in to change notification settings - Fork 257
Expand file tree
/
Copy pathinstanceGroupController.js
More file actions
49 lines (41 loc) · 1.15 KB
/
instanceGroupController.js
File metadata and controls
49 lines (41 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import http from "../http-common";
const getAll = async (instanceName) => {
return await http
.get("/group/fetchAllGroups/:instance/?getParticipants=false", {
params: {
instance: instanceName
}
})
.then((r) => r.data)
.catch((error) => {
throw error.response?.data || error.response || error;
});
}
const getById = async (instanceName, groupId) => {
return await http
.get(`/group/findGroupInfos/:instance/?groupJid=${groupId}`, {
params: { instance: instanceName }
})
.then((r) => r.data)
.catch((error) => {
throw error.response?.data || error.response || error;
});
}
const updateParticipant = async (instanceName, groupId, action, participants) => {
return await http
.put(`/group/updateParticipant/:instance/?groupJid=${groupId}`, {
action,
participants // Array of participants phone numbers
}, {
params: { instance: instanceName }
})
.then((r) => r.data)
.catch((error) => {
throw error.response?.data || error.response || error;
});
}
export default {
getAll: getAll,
getById: getById,
updateParticipant: updateParticipant
}