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

com.sap.cloud.sdk.services.recastai.botresponses.Button Maven / Gradle / Ivy

Go to download

Integration of SAP Conversational AI, aka Recast AI (Beta release, still subject to change - up to discontinuation of module).

There is a newer version: 2.28.0
Show newest version
/*
 * Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved.
 */

package com.sap.cloud.sdk.services.recastai.botresponses;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

import com.google.common.annotations.Beta;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

/**
 * This button extends the slimbutton allowing to set the type to POSTBACK, WEB_URL or PHONE_NUMBER.
 */
@Beta
public class Button extends SlimButton
{
    @SerializedName( "type" )
    @Expose
    private final String type;

    /**
     * A button which offers three different type of actions upon getting clicked.
     * 
     * @param title
     *            The title to be displayed
     * @param value
     *            the value to be handed back when the button is clicked
     * @param type
     *            the button type as a string
     */
    public Button( @Nonnull final String title, @Nonnull final String value, @Nonnull final String type )
    {
        super(title, value);
        this.type = type;
    }

    /**
     * A button which offers three different type of actions upon getting clicked.
     * 
     * @param title
     *            The title to be displayed
     * @param value
     *            the value to be handed back when the button is clicked
     * @param buttonType
     *            one of the three button types as defined by recast and persisted in an enum
     */
    public Button( @Nonnull final String title, @Nonnull final String value, @Nonnull final ButtonType buttonType )
    {
        super(title, value);
        type = buttonType.getTypeValue();
    }

    /**
     * The type of the button as defined through the enums.
     * 
     * @return an enum describing button types
     */
    @Nullable
    public ButtonType getButtonType()
    {
        if( getStringType() == null ) {
            return null;
        }
        return ButtonType.parse(getStringType());
    }

    /**
     * The type of this button as a string.
     * 
     * @return string representation of types as Set by Recast Ai
     */
    @Nullable
    public String getStringType()
    {
        return type;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy