-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexpressions-example.js
More file actions
49 lines (47 loc) · 1.64 KB
/
expressions-example.js
File metadata and controls
49 lines (47 loc) · 1.64 KB
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
const jsonata = require('jsonata');
const TransformExpressions = {
'/api/messages': jsonata(`{
"request" : {
"path" : $join(["/v9/messages", request.payload.action = 'create' and request.payload.post.participant_id != null?'send_to_user':'send'],"/"),
"payload" : {
"id" : $number(response.payload.post.id),
"conv_id" : $number(request.payload.post.group),
"to_user_id" : $number(request.payload.post.participant_id),
"client_id" : request.payload.post.client_id,
"content" : request.payload.post.content,
"embeds" : request.payload.post.embeds,
"created_at" : $number(request.payload.post.created)
},
"headers" : {
"content-type": request.headers.\`content-type\`,
"user-agent": request.headers.\`user-agent\`,
"cookie": request.headers.cookie,
"origin": request.headers.origin,
"referer": request.headers.referer
},
"method" : $uppercase(request.method)
},
"response" : {
"headers" : {
"content-type" : response.headers.\`content-type\`
},
"payload" : {
"conversation" : {
"id" : response.payload.group.id,
"unqiue_hash" : response.payload.group.hash,
"created_at" : response.payload.group.created
},
"message" : {
"id" : response.payload.post.id,
"content" : response.payload.post.content,
"embeds" : response.payload.post.embeds,
"created_at" : response.payload.post.created,
"client_id" : response.payload.post.client_id
}
}
}
}`)
};
module.exports = {
TransformExpressions
};