-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrequest.go
More file actions
48 lines (41 loc) · 887 Bytes
/
Copy pathrequest.go
File metadata and controls
48 lines (41 loc) · 887 Bytes
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
package goask
import (
"strconv"
"time"
)
type Timestamp time.Time
type SessionAttributes map[string]interface{}
type AlexaSession struct {
New bool
SessionID string
Attributes SessionAttributes
Application struct {
ApplicationID string
}
User struct {
UserID, AccessToken string
}
}
type AlexaRequest struct {
Type string
Timestamp Timestamp
RequestID string
Intent struct {
Name string
Slots map[string]struct {
Name, Value string
}
}
}
type AlexaRequestContainer struct {
Version string
Session AlexaSession
Request AlexaRequest
}
// UnmarshalJSON converts the string representation of a Unix timestamp
// (which is how Alexa formats timestamp values) to our Timestamp type
func (t Timestamp) UnmarshalJSON(b []byte) (err error) {
tsUnix, _ := strconv.ParseInt(string(b), 10, 0)
t = Timestamp(time.Unix(tsUnix, 0))
return
}