PHP code example of tumainimosha / credit-info

1. Go to this page and download the library: Download tumainimosha/credit-info 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/ */

    

tumainimosha / credit-info example snippets

 
$creditInfoService = new \CreditInfo\CreditInfo();
$details = $creditInfoService->getVehicleReport($registration_number);
 
$creditInfoService = new \CreditInfo\CreditInfo();
$details = $creditInfoService->getDrivingLicenseReport($driving_license_no);
 
$creditInfoService = new \CreditInfo\CreditInfo();
$details = $creditInfoService->getNationalIdReport($national_id);

use CreditInfo\Exceptions\DataNotFoundException;
use CreditInfo\Exceptions\Exception;
use CreditInfo\Exceptions\InvalidReferenceNumberException;
use CreditInfo\Exceptions\TimeoutException;
use CreditInfo\CreditInfo;

...

public function testVehicleInfo() {

    $registration = 't100abc';
    
    $creditInfoService = new CreditInfo();
    try {
        $details = $creditInfoService->getVehicleReport($registration);
    } 
    catch(InvalidReferenceNumberException $ex) {
        // Handle case invalid reference number case
        throw($ex);
    }
    catch(TimeoutException $ex) {
        // Handle case if request timeout
        throw($ex);
    }
    catch(DataNotFoundException $ex) {
        // Handle case if registration number not found
        throw($ex);
    }
    catch(Exception $e) {
        // Handle other API errors
        throw($e);
    }
    
    dd($details);
    
}
...

bash
php artisan vendor:publish --provider="CreditInfo\ServiceProvider" --tag="config"