From 653e5cbcb8f442879e381b1c0f005c2ea55acd81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Thu, 18 Jul 2024 12:32:26 +0900 Subject: [PATCH] rename --- src/apl/ChildListDirective.ts | 46 +++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/apl/ChildListDirective.ts diff --git a/src/apl/ChildListDirective.ts b/src/apl/ChildListDirective.ts new file mode 100644 index 0000000..2132b30 --- /dev/null +++ b/src/apl/ChildListDirective.ts @@ -0,0 +1,46 @@ + +import { Directive } from "ask-sdk-model"; + +const DOCUMENT_ID = "child_list"; + +class ChildListDirective { + + public createDirectivePayload = (dataSources = {}, tokenId = "documentToken"): Directive => { + return { + type: "Alexa.Presentation.APL.RenderDocument", + token: tokenId, + document: { + type: "Link", + src: "doc://alexa/apl/documents/" + DOCUMENT_ID + }, + datasources: dataSources + } + }; + + public createDataSources = (listItems: string[]) => { + const datasource = { + "textListData": { + "type": "object", + "objectId": "textListSample", + "backgroundImage": { + "contentDescription": null, + "smallSourceUrl": null, + "largeSourceUrl": null, + "sources": [ + { + "url": "https://d2o906d8ln7ui1.cloudfront.net/images/templates_v3/textlist/AlexaTextListBackground_Dark.png", + "size": "large" + } + ] + }, + "title": "子供を選択", + "listItems": listItems, + "logoUrl": "https://d2o906d8ln7ui1.cloudfront.net/images/templates_v3/logo/logo-modern-botanical-white.png" + } + }; + + return datasource; + } +} + +export default new ChildListDirective();