Util::getTemplate('index.php'); return; } //ensure user submitted credentials if (!isset($_POST['email'], $_POST['password'])) { Util::getTemplate('login.php'); return; } //add credentials to session Auth::authenticate($_POST['email'], $_POST['password']); //test credentials $lsm = new LsmCurl(false); //force debug mode off $lsm->setEndpoint(LSM_API_ENDPOINT . "authenticate/customer"); //change to /authenticate, or /authenticate/customer accordingly $lsm->useGet(); //send the request $lsm->sendRequest(); $status = (int) $lsm->getResponseStatus(); $response = $lsm->getResponseContent(); if (!$response) { Auth::destroySession(); Auth::startSession(); Util::getTemplate('500.php'); return; } if ($status < 200 || $status > 204 || @(!$response->isSuccess)) { //error validating Auth::destroySession(); Auth::startSession(); // if( DEBUG_API_CALLS )
} //force a search query if (!isset($_REQUEST['q']) || empty($_REQUEST['q'])) { Util::getTemplate('index.php'); return; } //ensure the user has verfied they want to ship the order if (!isset($_REQUEST['verified']) || (int) $_REQUEST['verified'] != 1) { Util::getTemplate('order.detail.php'); return; } //first get an order representation $orderRepEntry = LSM_API_ENDPOINT . "order/" . $_REQUEST['q']; $orderRepLsm = new LsmCurl(); $orderRepLsm->setEndpoint($orderRepEntry); $orderRepLsm->useGet(); $orderRepLsm->sendRequest(); $order = $orderRepLsm->getResponseContent(); if (!$order || (int) $orderRepLsm->getResponseStatus() != 200) { Util::getTemplate('500.php'); return; } //update the tracking number $order->trackingNumber = "1z555555555"; //parse entry if (isset($_REQUEST['entry'])) { $entry = ApiLinks::decodeHateoasLink($_REQUEST['entry']); } else { $entry = LSM_API_ENDPOINT . "order/ship"; } //ensure we have a request to create
$entry = LSM_API_ENDPOINT . "order/" . $_REQUEST['q']; } $lsm = new LsmCurl(); $lsm->setEndpoint($entry); $lsm->useGet(); $lsm->sendRequest(); $order = $lsm->getResponseContent(); if (!$order || (int) $lsm->getResponseStatus() != 200) { Util::getTemplate('500.php'); return; } //get product details $productEntry = LSM_API_ENDPOINT . "product-by-id/" . $order->productID; $productLsm = new LsmCurl(); $productLsm->setEndpoint($productEntry); $productLsm->useGet(); $productLsm->sendRequest(); $product = $productLsm->getResponseContent(); if (!$product || (int) $productLsm->getResponseStatus() != 200) { Util::getTemplate('500.php'); return; } Util::getHeader(); if (DEBUG_API_CALLS) { echo "<pre class='debug'>"; var_dump($order); echo "</pre>"; echo "<pre class='debug'>"; var_dump($product); echo "</pre>"; }