feat(smartcard): Add get ev battery level integration

This commit is contained in:
Faruk AYDIN
2023-09-19 18:09:11 +02:00
parent 2f0125e871
commit ba17cde59b
3 changed files with 40 additions and 2 deletions

View File

@@ -0,0 +1,36 @@
import defineAction from '../../../../helpers/define-action';
export default defineAction({
name: 'Get EV Battery Level',
key: 'getEvBatteryLevel',
description: 'Get the battery level of an electric vehicle.',
arguments: [
{
label: 'Vehicle',
key: 'vehicle',
type: 'dropdown' as const,
required: true,
description: 'The vehicle to get the location of.',
variables: true,
source: {
type: 'query',
name: 'getDynamicData',
arguments: [
{
name: 'key',
value: 'listVehicles',
},
],
},
},
],
async run($) {
const { vehicle } = $.step.parameters;
const response = await $.http.get(
`/vehicles/${vehicle}/battery?mode=simulated`
);
$.setActionItem({ raw: response.data });
},
});

View File

@@ -1,3 +1,4 @@
import getVehicleLocation from './get-vehicle-location'; import getVehicleLocation from './get-vehicle-location';
import getEvBatteryLevel from './get-ev-battery-level';
export default [getVehicleLocation]; export default [getVehicleLocation, getEvBatteryLevel];

View File

@@ -4,8 +4,9 @@ import { URLSearchParams } from 'url';
export default async function generateAuthUrl($: IGlobalVariable) { export default async function generateAuthUrl($: IGlobalVariable) {
const scopes = [ const scopes = [
'read_odometer', 'read_odometer',
'read_vehicle_info', 'required:read_vehicle_info',
'required:read_location', 'required:read_location',
'required:read_battery',
]; ];
const oauthRedirectUrlField = $.app.auth.fields.find( const oauthRedirectUrlField = $.app.auth.fields.find(