/**
* Key mapping for pluto vehicle api call to human readable text
* @module
* @since 0.0.16
*/
/**
* The label/type/unit for each of the values in the pluto vehicle api call
* NOTE: JSDOC IS NOT SHOWING NESTED VALUES
* @constant
* @type {struct}
* @default
*/
const skv_map = {
weights_dimensions: {
kerb_weight_kg: {
label: 'Kerb Weight from',
type: 'integer',
unit: 'kg',
},
gross_vehicle_weight_kg: {
label: 'Gross vehicle weight',
type: 'integer',
unit: 'kg',
},
length_mm: {
label: 'Length',
type: 'integer',
unit: 'mm',
},
width_mm: {
label: 'Width',
type: 'integer',
unit: 'mm',
},
height_mm: {
label: 'Height',
type: 'integer',
unit: 'mm',
},
},
battery: {
weighted_combined_mpg: {
label: 'Weighted combined MPG',
type: 'integer',
},
power_kw: {
label: 'Power',
type: 'integer',
unit: 'kw',
},
charge_kwh: {
label: 'Charge input',
type: 'integer',
unit: 'kw/h',
},
range_miles: {
label: 'Maximum range',
type: 'integer',
unit: 'miles',
},
},
price: {
p11d: {
label: 'P11D',
type: 'currency',
unit: '£',
},
date: {
label: 'date',
type: 'string',
},
base_net: {
label: 'Base net',
type: 'currency',
unit: '£',
},
vat: {
label: 'VAT',
type: 'integer',
unit: '%',
},
delivery_net: {
label: 'Delivery net',
type: 'currency',
unit: '£',
},
otr: {
label: 'On the road price',
type: 'currency',
unit: '£',
},
first_registration_fee: {
label: 'First registration fee',
type: 'currency',
unit: '£',
},
},
ved: {
ved: {
label: 'Vehicle Excise Duty',
type: 'currency',
unit: '£',
},
},
description: {
derivative: {
label: 'Derivative',
type: 'string',
},
transmission: {
label: 'Transmission',
type: 'string',
},
doors: {
label: 'Doors',
type: 'integer',
},
manufacturer_transmission: {
label: 'Manufacturer transmission',
type: 'string',
},
fueltype: {
label: 'Fuel type',
type: 'string',
},
engine: {
label: 'Engine',
type: 'string',
},
grade: {
label: 'Trim',
type: 'string',
},
model: {
label: 'Model',
type: 'string',
},
make: {
label: 'Make',
type: 'string',
},
bodystyle: {
label: 'Body style',
type: 'string',
},
seats: {
label: 'Seats',
type: 'integer',
},
},
emissions: {
wltp_co2_gpkm_tel: {
label: 'CO<sub>2</sub> TEL',
type: 'integer',
unit: 'g/km',
},
wltp_co2_gpkm: {
label: 'CO<sub>2</sub>',
type: 'integer',
unit: 'g/km',
},
wltp_co2_gpkm_teh: {
label: 'CO<sub>2</sub> TEH',
type: 'integer',
unit: 'g/km',
},
particulates: {
label: 'Particules',
type: 'integer',
unit: 'g/km',
},
nox: {
label: 'NO<sub>x</sub>',
type: 'integer',
unit: 'mg/km',
},
nedc_co2_gpkm: {
label: 'CO<sub>2</sub> (NEDC)',
type: 'integer',
unit: 'g/km',
},
hcnox: {
label: 'HCNO<sub>x</sub>',
type: 'integer',
unit: 'mg/km',
},
hc: {
label: 'HC',
type: 'integer',
unit: 'mg/km',
},
co: {
label: 'CO',
type: 'integer',
unit: 'mg/km',
},
euro: {
label: 'Euro standard',
type: 'string',
},
},
safety: {
ncap_child_occupant: {
label: 'NCAP child occupant',
type: 'integer',
},
ncap_safety_assist: {
label: 'NCAP safety assist',
type: 'integer',
},
ncap_adult_occupant: {
label: 'NCAP adult occupant',
type: 'integer',
},
insurance_group_number: {
label: 'Insurance group (1 - 50)',
type: 'integer',
},
ncap_vulnerable_road_users: {
label: 'NCAP vulnerable road users',
type: 'integer',
},
ncap_link: {
label: 'NCAP link',
type: 'string',
},
ncap_stars: {
label: 'NCAP rating',
type: 'integer',
},
ncap_review_year: {
label: 'NCAP review year',
type: 'string',
},
},
tax: {
vehicle_tax_low: {
label: 'Annual company vehicle tax - 20%',
type: 'currency',
unit: '£',
},
vehicle_tax_high: {
label: 'Annual company vehicle tax - 40%',
type: 'currency',
unit: '£',
},
fuel_tax_low: {
label: 'Annual fuel benefit tax - 20%',
type: 'currency',
unit: '£',
},
fuel_tax_high: {
label: 'Annual fuel benefit tax - 40%',
type: 'currency',
unit: '£',
},
},
technical: {
cc: {
label: 'Cubic Centimeters',
type: 'integer',
unit: 'CC',
},
driven_wheels: {
label: 'Drive',
type: 'string',
},
torque_nm: {
label: 'Torque',
type: 'integer',
unit: 'nm',
},
torque_lb: {
label: 'Torque',
type: 'integer',
unit: 'lb ft',
},
cylinders: {
label: 'Cylinders',
type: 'integer',
},
max_speed_mph: {
label: 'Maximum speed',
type: 'integer',
unit: 'mph',
},
acceleration_0_to_60_s: {
label: 'Acceleration 0-60',
type: 'integer',
unit: 'seconds',
},
power_ps: {
label: 'PS',
type: 'integer',
},
power_hp: {
label: 'Horsepower',
type: 'integer',
},
},
economy: {
fuel_tank_range_miles: {
label: 'Fuel range',
type: 'integer',
},
litre_per_100km: {
label: 'Litre per 100km',
type: 'integer',
},
fuel_tank_capacity_litres: {
label: 'Fuel tank capacity',
type: 'integer',
},
mpg_combined_teh: {
label: 'MPG combined (TEH)',
type: 'number',
decimal_places: 1,
},
mpg_combined_tel: {
label: 'MPG combined (TEL)',
type: 'number',
decimal_places: 1,
},
mpg_extra_high_teh: {
label: 'MPG extra high (TEH)',
type: 'number',
decimal_places: 1,
},
mpg_high_teh: {
label: 'MPG high (TEH)',
type: 'number',
decimal_places: 1,
},
mpg_medium_teh: {
label: 'MPG medium (TEH)',
type: 'number',
decimal_places: 1,
},
mpg_low_teh: {
label: 'MPG low (TEL)',
type: 'number',
decimal_places: 1,
},
mpg_high_tel: {
label: 'MPG high (TEL)',
type: 'number',
decimal_places: 1,
},
mpg_medium_tel: {
label: 'MPG medium (TEL)',
type: 'number',
decimal_places: 1,
},
mpg_extra_high_tel: {
label: 'MPG extra high (TEL)',
type: 'number',
decimal_places: 1,
},
mpg_low_tel: {
label: 'MPG low (TEL)',
type: 'number',
decimal_places: 1,
},
},
load_details: {
boot_space_litres: {
label: 'Boot space with seats up',
type: 'integer',
unit: 'm<sup>3</sup>',
},
boot_space_max_litres: {
label: 'Boot space with seats down',
type: 'integer',
unit: 'm<sup>3</sup>',
},
towing_weight_unbraked_kg: {
label: 'Max towing weight - unbraked',
type: 'integer',
unit: 'kg',
},
width_max_mm: {
label: 'Maximum width',
type: 'integer',
unit: 'mm',
},
width_min_mm: {
label: 'Minimum width',
type: 'integer',
unit: 'mm',
},
length_mm: {
label: 'Length',
type: 'integer',
unit: 'mm',
},
width_mm: {
label: 'Width',
type: 'integer',
unit: 'mm',
},
payload_kg: {
label: 'Payload',
type: 'integer',
unit: 'kg',
},
towing_weight_braked_kg: {
label: 'Max towing weight - braked',
type: 'integer',
unit: 'kg',
},
height_mm: {
label: 'Height',
type: 'integer',
unit: 'mm',
},
},
};
/**
* Pass in the category name and its child key to get a struct of human readable
* values
* @param {string} key pluto api object key
* @returns {struct}
*/
const getItem = (str_group_key, str_field_key) => {
let skv_return = {};
// check we have a group to work with
if (Object.prototype.hasOwnProperty.call(skv_map, str_group_key)) {
// get top level struct
const skv_struct = skv_map[str_group_key];
if (Object.prototype.hasOwnProperty.call(skv_struct, str_field_key)) {
skv_return = skv_struct[str_field_key];
}
}
return skv_return;
};
export {
getItem,
};