-
Notifications
You must be signed in to change notification settings - Fork 0
/
Function.cs
71 lines (66 loc) · 2.59 KB
/
Function.cs
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
using System.Collections.Generic;
using Alexa.NET;
using Alexa.NET.APL;
using Alexa.NET.APL.Commands;
using Alexa.NET.APL.Components;
using Alexa.NET.Request;
using Alexa.NET.Response;
using Alexa.NET.Response.APL;
using Amazon.Lambda.Core;
using Newtonsoft.Json;
// Assembly attribute to enable the Lambda function's JSON input to be converted into a .NET class.
[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.Json.JsonSerializer))]
namespace APLTransition
{
public class Function
{
public SkillResponse FunctionHandler(APLSkillRequest input, ILambdaContext context)
{
var response = ResponseBuilder.Tell("Here's your transition");
response.Response.Directives.Add(new RenderDocumentDirective
{
Document = GetDocument()
});
return response;
}
private APLDocument GetDocument()
{
var definition = JsonConvert.DeserializeObject<CommandDefinition>(System.IO.File.ReadAllText("JackInTheBox.json"));
return new APLDocument(APLDocumentVersion.V1_1)
{
Commands = new Dictionary<string, CommandDefinition>
{
{"JackInTheBox",definition }
},
MainTemplate = new Layout(
new Container
{
Height = new AbsoluteDimension(100, "vh"),
Width = new AbsoluteDimension(100, "vw"),
AlignItems = "center",
Direction = "column",
JustifyContent = "center",
Items = new List<APLComponent>
{
new Text("APL Transition!")
{
FontSize = 70,
Height = new AbsoluteDimension(15,"vh"),
Width = new AbsoluteDimension(47,"vw"),
OnMount = new List<APLCommand>
{
new CustomCommand("JackInTheBox")
{
ParameterValues = new Dictionary<string, object>
{
{"duration",2000 }
}
}
}
}
}
}).AsMain()
};
}
}
}