The REST API uses HTTP headers for authorisation
$token="votre_token_ici";
$sirenDeVotreClient="824236988"; // code SIREN de Novalend pour l'exemple
$json='{"sirenClient":"'.$sirenDeVotreClient.'"}';
$crl = curl_init("https://test.novalend.com/api/eligibilities");
$headr = array();
$headr[] = 'Accept: application/json';
$headr[] = 'Content-type: application/json';
$headr[] = 'Authorization: Basic '.$token;
curl_setopt($crl, CURLOPT_HTTPHEADER,$headr);
curl_setopt($crl, CURLOPT_POST,true);
curl_setopt($crl, CURLOPT_RETURNTRANSFER,true);
curl_setopt($crl, CURLOPT_POSTFIELDS, $json);
$curl_response = curl_exec($crl);
curl_close($crl);
$response=json_decode($curl_response,true);
if ($response["code"]==400)
{
echo "Cette valeur n'est pas un code SIREN valide.";
exit();
}
if ($response["isEligible"])
echo "La société ".$response["name"]." est éligible au leasing.";
else
echo "Le résultat de l'analyse financière de la société ".$response["name"]." ne nous permet pas de formuler une offre en ligne.";
L’API REST utilise les en-têtes HTTP pour l’autorisation
$token="votre_token_ici";
$sirenDeVotreClient="542051180"; // Code SIREN de TOTAL SA pour l'exemple
$sirenSupplier="824236988" // Mettre votre SIREN. Ici code SIREN de Novalend pour l'exemple
$json='{
"sirenClient":"'.$sirenDeVotreClient.'",
"sirenSupplier":"'.$sirenSupplier.'",
"equipmentType":1,
"duration":48,
"period":1,
"amount":15000,
"condition":"Neuf",
"intangible":0,
"rebillable":200
}';
$crl = curl_init("https://test.novalend.com/api/quotations");
$headr = array();
$headr[] = 'Accept: application/json';
$headr[] = 'Content-type: application/json';
$headr[] = 'Authorization: Basic '.$token;
curl_setopt($crl, CURLOPT_HTTPHEADER,$headr);
curl_setopt($crl, CURLOPT_POST,true);
curl_setopt($crl, CURLOPT_RETURNTRANSFER,true);
curl_setopt($crl, CURLOPT_POSTFIELDS, $json);
$curl_response = curl_exec($crl);
curl_close($crl);
$response=json_decode($curl_response,true);
if ($response["code"]==400)
{
echo "Bad request, in the response, you will see which field is missing or invalid.";
exit();
}
if ($response["rent"])
echo "Le loyer est de ".$response["rent"]."€";