@@ -15,8 +15,8 @@ import { TeslemetryVehicleApi } from "./TeslemetryVehicleApi.js";
1515
1616export class TeslemetryApi {
1717 private root : Teslemetry ;
18- public _vehicles : Record < string , TeslemetryVehicleApi > = { } ;
19- public _energySites : Record < string , TeslemetryEnergyApi > = { } ;
18+ public vehicles : Map < string , TeslemetryVehicleApi > = new Map ( ) ;
19+ public energySites : Map < number , TeslemetryEnergyApi > = new Map ( ) ;
2020 public user : TeslemetryUserApi ;
2121 public charging : TeslemetryChargingApi ;
2222
@@ -31,10 +31,10 @@ export class TeslemetryApi {
3131 * @returns The vehicle API instance for the specified VIN.
3232 */
3333 public getVehicle ( vin : string ) {
34- if ( ! this . _vehicles [ vin ] ) {
35- this . _vehicles [ vin ] = new TeslemetryVehicleApi ( this . root , vin ) ;
34+ if ( ! this . vehicles . has ( vin ) ) {
35+ new TeslemetryVehicleApi ( this . root , vin ) ;
3636 }
37- return this . _vehicles [ vin ] ;
37+ return this . vehicles . get ( vin ) ! ;
3838 }
3939
4040 /**
@@ -43,10 +43,10 @@ export class TeslemetryApi {
4343 * @returns The energy site API instance for the specified ID.
4444 */
4545 public getEnergySite ( id : number ) {
46- if ( ! this . _energySites [ id ] ) {
47- this . _energySites [ id ] = new TeslemetryEnergyApi ( this . root , id ) ;
46+ if ( ! this . energySites . has ( id ) ) {
47+ new TeslemetryEnergyApi ( this . root , id ) ;
4848 }
49- return this . _energySites [ id ] ;
49+ return this . energySites . get ( id ) ! ;
5050 }
5151
5252 /**
@@ -63,10 +63,10 @@ export class TeslemetryApi {
6363 this . getEnergySite ( product . energy_site_id ) ;
6464 }
6565 } ) ;
66- return { vehicles : this . _vehicles , energySites : this . _energySites } ;
66+ return { vehicles : this . vehicles , energySites : this . energySites } ;
6767 }
6868
69- public async fields ( ) {
69+ public async getFields ( ) {
7070 const { data } = await getFieldsJson ( { client : this . root . client } ) ;
7171 return data ;
7272 }
@@ -76,7 +76,7 @@ export class TeslemetryApi {
7676 * @returns A promise that resolves to an object containing a `response` array and count.
7777 * Each item in the array is a product, which can be a vehicle or an energy site, and a `count` of the products.
7878 */
79- public async products ( ) {
79+ public async getProducts ( ) {
8080 const { data } = await getApi1Products ( { client : this . root . client } ) ;
8181 return data ;
8282 }
@@ -95,7 +95,7 @@ export class TeslemetryApi {
9595 * @returns Promise to an object containing metadata about the account,
9696 * including user UID, region, scopes, and lists of vehicles and energy sites.
9797 */
98- public async metadata ( ) {
98+ public async getMetadata ( ) {
9999 const { data } = await getApiMetadata ( { client : this . root . client } ) ;
100100 return data ;
101101 }
@@ -106,7 +106,7 @@ export class TeslemetryApi {
106106 * @returns Promise to an object containing lists of paired and unpaired VINs,
107107 * and detailed info for each vehicle.
108108 */
109- public async fleetStatus ( vins : string [ ] ) {
109+ public async getFleetStatus ( vins : string [ ] ) {
110110 const { data } = await postApi1VehiclesFleetStatus ( {
111111 body : { vins } ,
112112 client : this . root . client ,
@@ -119,7 +119,7 @@ export class TeslemetryApi {
119119 * @returns Promise to an object containing a list of vehicles,
120120 * pagination details, and a total count.
121121 */
122- public async vehicles ( ) {
122+ public async getVehicles ( ) {
123123 const { data } = await getApi1Vehicles ( { client : this . root . client } ) ;
124124 return data ;
125125 }
0 commit comments