-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrequests.go
More file actions
324 lines (309 loc) · 11 KB
/
requests.go
File metadata and controls
324 lines (309 loc) · 11 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
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
package alexa
const (
audioPlayerPlaybackStartedType = "AudioPlayer.PlaybackStarted"
audioPlayerPlaybackFinishedType = "AudioPlayer.PlaybackFinished"
audioPlayerPlaybackStoppedType = "AudioPlayer.PlaybackStopped"
audioPlayerPlaybackNearlyFinishedType = "AudioPlayer.PlaybackNearlyFinshed"
audioPlayerPlaybackFailedType = "AudioPlayer.PlaybackFailed"
intentRequestType = "IntentRequest"
launchRequestType = "LaunchRequest"
playbackControllerNextCommandIssuedType = "PlaybackController.NextCommandIssued"
playbackControllerPausedCommandIssuedType = "PlaybackController.PausedCommandIssued"
playbackControllerPlayCommandIssuedType = "PlaybackController.PlayCommandIssued"
playbackControllerPreviousCommandIssuedType = "PlaybackController.PreviousCommandIssued"
sessionEndedRequestType = "SessionEndedRequest"
systemExceptionEncounteredType = "System.ExceptionEncountered"
)
// An AudioStopperQueueClearerHandler is a function that responds to any audio
// request where stopping and queue changes are allowed.
type AudioStopperQueueClearerHandler func(AudioStopperQueueClearer, *AudioPlaybackRequest) error
// An AudioPlayerStopperQueueClearerHandler is a function that responds to any
// request where playing, stopping, or queue changes are allowed.
type AudioPlayerStopperQueueClearerHandler func(AudioPlayerStopperQueueClearer, *AudioPlaybackRequest) error
// An AudioPlaybackFailedHandler is a function that responds to a request for
// when the playback of an audio file fails.
type AudioPlaybackFailedHandler func(AudioPlayerStopperQueueClearer, *AudioPlaybackFailedRequest) error
// An AudioPlaybackStoppedHandler is a function that responds to a request for
// when the playback of an audio file stops.
type AudioPlaybackStoppedHandler func(*AudioPlaybackRequest) error
// A PlaybackControllerRequestHandler is a function that will receive a request
// payload when the controller state updates.
type PlaybackControllerRequestHandler func(AudioPlayerStopperQueueClearer, *PlaybackControllerRequest) error
// A SessionEndedRequestHandler is a function that will receive a request
// payload when a session is ended.
type SessionEndedRequestHandler func(*SessionEndedRequest) error
// A SystemExceptionEncounteredHandler is a function that can receive a request
// payload when a hardware exception is encountered.
type SystemExceptionEncounteredHandler func(*SystemExceptionEncounteredRequest) error
// An AudioPlaybackFailedRequest represents the payload provided by Amazon when
// audio playback enters a failed state.
type AudioPlaybackFailedRequest struct {
Version string `json:"version"`
Context struct {
System struct {
APIEndpoint string `json:"apiEndpoint"`
Application struct {
ID string `json:"applicationId"`
} `json:"application"`
User struct {
AccessToken string `json:"accessToken"`
ID string `json:"userId"`
Permissions struct {
ConsentToken string `json:"consentToken"`
} `json:"permissions"`
} `json:"user"`
} `json:"system"`
} `json:"context"`
Request struct {
Type string `json:"type"`
RequestID string `json:"requestId"`
Timestamp string `json:"timestamp"`
Token string `json:"token"`
OffsetInMilliseconds int `json:"offsetInMilliseconds"`
Locale string `json:"locale"`
Error struct {
Type string `json:"type"`
Message string `json:"message"`
PlaybackState struct {
Token string `json:"token"`
OffsetInMilliseconds int `json:"offsetInMilliseconds"`
PlayerActivity string `json:"playerActivity"`
} `json:"currentPlaybackState"`
} `json:"error"`
} `json:"request"`
}
// An AudioPlaybackRequest represents the payload provided by amazon when the
// audio playback changes state.
type AudioPlaybackRequest struct {
Version string `json:"version"`
Context struct {
System struct {
APIEndpoint string `json:"apiEndpoint"`
Application struct {
ID string `json:"applicationId"`
} `json:"application"`
User struct {
AccessToken string `json:"accessToken"`
ID string `json:"userId"`
Permissions struct {
ConsentToken string `json:"consentToken"`
} `json:"permissions"`
} `json:"user"`
} `json:"system"`
} `json:"context"`
Request struct {
Type string `json:"type"`
RequestID string `json:"requestId"`
Timestamp string `json:"timestamp"`
Token string `json:"token"`
OffsetInMilliseconds int `json:"offsetInMilliseconds"`
Locale string `json:"locale"`
} `json:"request"`
}
// IntentRequest represents they payload provided by Amazon when an Alexa Intent
// request is made.
type IntentRequest struct {
Version string `json:"version"`
Context struct {
System struct {
APIEndpoint string `json:"apiEndpoint"`
Application struct {
ID string `json:"applicationId"`
} `json:"application"`
User struct {
AccessToken string `json:"accessToken"`
ID string `json:"userId"`
Permissions struct {
ConsentToken string `json:"consentToken"`
} `json:"permissions"`
} `json:"user"`
} `json:"system"`
} `json:"context"`
Session struct {
Application struct {
ID string `json:"applicationId"`
} `json:"application"`
Attributes map[string]interface{} `json:"attributes"`
ID string `json:"sessionId"`
New bool `json:"new"`
User struct {
AccessToken string `json:"accessToken"`
ID string `json:"userId"`
Permissions struct {
ConsentToken string `json:"consentToken"`
} `json:"permissions"`
} `json:"user"`
} `json:"session"`
Request struct {
RequestID string `json:"requestId"`
Timestamp string `json:"timestamp"`
DialogState string `json:"dialogState"`
Locale string `json:"locale"`
Intent struct {
Name string `json:"name"`
ConfirmationStatus string `json:"confirmationStatus"`
Slots map[string]struct {
Name string `json:"name"`
Value string `json:"value"`
ConfirmationStatus string `json:"confirmationStatus"`
Resolutions struct {
ResolutionsPerAuthority []struct {
Authority string `json:"authority"`
Status struct {
Code string `json:"code"`
} `json:"status"`
Values []struct {
Value struct {
Name string `json:"name"`
ID string `json:"id"`
} `json:"value"`
} `json:"values"`
} `json:"resolutionsPerAuthority"`
} `json:"resolutions"`
} `json:"slots"`
} `json:"intent"`
} `json:"request"`
}
// A LaunchRequest represents the payload provided by Amazon when a launch
// request is made.
type LaunchRequest struct {
Version string `json:"version"`
Context struct {
System struct {
APIEndpoint string `json:"apiEndpoint"`
Application struct {
ID string `json:"applicationId"`
} `json:"application"`
User struct {
AccessToken string `json:"accessToken"`
ID string `json:"userId"`
Permissions struct {
ConsentToken string `json:"consentToken"`
} `json:"permissions"`
} `json:"user"`
} `json:"system"`
} `json:"context"`
Session struct {
Application struct {
ID string `json:"applicationId"`
} `json:"application"`
Attributes map[string]interface{} `json:"attributes"`
ID string `json:"sessionId"`
New bool `json:"new"`
User struct {
AccessToken string `json:"accessToken"`
ID string `json:"userId"`
Permissions struct {
ConsentToken string `json:"consentToken"`
} `json:"permissions"`
} `json:"user"`
} `json:"session"`
Request struct {
Timestamp string `json:"timestamp"`
RequestID string `json:"requestId"`
Locale string `json:"locale"`
} `json:"request"`
}
// A PlaybackControllerRequest represents the payload provided by Amazon when
// a controller state updates.
type PlaybackControllerRequest struct {
Version string `json:"version"`
Context struct {
System struct {
APIEndpoint string `json:"apiEndpoint"`
Application struct {
ID string `json:"applicationId"`
} `json:"application"`
User struct {
AccessToken string `json:"accessToken"`
ID string `json:"userId"`
Permissions struct {
ConsentToken string `json:"consentToken"`
} `json:"permissions"`
} `json:"user"`
} `json:"system"`
} `json:"context"`
Request struct {
RequestID string `json:"requestId"`
Timestamp string `json:"timestamp"`
Locale string `json:"locale"`
} `json:"request"`
}
// A SessionEndedRequest represents the payload provided by Amazon when a
// session ended request is made.
type SessionEndedRequest struct {
Version string `json:"version"`
Context struct {
System struct {
APIEndpoint string `json:"apiEndpoint"`
Application struct {
ID string `json:"applicationId"`
} `json:"application"`
User struct {
AccessToken string `json:"accessToken"`
ID string `json:"userId"`
Permissions struct {
ConsentToken string `json:"consentToken"`
} `json:"permissions"`
} `json:"user"`
} `json:"system"`
} `json:"context"`
Session struct {
Application struct {
ID string `json:"applicationId"`
} `json:"application"`
Attributes map[string]interface{} `json:"attributes"`
ID string `json:"sessionId"`
New bool `json:"new"`
User struct {
AccessToken string `json:"accessToken"`
ID string `json:"userId"`
Permissions struct {
ConsentToken string `json:"consentToken"`
} `json:"permissions"`
} `json:"user"`
} `json:"session"`
Request struct {
Timestamp string `json:"timestamp"`
RequestID string `json:"requestId"`
Reason string `json:"reason"`
Error struct {
Type string `json:"type"`
Message string `json:"message"`
} `json:"error"`
Locale string `json:"locale"`
} `json:"request"`
}
// A SystemExceptionEncounteredRequest represents the payload provided by Amazon
// when a system exception request is made.
type SystemExceptionEncounteredRequest struct {
Version string `json:"version"`
Context struct {
System struct {
APIEndpoint string `json:"apiEndpoint"`
Application struct {
ID string `json:"applicationId"`
} `json:"application"`
User struct {
AccessToken string `json:"accessToken"`
ID string `json:"userId"`
Permissions struct {
ConsentToken string `json:"consentToken"`
} `json:"permissions"`
} `json:"user"`
} `json:"system"`
} `json:"context"`
Request struct {
Type string `json:"type"`
RequestID string `json:"requestId"`
Timestamp string `json:"timestamp"`
Locale string `json:"locale"`
Error struct {
Type string `json:"type"`
Message string `json:"message"`
} `json:"error"`
Cause struct {
RequestID string `json:"requestId"`
} `json:"cause"`
} `json:"request"`
}