1. Go to this page and download the library: Download andreani/sdk-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
andreani / sdk-php example snippets
use Andreani\Andreani;
use Andreani\Requests\CotizarEnvio;
// Los siguientes datos son de prueba, para la implementación en un entorno productivo deberán reemplazarse por los verdaderos
$request = new CotizarEnvio();
$request->setCodigoDeCliente('CL0003750');
$request->setNumeroDeContrato('400006709');
$request->setCodigoPostal('1014');
$request->setPeso(500);
$request->setVolumen(100);
$request->setValorDeclarado(100);
$andreani = new Andreani('eCommerce_Integra','passw0rd','test');
$response = $andreani->call($request);
if($response->isValid()){
$tarifa = $response->getMessage()->CotizarEnvioResult->Tarifa;
echo "La cotización funcionó bien y la tarifa es $tarifa";
} else {
echo "La cotización falló, el mensaje de error es el siguiente";
var_dump($response->getMessage());
}
namespace MiApp\Requests;
use Andreani\Resources\WebserviceRequest;
class MiRequest implements WebserviceRequest{
protected $dato;
public function setDato($dato){
$this->dato = $dato;
}
public function getDato(){
return $this->dato;
}
public function getWebserviceIndex() {
return 'mi_request';
}
}
namespace MiApp\Resources;
use Andreani\Resources\WebserviceRequest;
use Andreani\Resources\ArgumentConverter;
class MiArgumentConverter implements ArgumentConverter{
public function getArgumentChain(WebserviceRequest $consulta){
if($consulta->getWebserviceIndex() == 'mi_request') return $this->convertMiRequest($consulta);
}
protected function convertMiRequest(WebserviceRequest $consulta){
$arguments = array(
'Metodo' => array(
'Dato' => $consulta->getDato()
)
);
return $arguments;
}
}
json
"andreani/sdk-php": "dev-master"
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.