PHP code example of totov / laravel-cap-hpi

1. Go to this page and download the library: Download totov/laravel-cap-hpi 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/ */

    

totov / laravel-cap-hpi example snippets


return [
    'client_id' => env('CAP_CLIENT_ID', 'null'),
    'secret' => env('CAP_SECRET', 'null'),
];

use Totov\Cap\Cap;
use Totov\Cap\Subsets\CurrentValuations\CurrentValuationOptions;
use Totov\Cap\Subsets\FutureValuations\FutureValuationOptions;
use Totov\Cap\Subsets\FullVehicleData\Options;

// Initialise cap with client ID and secret
$clientId = config('cap.client_id');
$secret = config('cap.secret');
$cap = new Cap($clientId, $secret);

// Or grab from the container which automatically grabs the config and creates a singleton
$cap = app(Cap::class);

// Get current API version and status
$version = $cap->version();
$status = Cap::status();

// Get full vehicle data by VRM
$currentPoints = new CurrentValuationOptions(['TradeClean'], [['mileage' => 20000]]);
$futurePoints = new FutureValuationOptions(['TradeClean'], [['mileage' => 25000, 'valuationDate' => '2021-09-19']]);
$options = new Options($currentPoints, $futurePoints);

$cap->fullVehicleData->byVrm('AB12CDE', $options);

// Look up current valuation by VRM
$options = new CurrentValuationOptions(['TradeClean'], [['mileage' => 20000]]);
$cap->currentValuations->byVrm('AB12CDE', $options);

// Look up equipment by VRM
$cap->equipment->byVrm('AB12CDE');

// Look up derivative details by VRM
$cap->derivativeDetails->byVrm('AB12CDE');

// Get vehicle details by VRM
$cap->vehicleDetails->byVrm('AB12CDE');

// Get vehicle SMMT data by VRM
$cap->smmtData->byVrm('AB12CDE');

// Get previous keepers of vehicle by VRM
$cap->vehicleKeepers->byVrm('AB12CDE');

// Look up DVLA data for vehicle by VRM
$cap->dvlaData->byVrm('AB12CDE');

// Perform flag check lookup by VRM
$cap->checkFlags->byVrm('AB12CDE');

// Get future valuation for vehicle by VRM
$options = new FutureValuationOptions(['TradeClean'], [['mileage' => 25000, 'valuationDate' => '2021-09-19']]);
$cap->futureValuations->byVrm('AB12CDE', $options);

// Get derivative image for vehicle by VRM
$response = $cap->derivativeImages->byVrm('AB12CDE');
if ($response->ok()) {
    $imageContent = $response->body();
    // ...
}

// Get latest MOT details for vehicle by VRM
$cap->motHistory->byVrm('AB12CDE', true);

// Or all MOT history for vehicle by VRM
$cap->motHistory->byVrm('AB12CDE');

// Get brands info
$cap->derivativeHierarchy->brands->byDerivativeType('cars');
$cap->derivativeHierarchy->brands->byDerivativeTypeAndBrandId('cars', 25545);

// Get ranges info
$cap->derivativeHierarchy->ranges->byDerivativeTypeAndBrandId('cars', 25545);
$cap->derivativeHierarchy->ranges->byDerivativeTypeAndRangeId('cars', 89);

// Get model info
$cap->derivativeHierarchy->models->byDerivativeTypeAndBrandId('cars', 25545);
$cap->derivativeHierarchy->models->byDerivativeTypeAndRangeId('cars', 89);
$cap->derivativeHierarchy->models->byDerivativeTypeAndModelId('cars', 25547);

// Get trim info
$cap->derivativeHierarchy->trims->byDerivativeTypeAndModelId('cars', 25547);

// Get derivatives
$cap->derivativeHierarchy->derivatives->byDerivativeTypeAndModelId('cars', 25547);
$cap->derivativeHierarchy->derivatives->byDerivativeTypeAndTrimId('cars', 10619);

// Get technical spec categories
$cap->technicalSpecification->categories->byDerivativeType('cars');
$cap->technicalSpecification->categories->byDerivativeTypeAndCategoryId('cars', 8);

// Get technical specs for vehicle by VRM
$cap->technicalSpecification->byVrm('AB12CDE');

// Get technical specs for vehicle by VRM with filter on returned items (category IDs and item IDs)
$cap->technicalSpecification->byVrm('AB12CDE', [6, 7], [33, 34, 24]);
bash
php artisan vendor:publish --provider="Totov\Cap\CapServiceProvider" --tag="laravel-cap-hpi-config"