olsgreen / autotrader-api
此包提供了一种轻松与Auto Trader API交互的方法。
1.7.3
2024-04-17 10:43 UTC
Requires
- php: >=7.4
- ext-fileinfo: *
- ext-json: *
- guzzlehttp/guzzle: ^6.0 || ^7.2
- optimus/onion: ^1.0
- psr/log: ^1.1
- symfony/options-resolver: ^5.0
Requires (Dev)
- mockery/mockery: ^1.3
- phpunit/phpunit: ^9.0
README
此包提供了一种轻松与AutoTrader API交互的方法。
安装
使用composer将客户端添加到您的项目中。
composer require olsgreen/autotrader-api
用法
AutoTrader要求您交换您的密钥和密码以获取访问令牌,然后使用此令牌访问API。
身份验证
// Create an instance of the client to obtain an access token. $api = new \Olsgreen\AutoTrader\Client(); $accessToken = $api->authentication()->getAccessToken('YOUR_KEY', 'YOUR_SECRET'); // once you have your access token you can create client instances like: $api = new \Olsgreen\AutoTrader\Client(['access_token' => $accessToken]);
车辆
此端点用于查找注册在英国的车辆并返回核心车辆数据。
查找基本信息
检索有效英国注册(VRM)的车辆基本信息数据。
$vehicle = $api->vehicles()->lookup('123456', 'HG17XXX'); /* * Will return something similar to the below. * * [ * "vehicle" => [ * "ownershipCondition" => "Used", * "registration" => "HG17XXX", * "vin" => "WMWWG320503CXXXXX", * "make" => "MINI", * "model" => "Convertible", * "generation" => "Convertible (2015 - 2018)", * "derivative" => "1.5 Cooper Convertible 2dr Petrol (s/s) (136 ps)", * "derivativeId" => "5b746c3a24974b8fa1048b0141356a34", * "vehicleType" => "Car", * "trim" => "Cooper", * "bodyType" => "Convertible", * "fuelType" => "Petrol", * "cabType" => null, * "transmissionType" => "Manual", * ... * ], * ], * ] * * For the full response see: * https://developers.autotrader.co.uk/documentation#vehicle-base-information */
扩展查找
您可以通过提供以下一个或多个标志,通过lookup
方法检索VRM的额外数据集
注意: VehicleLookupFlags::VEHICLE_METRICS
& VehicleLookupFlags::VALUATIONS
标志还需要传递当前里程作为最后一个参数,如下所示。
-
VehicleLookupFlags::MOT_TESTS
提供指定车辆的最新MOT测试信息。
-
VehicleLookupFlags::FEATURES
提供指定车辆的常规和可选功能的数组。
-
VehicleLookupFlags::BASIC_VEHICLE_CHECK
提供各种车辆特定来源数据。
-
VehicleLookupFlags::FULL_VEHICLE_CHECK
提供各种车辆特定来源数据。
-
VehicleLookupFlags::VALUATIONS
提供指定车辆的多种Auto Trader估值。
-
VehicleLookupFlags::VEHICLE_METRICS
提供指定车辆的多种Auto Trader估值和车辆指标。
-
VehicleLookupFlags::COMPETITORS
提供一个预构建的URL,允许用户探索市场竞争力。
// For example, to retrieve the MOT & basic vehicle check datasets // we can do the following: use Olsgreen\AutoTrader\Api\Builders\LookupRequestBuilder; $request = LookupRequestBuilder::create() ->setRegistration('EO66XXX') ->setFlags([ VehicleLookupFlags::BASIC_VEHICLE_CHECK, VehicleLookupFlags::VEHICLE_METRICS ]); $vehicle = $api->vehicles()->lookup($request); /* * Will return something similar to the below. * * [ * "vehicle" => [ * "ownershipCondition" => "Used", * "registration" => "EO66XXX", * "vin" => "WMWWG320503CXXXXX", * "make" => "MINI", * "model" => "Convertible", * "generation" => "Convertible (2015 - 2018)", * "derivative" => "1.5 Cooper Convertible 2dr Petrol (s/s) (136 ps)", * "derivativeId" => "5b746c3a24974b8fa1048b0141356a34", * "vehicleType" => "Car", * "trim" => "Cooper", * "bodyType" => "Convertible", * "fuelType" => "Petrol", * "cabType" => null, * "transmissionType" => "Manual", * ... * * "check" => [ * "insuranceWriteoffCategory" => null, * "scrapped" => false, * "stolen" => false, * "imported" => false, * "exported" => false, * "previousOwners" => 1, * "keeperChanges" => [ * [ * "dateOfLastKeeper" => "2020-07-14", * ], * ], * "v5cs" => [ * [ * "issuedDate" => "2017-06-30", * ], * ], * ], * * "motTests" => [ * [ * "completedDate" => "2020-06-26T10:05:59Z", * "expiryDate" => "2021-06-25", * "testResult" => "Passed", * "odometerValue" => 16330, * "odometerUnit" => "Miles", * "motTestNumber" => "444811158817", * "rfrAndComments" => [], * ], * ... * ], * ], * ] * * For the full responses see: * https://developers.autotrader.co.uk/documentation#vehicle-base-information */