All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.samarth2222.skillA.SkillABuilder Maven / Gradle / Ivy

There is a newer version: 1.0.4
Show newest version
package com.github.samarth2222.skillA;

import java.nio.charset.StandardCharsets;

import org.apache.commons.io.IOUtils;

import com.amazon.ask.model.services.util.JacksonSerializer;
import com.amazon.ask.smapi.model.v1.skill.conversations.Acolade;
import com.amazon.ask.smapi.model.v1.skill.conversations.ResponseTemplate;
import com.amazon.ask.smapi.model.v1.skill.interactionModel.InteractionModelData;

public class SkillABuilder {
    private static final JacksonSerializer ASK_JACKSON_SERIALIZER = new JacksonSerializer();

    public static void main(String[] args) {
        final SkillABuilder skillABuilder = new SkillABuilder();
        try {
            System.out.println("Acolade: " + skillABuilder.vendAcoladeJsonForSkillA());
            System.out.println("\n\nInteraction Model: " + skillABuilder.vendInteractionModelJsonForSkillA());
            System.out.println("\n\nResponse Template: " + skillABuilder.vendResponseTemplateJsonForSkillA());
            System.out.println("\n\nDialog:\n\n" + skillABuilder.vendDialogStringForSkillA());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    // Methods to vend Acolade

    public Acolade vendAcoladeObjectForSkillA() throws Exception {
        return new JacksonSerializer().deserialize(
                ClassLoader.getSystemClassLoader().getResourceAsStream("acolade.json"),
                Acolade.class);
    }

    public String vendAcoladeJsonForSkillA() throws Exception {
        Acolade acolade = vendAcoladeObjectForSkillA();
        return ASK_JACKSON_SERIALIZER.serialize(acolade);
    }

    // Methods to vend Interaction Model

    public InteractionModelData vendInteractionModelObjectForSkillA() throws Exception {
        return new JacksonSerializer().deserialize(
                ClassLoader.getSystemClassLoader().getResourceAsStream("interactionModel.json"),
                InteractionModelData.class);
    }

    public String vendInteractionModelJsonForSkillA() throws Exception {
        InteractionModelData interactionModelData = vendInteractionModelObjectForSkillA();
        return ASK_JACKSON_SERIALIZER.serialize(interactionModelData);
    }

    // Methods to vend Response Template

    public ResponseTemplate vendResponseTemplateObjectForSkillA() throws Exception {
        return new JacksonSerializer().deserialize(
                ClassLoader.getSystemClassLoader().getResourceAsStream("responseTemplate.json"),
                ResponseTemplate.class);
    }

    public String vendResponseTemplateJsonForSkillA() throws Exception {
        ResponseTemplate interactionModelData = vendResponseTemplateObjectForSkillA();
        return ASK_JACKSON_SERIALIZER.serialize(interactionModelData);
    }

    // Methods to vend dialog.acdl

    public String vendDialogStringForSkillA() throws Exception {
        return IOUtils.toString(
                ClassLoader.getSystemClassLoader().getResourceAsStream("dialog.acdl"),
                StandardCharsets.UTF_8);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy