-
Notifications
You must be signed in to change notification settings - Fork 7
/
request.js
88 lines (68 loc) · 1.75 KB
/
request.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
class Request {
constructor(req) {
this._body = req;
}
get body() {
return this._body;
}
get query() {
return this.body.query;
}
get session() {
return this.body.session;
}
get appId() {
return this.session.application.app_id;
}
get user() {
return this.session.user;
}
get context() {
return this.body.context;
}
get slotInfo() {
return this.body.request.slot_info;
}
get intentName() {
if (!this.slotInfo) return null;
return this.slotInfo.intent_name;
}
get eventType() {
return this.body.request.event_type;
}
get eventProperty() {
return this.body.request.event_property;
}
get requestId() {
return this.body.request.request_id;
}
get requestType() {
return this.body.request.type;
}
get isEnterSkill() {
return (this.requestType === 0);
}
get isInSkill() {
return (this.requestType === 1);
}
get isQuitSkill() {
return (this.requestType === 2);
}
get isNoResponse() {
if (!this.body.request.no_response) return false;
return ((this.isInSkill) && this.body.request.no_response);
}
get isRecordFinish() {
if (!this.eventType) return false;
return ((this.isInSkill) && this.eventType === 'leavemsg.finished');
}
get isRecordFail() {
if (!this.eventType) return false;
return ((this.isInSkill) && this.eventType === 'leavemsg.failed');
}
get isPlayFinishing() {
if (!this.eventType) return false;
return ((this.isInSkill) && this.eventType === 'mediaplayer.playbacknearlyfinished');
}
}
module.exports = Request;