1 /++
2  + Authors: Stephan Dilly, lastname dot firstname at gmail dot com
3  + Copyright: MIT
4  +/
5 module ask.types;
6 
7 import vibe.data.serialization:name,optional,byName;
8 import std.typecons:Nullable;
9 
10 ///
11 struct AlexaUser {
12 	///
13 	string userId;
14 	///
15 	@optional
16 	string accessToken;
17 }
18 
19 ///
20 struct AlexaApplication {
21 	///
22 	string applicationId;
23 }
24 
25 ///
26 struct AlexaOutputSpeech {
27 	///
28 	enum Type
29 	{
30 		PlainText,
31 		SSML,
32 	}
33 
34 	///
35 	@byName
36 	Type type = Type.PlainText;
37 	///
38 	string text;
39 	///
40 	string ssml;
41 }
42 
43 /// see https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/alexa-skills-kit-interface-reference#card-object
44 struct AlexaCard {
45 
46 	///
47 	enum Type
48 	{
49 		Simple,
50 		Standard,
51 		LinkAccount
52 	}
53 
54 	///
55 	@byName
56 	Type type = Type.Simple;
57 	///
58 	string title;
59 	///
60 	string text;
61 	///
62 	string content;
63 
64 	///
65 	struct Image
66 	{
67 		///
68 		string smallImageUrl;
69 		///
70 		string largeImageUrl;
71 	}
72 
73 	///
74 	Image image;
75 }
76 
77 ///
78 struct AlexaResponse {
79 
80 	///
81 	struct Reprompt {
82 		///
83 		AlexaOutputSpeech outputSpeech;
84 	}
85 
86 	///
87 	AlexaOutputSpeech outputSpeech;
88 	///
89 	AlexaCard card;
90 	///
91 	Nullable!Reprompt reprompt;
92 }
93 
94 ///
95 struct AlexaResult {
96 
97 	///
98 	@name("version")
99 	string _version = "1.0";
100 
101 	///
102 	string[string] sessionAttributes;
103 
104 	///
105 	bool shouldEndSession;
106 
107 	///
108 	AlexaResponse response;
109 }
110 
111 //TODO:
112 ///
113 /+struct AlexaDevice
114 {
115 	supportedInterfaces
116 }+/
117 
118 /// see https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/alexa-skills-kit-interface-reference#context-object
119 struct AlexaRequestContext {
120 
121 	/// see https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/alexa-skills-kit-interface-reference#system-object
122 	struct AlexaSystem
123 	{
124 		///
125 		AlexaApplication application;
126 		///
127 		AlexaUser user;
128 		//TODO:
129 		//AlexaDevice device;
130 	}
131 
132 	///
133 	struct AlexaAudioPlayer
134 	{
135 		///
136 		@optional
137 		string token;
138 		///
139 		@optional
140 		int offsetInMilliseconds;
141 		///
142 		string playerActivity;
143 	}
144 
145 	///
146 	@name("System")
147 	AlexaSystem system;
148 	///
149 	@name("AudioPlayer")
150 	AlexaAudioPlayer audioPlayer;
151 }
152 
153 ///
154 struct AlexaIntent
155 {
156 	///
157 	struct AlexaSlot
158 	{
159 		///
160 		string name;
161 		///
162 		@optional
163 		string value;
164 	}
165 
166 	///
167 	string name;
168 	///
169 	@optional
170 	AlexaSlot[string] slots;
171 }
172 
173 ///
174 struct AlexaRequest
175 {
176 	///
177 	struct Error
178 	{
179 		///
180 		string type;
181 		///
182 		string message;
183 	}
184 
185 	///
186 	enum Type
187 	{
188 		///
189 		LaunchRequest,
190 		///
191 		IntentRequest,
192 		///
193 		SessionEndedRequest
194 	}
195 
196 	///
197 	@byName
198 	Type type;
199 	///
200 	string requestId;
201 	///
202 	string timestamp;
203 	///
204 	string locale;
205 
206 	///
207 	@optional
208 	string reason;
209 
210 	///
211 	@optional
212 	Error error;
213 
214 	///
215 	@optional
216 	AlexaIntent intent;
217 }
218 
219 /// see https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/alexa-skills-kit-interface-reference#request-format
220 struct AlexaEvent {
221 
222 	///
223 	struct Session {
224 
225 		///
226 		@name("new")
227 		bool _new;
228 		///
229 		string sessionId;
230 		///
231 		AlexaApplication application;
232 		///
233 		@optional
234 		string[string] attributes;
235 		///
236 		AlexaUser user;
237 	}
238 
239 	///
240 	@name("version")
241 	string _version;
242 
243 	///
244 	Session session;
245 
246 	///
247 	AlexaRequest request;
248 }
249 
250 ///
251 struct AlexaContext
252 {
253 	///
254 	string functionName;
255 	///
256 	string invokedFunctionArn;
257 	///
258 	string awsRequestId;
259 	///
260 	string logStreamName;
261 	///
262 	string invokeid;
263 	///
264 	bool callbackWaitsForEmptyEventLoop;
265 	///
266 	string logGroupName;
267 	///
268 	string functionVersion;
269 	///
270 	string memoryLimitInMB;
271 }