Ejemplo n.º 1
0
//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
$lsm = new LsmCurl();
$lsm->setEndpoint($entry);
$lsm->usePost();
//send the request
$lsm->setParameters($order);
$lsm->sendRequest();
$response = $lsm->getResponseContent();
$status = (int) $lsm->getResponseStatus();
if (!$response || $status < 200 || $status > 204 || @(!$response->isSuccess)) {
    Util::getTemplate('500.php');
    return;
Ejemplo n.º 2
0
/**
 * @todo
 * This template is used for viewing a product review
 */
if (!Auth::isAuthenticated()) {
    Util::getTemplate('login.php');
    return;
}
//ensure we know what we're creating a review for
if (!isset($_REQUEST['q'], $_REQUEST['entry']) || empty($_REQUEST['q']) || empty($_REQUEST['entry'])) {
    Util::getTemplate('products.search.php');
    return;
}
$lsm = new LsmCurl();
$lsm->setEndpoint(ApiLinks::decodeHateoasLink($_REQUEST['entry']));
$lsm->useGet();
$lsm->sendRequest();
$reviews = $lsm->getResponseContent();
if ((int) $lsm->getResponseStatus() != 200) {
    Util::getTemplate('500.php');
    return;
}
Util::getHeader();
if (DEBUG_API_CALLS) {
    echo "<pre class='debug'>";
    var_dump($reviews);
    echo "</pre>";
}
?>