<?php
    header('Access-Control-Allow-Origin: *'); 
    header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept");

    include "vendor/autoload.php";

    use Stenfrank\UBL21dian\Client;
    use Stenfrank\UBL21dian\ClientProd;
    use Stenfrank\UBL21dian\Templates\SOAP\GetXmlByDocumentKey;
    use Stenfrank\UBL21dian\Templates\SOAP\GetXmlByDocumentKeyProd;

    $certificado = str_replace('\\','/',$_POST['certificado']);
    $password = $_POST['pase'];

    if($_POST['ambiente']==0){
        $GetXmlByDocumentKey = new GetXmlByDocumentKey($certificado,$password);
    }else{
        $GetXmlByDocumentKey = new GetXmlByDocumentKeyProd($certificado,$password);
    }

    $GetXmlByDocumentKey->trackId = $_POST['key'];

    $GetXmlByDocumentKey->sign();

    if($_POST['ambiente']==0){
        $client = new Client($GetXmlByDocumentKey);
    }else{
        $client = new ClientProd($GetXmlByDocumentKey);
    }

    echo $client;
?>