-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
38 lines (32 loc) · 951 Bytes
/
index.js
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
const axios = require('axios');
class SipuniApi {
host = 'https://sipuni.com';
token;
constructor({token, host}) {
if (host)
this.host = host;
if (!token)
throw new Error('token not set');
this.token = token;
axios.defaults.headers.common['Authorization'] = `Bearer ${token}`;
}
async sendNotifyWebphoneSimple(shortNum, cardTitle, urlTitle, url) {
return this.sendNotifyWebphone(shortNum, {
"title": cardTitle,
"links": [
{
"title": urlTitle,
"url": url
}
]
});
}
async sendNotifyWebphone(shortNum, notifyData) {
let res = await axios.post(this.host + '/ext/sendNotifyWebPhoneFaas', {
shortNum: shortNum,
data: notifyData
});
return !!res.data.success;
}
}
module.exports = SipuniApi;