<?php

/*
 * ROMAN DIGITAL - Autor: Américo Patetta
 */

set_include_path("../../");
include_once("server/class/Delivery.php");

$jsonParams = file_get_contents('php://input');
$paramObj = json_decode($jsonParams);

if (isset($paramObj->idDelivery)  && isset($paramObj->idTarjeta) && isset($paramObj->token) && $paramObj->token == TOKEN_BRODEVO) {
    
    $delivery = new Delivery($paramObj->idDelivery);
    if(isset($paramObj->pedidos)){
        $response['ack'] = ($delivery->addPedidos($paramObj->pedidos))?0:-1;
    } else {
        $response['ack'] = -2;
    }
} else {
    $response['ack'] = -1;
}

header('Content-Type: application/json; charset=utf-8');
echo json_encode($response);
