Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* MIT License
*
* Copyright (c) 2016 BotMill.io
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package co.aurasphere.botmill.fb.threadsettings;
import java.util.ArrayList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import co.aurasphere.botmill.fb.FbBotDefinition;
import co.aurasphere.botmill.fb.internal.util.network.NetworkUtils;
import co.aurasphere.botmill.fb.model.outcoming.template.button.Button;
import co.aurasphere.botmill.fb.model.outcoming.template.button.BuyButton;
import co.aurasphere.botmill.fb.model.outcoming.template.button.PaymentSummary;
import co.aurasphere.botmill.fb.model.outcoming.template.button.PostbackButton;
import co.aurasphere.botmill.fb.model.outcoming.template.button.WebUrlButton;
import co.aurasphere.botmill.fb.model.threadsettings.CallToActionsRequest;
import co.aurasphere.botmill.fb.model.threadsettings.DomainActionType;
import co.aurasphere.botmill.fb.model.threadsettings.ThreadState;
import co.aurasphere.botmill.fb.model.threadsettings.WhitelistDomainRequest;
import co.aurasphere.botmill.fb.model.threadsettings.greeting.SetGreetingTextRequest;
import co.aurasphere.botmill.fb.model.threadsettings.payment.PaymentDevModeAction;
import co.aurasphere.botmill.fb.model.threadsettings.payment.PaymentSettings;
/**
* Class which handles the configuration of the Facebook Messenger Platform
* Thread Settings (for more informations, see the link below). The methods of
* this class needs to be called only once and thus shouldn't be put on the
* class that implements {@link FbBotDefinition}. The best way of handling the
* configuration would be defining your own class with a main method and put the
* call on it.
*
* @author Donato Rimenti
* @see Facebook's Thread Settings Documentation
*/
public class FbBotMillThreadSettingsConfiguration {
/**
* The logger.
*/
private static final Logger logger = LoggerFactory
.getLogger(FbBotMillThreadSettingsConfiguration.class);
/**
* Instantiates a new FbBotMillThreadSettingsConfiguration.
*/
private FbBotMillThreadSettingsConfiguration() {
}
/**
* This method is used to add any payment settings needed.
*
* @param paymentSettings
* the payment settings object.
* @see Payments settings
*/
public static void addPaymentSettings(PaymentSettings paymentSettings) {
if (paymentSettings == null) {
logger.error("FbBotMill validation error: Payment Settings can't be null or empty!");
return;
}
NetworkUtils.postThreadSetting(paymentSettings);
}
/**
* Sets the greeting message for the bot. The Greeting Text is only rendered
* the first time the user interacts with a the Page on Messenger.
*
* @param message
* the greeting message to show.
* @see Facebook's Greeting Text Documentation
*/
public static void setGreetingMessage(String message) {
if (message == null || message.isEmpty()) {
logger.error("FbBotMill validation error: Greeting message can't be null or empty!");
return;
}
SetGreetingTextRequest request = new SetGreetingTextRequest(message);
NetworkUtils.postThreadSetting(request);
}
/**
* Sets the Get Started Button for the bot. The Get Started button is only
* rendered the first time the user interacts with a the Page on Messenger.
* When this button is tapped, the defined payload will be sent back with a
* postback received callback.
*
* @param payload
* the payload to return when the button is tapped.
* @see Facebook's Get Started Button Documentation
*/
public static void setGetStartedButton(String payload) {
if (payload == null || payload.isEmpty()) {
logger.error("FbBotMill validation error: Get Started Button payload can't be null or empty!");
return;
}
Button button = new PostbackButton(null, null, payload);
List