-
Notifications
You must be signed in to change notification settings - Fork 0
/
SlackClient.js
37 lines (33 loc) · 893 Bytes
/
SlackClient.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
function getUserPresenceReqOptions(token, userId){
return ({
'method' : 'get',
'headers': {
'contentType': 'application/x-www-form-urlencoded'
},
'payload': {
token: token,
user: userId,
}
});
}
function getUserPresenceResponse(token, userId){
var response = UrlFetchApp.fetch(SLACK_USER_PRESENCE_API_URL, getUserPresenceReqOptions(token, userId));
return response;
}
function getPostMessageReqOptions(token, channelId, message){
var postMessageData = {
token: token,
channel: channelId,
text: message
};
return ({
headers: {
'contentType': 'application/x-www-form-urlencoded'
},
payload: postMessageData
});
}
function postMessageToSlackChannel(token, channelId, message){
var response = UrlFetchApp.fetch(SLACK_POST_MESSAGE_API_URL, getPostMessageReqOptions(token, channelId, message));
return response;
}