Search in sources :

Example 1 with FacebookConfirmationMessage

use of co.aurasphere.botmill.fb.model.incoming.FacebookConfirmationMessage in project fb-botmill by BotMill.

the class FbBotMillNetworkController method propagateResponse.

/**
	 * Propagates the response to the registered {@link FbBotMillMonitor}.
	 *
	 * @param response
	 *            the response to propagate.
	 */
private static void propagateResponse(BotMillNetworkResponse response) {
    String output = response.getResponse();
    if (response.isError()) {
        // Parses the error message and logs it.
        FacebookErrorMessage errorMessage = FbBotMillJsonUtils.fromJson(output, FacebookErrorMessage.class);
        FacebookError error = errorMessage.getError();
        logger.error("Error message from Facebook. Message: [{}], Code: [{}], Type: [{}], FbTraceID: [{}].", error.getMessage(), error.getCode(), error.getType(), error.getFbTraceId());
        // Sends the callback to the registered network monitors.
        for (FbBotMillMonitor monitor : registeredMonitors) {
            monitor.onError(errorMessage);
        }
    } else {
        FacebookConfirmationMessage confirmationMessage = FbBotMillJsonUtils.fromJson(output, FacebookConfirmationMessage.class);
        logger.debug("Confirmation from Facebook. Recipient ID: [{}], Message ID: [{}], Result Message: [{}]", confirmationMessage.getRecipientId(), confirmationMessage.getMessageId(), confirmationMessage.getResult());
        // Sends the callback to the registered network monitors.
        for (FbBotMillMonitor monitor : registeredMonitors) {
            monitor.onConfirmation(confirmationMessage);
        }
    }
}
Also used : FacebookConfirmationMessage(co.aurasphere.botmill.fb.model.incoming.FacebookConfirmationMessage) FacebookError(co.aurasphere.botmill.fb.model.incoming.FacebookError) FbBotMillMonitor(co.aurasphere.botmill.fb.support.FbBotMillMonitor) FacebookErrorMessage(co.aurasphere.botmill.fb.model.incoming.FacebookErrorMessage)

Aggregations

FacebookConfirmationMessage (co.aurasphere.botmill.fb.model.incoming.FacebookConfirmationMessage)1 FacebookError (co.aurasphere.botmill.fb.model.incoming.FacebookError)1 FacebookErrorMessage (co.aurasphere.botmill.fb.model.incoming.FacebookErrorMessage)1 FbBotMillMonitor (co.aurasphere.botmill.fb.support.FbBotMillMonitor)1