<?php
include_once '../config/header.php';
include_once '../config/helper.php';
include_once '../config/database.php';
include_once '../objects/vecinos_anexos.php';
include_once '../token/validatetoken.php';

$database = new Database();
$db = $database->getConnection();
 
$vecinos_anexos = new Vecinos_Anexos($db);
$data = json_decode(file_get_contents("php://input"));

if(true){
	
    
$vecinos_anexos->rut = $data->rut;
$vecinos_anexos->nombre = $data->nombre;
$vecinos_anexos->apellido = $data->apellido;
$vecinos_anexos->clave_app = $data->clave_app;
$vecinos_anexos->id_vecino = $data->id_vecino;
 	$lastInsertedId=$vecinos_anexos->create();
    if($lastInsertedId!=0){
        http_response_code(201);
        echo json_encode(array("status" => "success", "code" => 1,"message"=> "Created Successfully","document"=> $lastInsertedId));
    }
    else{
        http_response_code(503);
		echo json_encode(array("status" => "error", "code" => 0,"message"=> "Unable to create vecinos_anexos","document"=> ""));
    }
}
else{
    http_response_code(400);
	echo json_encode(array("status" => "error", "code" => 0,"message"=> "Unable to create vecinos_anexos. Data is incomplete.","document"=> ""));
}
?>
