DVLA 搜索的 SDK

v0.6.0 2017-05-16 19:47 UTC

This package is not auto-updated.

Last update: 2024-09-28 20:03:31 UTC


README

Code Climate Test Coverage Build Status

DVLA 搜索 PHP SDK

DVLASearch API 的 PHP SDK

需求

  • PHP >=7.0.0

安装

composer require dvlasearch/sdk

使用方法

每个请求将返回相关请求的对象,该对象将有方法来请求同一辆车的其他信息。

如果库遇到 API 错误,将抛出异常。

车辆客户端

<?php

use DVLASearch\SDK\Clients\Vehicle;

$client = new Vehicle('API KEY HERE');
$vehicle = $client->get('MT09 VCA');

// $vehicle->error will be set if the number plate isn't attached to a vehicle
if(!isset($vehicle->error)) {
  var_dump($vehicle);
} else {
  var_dump('No vehicle found for ' . $vehicle->plate);
}

成功返回

Vehicle {#348 ▼
  -key: "DvlaSearchDemoAccount"
  +plate: "mt09vca"
  +"make": "SAAB"
  +"dateOfFirstRegistration": "27 July 2009"
  +"yearOfManufacture": "2009"
  +"cylinderCapacity": "1910cc"
  +"co2Emissions": "177 g/km"
  +"fuelType": "DIESEL"
  +"taxStatus": "Tax not due"
  +"colour": "GREY"
  +"typeApproval": "M1"
  +"wheelPlan": "2 AXLE RIGID BODY"
  +"revenueWeight": "Not available"
  +"taxDetails": "Tax due: 01 October 2016"
  +"motDetails": "Expires: 02 October 2016"
  +"taxed": true
  +"mot": true
  +"vin": "YS3FF41W391018057"
  +"model": "9-3 VECTOR S ANNIVERSARY LTD TID"
  +"transmission": "AUTOMATIC"
  +"numberOfDoors": "4"
  +"sixMonthRate": ""
  +"twelveMonthRate": ""
}

错误返回

Vehicle {#348 ▼
  -key: "DvlaSearchDemoAccount"
  +plate: "mt09vca"
  +"message": "No vehicle found"
  +"error": 0
}

方法

mot()

返回该车辆的 MOT 数据

$vehicle->mot();

tyres()

返回该车辆的轮胎数据

$vehicle->tyres();

MOT 客户端

<?php

use DVLASearch\SDK\Clients\Mot;

$client = new Mot('API KEY HERE');
$mot = $client->get('MT09 VCA');

// $vehicle->error will be set if the number plate isn't attached to a vehicle
if(!isset($mot->error)) {
  var_dump($mot);
} else {
  var_dump('No MOT found for ' . $mot->plate);
}

成功返回

Mot {#380 ▼
  -key: "DvlaSearchDemoAccount"
  +plate: "mt09vca"
  +"make": "SAAB"
  +"model": "9-3 VECTOR S ANNIVERSARY LTD TID"
  +"dateFirstUsed": ""
  +"colour": "GREY"
  +"motTestReports": array:5 [▶]
}

错误返回

Mot {#380 ▼
  -key: "DvlaSearchDemoAccount"
  +"plate": "mt09vca"
  +"message": "No vehicle found"
  +"error": 0
}

方法

vehicle()

返回与 MOT 数据相关的车辆

$vehicle->vehicle();

tyres()

返回与 MOT 数据相关的车辆的轮胎数据

$vehicle->tyres();

轮胎客户端

<?php

use DVLASearch\SDK\Clients\Tyres;

$client = new Tyres('API KEY HERE');
$tyres = $client->get('MT09 VCA');

// $vehicle->error will be set if the number plate isn't attached to a vehicle
if(!isset($tyres->error)) {
  var_dump($tyres);
} else {
  var_dump('No MOT found for ' . $tyres->plate);
}

成功返回

Tyres {#381 ▼
  -key: "DvlaSearchDemoAccount"
  +plate: "mt09vca"
  +"make": "SAAB"
  +"model": "9-3 VECTOR S ANNIVERSARY LTD TID"
  +"year": 2009
  +"frontTyres": array:3 [▶]
  +"rearTyres": array:3 [▶]
}

错误返回

Tyres {#381 ▼
  -key: "DvlaSearchDemoAccount"
  +"plate": "mt09vca"
  +"message": "No vehicle found"
  +"error": 0
}

方法

vehicle()

返回与轮胎数据相关的车辆

$tyres->vehicle();

mot()

返回与轮胎数据相关的车辆的 MOT 数据

$tyres->mot();

运行测试

phpunit