node-vw-carnet
Version:
Connects to the VW Car-Net via the we-connect portal.
164 lines (163 loc) • 3.91 kB
TypeScript
/**
* The Carnet API client.
*/
export default class CarnetAPIClient {
/**
*
* @param {SessionOptions} options
* @param {typeof defaultLogger?} logger
* @param {((url: RequestInfo, init?: RequestInit) => Promise<Response>)?} http
*/
constructor(options: {
csrfToken: string;
carId: string;
cookies: {
name: string;
value: string;
}[];
}, logger?: any, http?: (url: RequestInfo, init?: RequestInit) => Promise<Response>);
options: {
csrfToken: string;
carId: string;
cookies: {
name: string;
value: string;
}[];
};
carId: string;
logger: any;
fetch: (url: RequestInfo, init?: RequestInit) => Promise<Response>;
/** @type {{ [x: string]: string }} */
headers: {
[x: string]: string;
};
/**
* Get the car location (lat, lon).
*
* @return {Promise<CarnetJSONResponse>}
*/
getLocation(): Promise<{
[x: string]: any;
errorCode: string;
}>;
/**
* Get the fully loaded car info (?).
*
* @return {Promise<CarnetJSONResponse>}
*/
getFullyLoadedCars(): Promise<{
[x: string]: any;
errorCode: string;
}>;
/**
* Get the complete vehicle JSON.
*
* @return {Promise<CarnetJSONResponse>}
*/
getCompleteVehicleJson(): Promise<{
[x: string]: any;
errorCode: string;
}>;
/**
* Load the car details.
*
* @return {Promise<CarnetJSONResponse>}
*/
loadCarDetails(): Promise<{
[x: string]: any;
errorCode: string;
}>;
/**
* Turn on/off electric climate.
*
* @param {boolean} on If `true` start, if `false` stop climate heating.
* @return {Promise<CarnetJSONResponse>}
*/
triggerClimatisation(on: boolean): Promise<{
[x: string]: any;
errorCode: string;
}>;
/**
* Starts the window heating.
* @return {Promise<CarnetJSONResponse>}
*/
triggerWindowheating(): Promise<{
[x: string]: any;
errorCode: string;
}>;
/**
* Get the vehicle details.
* @return {Promise<CarnetJSONResponse>}
*/
getPSPStatus(): Promise<{
[x: string]: any;
errorCode: string;
}>;
/**
* Get the vehicle details.
* @return {Promise<CarnetJSONResponse>}
*/
getVehicleDetails(): Promise<{
[x: string]: any;
errorCode: string;
}>;
/**
* Get the vehicle status data.
* @return {Promise<CarnetJSONResponse>}
*/
getVehicleStatusReport(): Promise<{
[x: string]: any;
errorCode: string;
}>;
/**
* Get latest vehicle report.
* @return {Promise<CarnetJSONResponse>}
*/
getLatestReport(): Promise<{
[x: string]: any;
errorCode: string;
}>;
/**
* Get e-manager info.
* @return {Promise<CarnetJSONResponse>}
*/
getEmanager(): Promise<{
[x: string]: any;
errorCode: string;
}>;
/**
* Get statistics about the latest trip.
* @return {Promise<CarnetJSONResponse>}
*/
getLatestTripStatistics(): Promise<{
[x: string]: any;
errorCode: string;
}>;
/**
* Performs a HTTP POST request to the Carnet API.
*
* @param {string} url
* @param {(string | null)?} body
* @return {Promise<CarnetJSONResponse>}
*/
triggerAction(url: string, body?: string): Promise<{
[x: string]: any;
errorCode: string;
}>;
}
export type CarnetCookie = {
name: string;
value: string;
};
export type SessionOptions = {
csrfToken: string;
carId: string;
cookies: {
name: string;
value: string;
}[];
};
export type CarnetJSONResponse = {
[x: string]: any;
errorCode: string;
};