-
Notifications
You must be signed in to change notification settings - Fork 257
Expand file tree
/
Copy pathinstanceChatController.js
More file actions
61 lines (55 loc) · 1.35 KB
/
instanceChatController.js
File metadata and controls
61 lines (55 loc) · 1.35 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
50
51
52
53
54
55
56
57
58
59
60
61
import http from "../http-common";
const getAll = async (instanceName) => {
return await http
.get("/chat/findChats/:instance", {
params: {
instance: instanceName
}
})
.then((r) => r.data)
.catch((error) => {
throw error.response?.data || error.response || error;
});
}
const hasWhatsapp = async (instanceName, numbers) => {
return await http
.post("/chat/whatsappNumbers/:instance", { numbers }, {
params: {
instance: instanceName
}
})
.then((r) => r.data)
.catch((error) => {
throw error.response?.data || error.response || error;
});
}
const getContacts = async (instanceName, numbers) => {
return await http
.post("/chat/findContacts/:instance", { numbers }, {
params: {
instance: instanceName
}
})
.then((r) => r.data)
.catch((error) => {
throw error.response?.data || error.response || error;
});
}
const sendMessage = async (instanceName, options) => {
return await http
.post("/message/sendText/:instance", options, {
params: {
instance: instanceName
}
})
.then((r) => r.data)
.catch((error) => {
throw error.response?.data || error.response || error;
});
}
export default {
getAll: getAll,
hasWhatsapp: hasWhatsapp,
getContacts: getContacts,
sendMessage: sendMessage
}