-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresponses.js
46 lines (42 loc) · 1.49 KB
/
responses.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
responses = {};
responses.failure = (key, msg) =>
`<response> \
<returncode>FAILED</returncode> \
<messageKey>${key}</messageKey> \
<message>${msg}</message> \
</response>`
;
responses.checksumError =
responses.failure("checksumError", "You did not pass the checksum security check.");
responses.createSuccess = (id, permanent, getRaw) =>
`<response> \
<returncode>SUCCESS</returncode> \
<hookID>${id}</hookID> \
<permanentHook>${permanent}</permanentHook> \
<rawData>${getRaw}</rawData> \
</response>`
;
responses.createFailure =
responses.failure("createHookError", "An error happened while creating your hook. Check the logs.");
responses.createDuplicated = id =>
`<response> \
<returncode>SUCCESS</returncode> \
<hookID>${id}</hookID> \
<messageKey>duplicateWarning</messageKey> \
<message>There is already a hook for this callback URL.</message> \
</response>`
;
responses.destroySuccess =
`<response> \
<returncode>SUCCESS</returncode> \
<removed>true</removed> \
</response>`;
responses.destroyFailure =
responses.failure("destroyHookError", "An error happened while removing your hook. Check the logs.");
responses.destroyNoHook =
responses.failure("destroyMissingHook", "The hook informed was not found.");
responses.missingParamCallbackURL =
responses.failure("missingParamCallbackURL", "You must specify a callbackURL in the parameters.");
responses.missingParamHookID =
responses.failure("missingParamHookID", "You must specify a hookID in the parameters.");
module.exports = responses;