TaskListのハンドラ実装, Complete仮置き

This commit is contained in:
rca 2024-07-17 09:19:25 +09:00
parent faa2249c10
commit 5b948f105a

View File

@ -4,6 +4,9 @@ import * as DynamoDBPersistantAttributesAdapter from 'ask-sdk-dynamodb-persisten
import { DialogState } from 'ask-sdk-model';
import MetaService from './service/MetaService';
import AuthService from './service/AuthService';
import TaskService from './service/TaskService';
import { TaskListResponse } from './models/Task';
import AttributeUtils from './AttributeUtils';
const LaunchRequestHandler = {
canHandle(handlerInput: Alexa.HandlerInput) {
@ -55,6 +58,34 @@ const KidShiftAuthIntentHandler = {
}
};
const KidShiftTaskListIntentHandler = {
canHandle(handlerInput: Alexa.HandlerInput) {
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
&& Alexa.getIntentName(handlerInput.requestEnvelope) === 'KidShiftTaskListIntent';
},
async handle(handlerInput: Alexa.HandlerInput) {
const attributeUtils = new AttributeUtils(handlerInput);
TaskService.setToken(await attributeUtils.getToken());
const taskList: TaskListResponse = await TaskService.getTasks();
return handlerInput.responseBuilder
.speak(taskList.list.map((task) => task.name).join(', '))
.getResponse();
}
};
const KidShiftTaskCompleteIntentHandler = {
canHandle(handlerInput: Alexa.HandlerInput) {
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
&& Alexa.getIntentName(handlerInput.requestEnvelope) === 'KidShiftTaskCompleteIntent';
},
async handle(handlerInput: Alexa.HandlerInput) {
return handlerInput.responseBuilder // Placeholder
.speak('WIP')
.getResponse();
}
};
const KidShiftMetaIntentHandler = {
canHandle(handlerInput: Alexa.HandlerInput) {
@ -164,6 +195,8 @@ exports.handler = Alexa.SkillBuilders.custom()
LaunchRequestHandler,
HelloWorldIntentHandler,
KidShiftAuthIntentHandler,
KidShiftTaskListIntentHandler,
KidShiftTaskCompleteIntentHandler,
KidShiftMetaIntentHandler,
HelpIntentHandler,
CancelAndStopIntentHandler,