Ejemplo n.º 1
0
function processRequest()
{
    @header('Content-type: application/json');
    $action = getRequestParameter("action");
    $token = getRequestParameter("token");
    if ($action == 'getAllDemos') {
        $maxItems = getRequestParameter("maxItems");
        $userEmail = getRequestParameter("userEmail");
        logUsage($action, "", $maxItems, $userEmail);
        echo json_encode(getAllConfigsFromDatabase($userEmail, $maxItems));
    } else {
        if ($action == 'getStandardDemos') {
            logUsage($action, "", "", "");
            echo json_encode(getDefaultConfigsFromDatabase());
        } else {
            if ($action == 'saveConfig') {
                $config = getRequestParameter("config");
                $savedConfig = saveConfig(json_decode($config));
                logUsage($action, "", $savedConfig->token, $config);
                echo json_encode($savedConfig);
            } else {
                if ($action == 'copyConfig') {
                    // copy token config to a new token
                    // copy website...
                    $newToken = copyConfig($token);
                    logUsage($action, "", $newToken, "");
                    echo json_encode($newToken);
                } else {
                    if ($action == 'getConfig') {
                        logUsage($action, "", $token, "");
                        echo json_encode(getConfig($token));
                    } else {
                        // display how to use service.
                        $endpointVariables = array("Name" => "token", "Type" => "String", "Mandatory" => false);
                        $serviceEndpoints = array(array("Name" => "Reset Demo", "Description" => "....", "Endpoint" => "/api?action=resetDemo&token=...", "Variables" => $endpointVariables), array("Name" => "Get Configuration", "Description" => "....", "Endpoint" => "/api?action=getConfig[&token=...]"), array("Name" => "Save Configuration", "Description" => "....", "Endpoint" => "/api?action=saveConfig&config=..."), array("Name" => "Get Offers", "Description" => "....", "Endpoint" => "/api?action=getOffers&customer=...&maxOffer=...&token=..."), array("Name" => "Respond to Offer", "Description" => "....", "Endpoint" => "/api?action=respondToOffer&offer=...&customer=...&token=..."), array("Name" => "Get History", "Description" => "....", "Endpoint" => "/api?action=getHistory&customer=...&token=..."));
                        $serviceEndpointDesc = array("Service Endpoints" => $serviceEndpoints);
                        echo json_encode($serviceEndpointDesc);
                    }
                }
            }
        }
    }
    // log usage
    return;
}
Ejemplo n.º 2
0
function process($action, $param)
{
    if ($action == 'reset') {
        session_destroy();
        header('Location:' . $_SERVER['PHP_SELF']);
        return true;
    } else {
        if ($action == 'saveScenario') {
            @header('Content-type: application/json');
            @logUsage("DEMO_SAVE", $param, "", "");
            return true;
        } else {
            @header('Content-type: application/json');
            @logUsage("DEMO_LOADING", $param, "", "");
            return true;
        }
    }
}
Ejemplo n.º 3
0
function processRequest()
{
    @header('Content-type: application/json');
    $action = getRequestParameter("action");
    $token = getRequestParameter("token");
    if ($action == 'getAllDemos') {
        $maxItems = getRequestParameter("maxItems");
        $userEmail = getRequestParameter("userEmail");
        logUsage($action, "", $maxItems, $userEmail);
        echo json_encode(getAllConfigsFromDatabase($userEmail, $maxItems));
    } else {
        if ($action == 'getStandardDemos') {
            logUsage($action, "", "", "");
            echo json_encode(getDefaultConfigsFromDatabase());
        } else {
            if ($action == 'resetDemo') {
                resetDemo($token);
                logUsage($action, "", $token, "");
            } else {
                if ($action == 'saveConfig') {
                    $config = getRequestParameter("config");
                    $savedConfig = saveConfig(json_decode($config));
                    logUsage($action, "", $savedConfig->token, $config);
                    echo json_encode($savedConfig);
                } else {
                    if ($action == 'copyConfig') {
                        // copy token config to a new token
                        // copy website...
                        $newToken = copyConfig($token);
                        logUsage($action, "", $newToken, "");
                        echo json_encode($newToken);
                    } else {
                        if ($action == 'getOffers') {
                            $customer = getRequestParameter("customer");
                            $channel = getRequestParameter("channel");
                            $list_size = getRequestParameter("maxOffers");
                            $do_not_track = getRequestParameter("DoNotTrack");
                            logUsage($action, "", $token, $channel);
                            echo json_encode(getOffers($token, $customer, $channel, $list_size, $do_not_track));
                        } else {
                            if ($action == 'changeAnalyticsScore') {
                                $customer = getRequestParameter("customer");
                                $scoreIndex = getRequestParameter("scoreIndex");
                                $scoreValue = getRequestParameter("scoreValue");
                                echo json_encode(changeAnalyticsScore($token, $customer, $scoreIndex, $scoreValue));
                            } else {
                                if ($action == 'respondToOffer') {
                                    $customer = getRequestParameter("customer");
                                    $offerCd = getRequestParameter("offer");
                                    $responseCd = getRequestParameter("response");
                                    $channelCd = getRequestParameter("channel");
                                    $details = getRequestParameter("details");
                                    logUsage($action, "", $token, $channelCd);
                                    echo json_encode(respondToOffer($token, $customer, $offerCd, $responseCd, $channelCd, $details));
                                } else {
                                    if ($action == 'getHistory') {
                                        $customer = getRequestParameter("customer");
                                        logUsage($action, "", $token, $customer);
                                        echo json_encode(getCustomerHistory($token, $customer));
                                    } else {
                                        if ($action == 'getConfig') {
                                            logUsage($action, "", $token, "");
                                            echo json_encode(getConfig($token));
                                        } else {
                                            // display how to use service.
                                            $endpointVariables = array("Name" => "token", "Type" => "String", "Mandatory" => false);
                                            $serviceEndpoints = array(array("Name" => "Reset Demo", "Description" => "....", "Endpoint" => "/api?action=resetDemo&token=...", "Variables" => $endpointVariables), array("Name" => "Get Configuration", "Description" => "....", "Endpoint" => "/api?action=getConfig[&token=...]"), array("Name" => "Save Configuration", "Description" => "....", "Endpoint" => "/api?action=saveConfig&config=..."), array("Name" => "Get Offers", "Description" => "....", "Endpoint" => "/api?action=getOffers&customer=...&maxOffer=...&token=..."), array("Name" => "Respond to Offer", "Description" => "....", "Endpoint" => "/api?action=respondToOffer&offer=...&customer=...&token=..."), array("Name" => "Get History", "Description" => "....", "Endpoint" => "/api?action=getHistory&customer=...&token=..."));
                                            $serviceEndpointDesc = array("Service Endpoints" => $serviceEndpoints);
                                            echo json_encode($serviceEndpointDesc);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    // log usage
    return;
}