tesla-fleet-api
Version:
A library for the [Tesla Fleet API](https://developer.tesla.com/docs/fleet-api), and the third parties services [Teslemetry](https://teslemetry.com/docs/getting-started/api) and [Tessie](https://developer.tessie.com/docs/tesla-api-comparison), which provi
54 lines (53 loc) • 1.68 kB
TypeScript
import Charging from "./charging.js";
import Energy from "./energy.js";
import Partner from "./partner.js";
import User from "./user.js";
import Vehicle from "./vehicle.js";
import { EnergyProduct, ProductsResponse, VehicleProduct } from "./types/products.js";
type Region = "na" | "eu" | "cn";
type Method = "GET" | "POST" | "PUT" | "DELETE";
export type ProductsByType = {
vehicles: VehicleProduct[];
energy_sites: EnergyProduct[];
};
export default class TeslaFleetApi {
server: string | null;
accessToken: string | null;
charging?: Charging;
energy?: Energy;
partner?: Partner;
user?: User;
vehicle?: Vehicle;
debug: boolean;
constructor(options: {
accessToken?: string;
region?: Region;
server?: string;
chargingScope?: boolean;
energyScope?: boolean;
partnerScope?: boolean;
userScope?: boolean;
vehicleScope?: boolean;
debug?: boolean;
});
/**
* Make a request to the Tesla Fleet API.
* @param method
* @param path
* @param params
* @param json
* @returns
*/
_request(method: Method, path: string, params?: Record<string, any> | null, json?: Record<string, any> | null): Promise<any>;
/**
* Returns products mapped to user.
* @returns An array of products including both vehicles and energy sites.
*/
products(): Promise<ProductsResponse>;
/**
* Return Tesla products separated into vehicles and energy_sites
* @returns A dictionary of vehicles and energy sites, each with an array of those products
*/
products_by_type(): Promise<ProductsByType>;
}
export {};