-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
51 lines (45 loc) · 1.19 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
const slackifyMarkdown = require('slackify-markdown');
const candidateMessage = body => {
let message = ""
switch (body.event_type) {
case "candidate_created":
message = "A new candidate is available"
break
case "candiate_moved":
message = `Candidate has changed stage to ${body.data.stage}`
break
}
return message
}
module.exports.process = body => {
if (body.data === undefined || body.resource_type === undefined) {
throw new Error("invalid request body")
}
switch (body.resource_type) {
case "candidate":
return {
parse: "full",
attachments: [{
color: "#00CF00",
title: body.data.name,
title_link: body.data.profile_url,
text: candidateMessage(body),
fields: [{
title: "Name",
value: body.data.name
}, {
title: "Stage",
value: body.data.stage
}, {
title: "Summary",
value: slackifyMarkdown(body.data.summary)
}]
}],
username: "Workable",
iconEmoji: ':construction_worker:'
}
break
default:
throw new Error("unknown resource_type")
}
}