wheely-search
v1.0.1
Published
Wheely Search widget. This widget delivers references to the SearchWidget class, that allows you to create a new stand-alone Wheely Widget. The widget expects certain parameters including your api key.
Downloads
3
Readme
Get started with wheely-search
The widget allows the user to pass a custom user situation and will return a list of model / versions that he could possibly afford. Example widget at: https://codepen.io/rkuyper/full/jQQQpJ/.
##Usage
const wheelySearch = require('wheely-search');
wheelySearch.searchWidget(
{
api : 'api_key',
id: 'target_element',
options : {
tracking : 'GTM-XXXXX', // writes user behaviour to Google Tag Managers DataLayer
height: 'height_of_widget', // leave empty if using wheely default height
width : 'width_of_widget', // leave empty if using wheely default width
style : 'stylesheet_of_choice', // leave empty if using wheely default style
color : 'button_color' // leave empty if using wheely default color
}
}
);
##Cached data Each request is cached inside the global dataLayer namespace. You can search the cached data by listening to 'vehicleSearch' event.
let cachedData = window.dataLayer;
Example of returned search object.
//Returned data
{
"results": [
{
"model": {
"id": 13001,
"name": "458 Spider",
"make": {
"id": 13,
"name": "Ferrari"
}
},
"items": [
{
"id": 1201,
"description": "458 Spider",
"bodyType": {
"id": 1,
"name": "Cabriolet",
"isDeleted": false
},
"cataloguePrice": 302418,
"doorsCount": 2,
"engineType": {
"averageFuelPrice": 1.766,
"name": "Benzine",
"id": 2,
"isDeleted": false
},
"transmissionType": {
"id": 2,
"name": "Automaat",
"isDeleted": false
},
"taxLiabilityType": {
"engineType": {
"averageFuelPrice": 0,
"name": "n.v.t.",
"id": 0,
"isDeleted": true
},
"registrationDate": "2018-01-01T00:00:00",
"engineTypeId": 0,
"tariff": 0.22,
"emissionFrom": 1,
"emissionTo": 999,
"isCalculatedTariff": false
},
"year": 2011,
"monthlyCost": {
"residualValue": 115425,
"installment": 0,
"writeOff": 3037.8968585081111,
"insurance": {
"liabilityInsurance": 51.320666666666661,
"personalLiability": 692.0309375,
"total": 743.35160416666668
},
"fuel": 383.22,
"roadTax": 61,
"maintenanceCost": 421.955709258,
"subTotal": 4264.2041719327781,
"total": 4647.4241719327783
}
},
{
"id": 1200,
"description": "458 Speciale A",
"bodyType": {
"id": 1,
"name": "Cabriolet",
"isDeleted": false
},
"cataloguePrice": 318371,
"doorsCount": 2,
"engineType": {
"averageFuelPrice": 1.766,
"name": "Benzine",
"id": 2,
"isDeleted": false
},
"transmissionType": {
"id": 2,
"name": "Automaat",
"isDeleted": false
},
"taxLiabilityType": {
"engineType": {
"averageFuelPrice": 0,
"name": "n.v.t.",
"id": 0,
"isDeleted": true
},
"registrationDate": "2018-01-01T00:00:00",
"engineTypeId": 0,
"tariff": 0.22,
"emissionFrom": 1,
"emissionTo": 999,
"isCalculatedTariff": false
},
"year": 2015,
"monthlyCost": {
"residualValue": 121500,
"installment": 0,
"writeOff": 3153.9571936902353,
"insurance": {
"liabilityInsurance": 48.22045833333334,
"personalLiability": 728.6059375,
"total": 776.82639583333332
},
"fuel": 383.22,
"roadTax": 54,
"maintenanceCost": 456.495695796,
"subTotal": 4441.2792853195688,
"total": 4824.499285319569
}
}
]
}
]
}