-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathlineService.ts
31 lines (26 loc) · 908 Bytes
/
lineService.ts
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
import logService from './logService';
import CONFIG from './config';
const lineService = {
pushMsg: (config) => {
logService.log('[LineService.pushMsg] Push message');
const { type, to, replyToken, messages } = config;
const payload = { messages };
if (to) {
payload.to = to;
}
if (replyToken) {
payload.replyToken = replyToken;
}
const option = {
'headers': {
'Content-Type': 'application/json; charset=UTF-8',
'Authorization': 'Bearer ' + CONFIG.LINE.CHANNEL_ACCESS_TOKEN
},
'method': 'post',
'payload': JSON.stringify(payload)
};
UrlFetchApp.fetch(CONFIG.LINE.URL_LINE + type, option);
logService.log('[LineService.pushMsg] Push message successfully');
}
};
export default lineService;