Skip to content

Commit

Permalink
fix(vehicle): Fix vehicle status api endpoint (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian authored Oct 25, 2022
1 parent b11545e commit a13dd59
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const vehicles = await user.vehicles();
const vehicleList = []; // Array of vehicles

for (userVehicle of vehicles) // For each user vehicle
vehicleList.push(userVehicle['vin']);
vehicleList.push(userVehicle['VIN']);
```

Now with a **vehicle vin** in hand, use `connectedcar.Vehicle()` to get a Vehicle object
Expand Down
11 changes: 10 additions & 1 deletion src/Api/Api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,21 @@ import {ConnectedCarException} from '../Exceptions/ConnectedCarException';
export class Api {
private headers: {};

constructor(accessToken: string, region: string) {
constructor(accessToken: string, region: string, locale = 'en-US') {
const regions = {
US: '71A3AD0A-CF46-4CCF-B473-FC7FE5BC4592',
CA: '71A3AD0A-CF46-4CCF-B473-FC7FE5BC4592',
EU: '1E8C7794-FF5F-49BC-9596-A1E0C86C5B19',
AU: '5C80A6BB-CF0D-4A30-BDBF-FC804B5C1A98',
};

const countryCode = {
US: 'USA',
CA: 'CAN',
EU: 'EUR',
AU: 'AUS',
};

this.headers = {
'auth-token': accessToken,
Accept: '*/*',
Expand All @@ -23,6 +30,8 @@ export class Api {
'Content-Type': 'application/json',
'Accept-Encoding': 'gzip, deflate, br',
'Application-Id': regions[region],
locale,
countryCode: countryCode[region],
};
}

Expand Down
7 changes: 5 additions & 2 deletions src/User/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ export class User extends Api {
* @returns
*/
public async vehicles(): Promise<AxiosResponse['data']> {
const vehicleData = await this.get(`https://api.mps.ford.com/api/users/vehicles`);
return vehicleData['vehicles']['$values'];
const vehicleData = await this.post(`https://api.mps.ford.com/api/expdashboard/v1/details`, {
dashboardRefreshRequest: 'All',
smsWakeUpVIN: '',
});
return vehicleData['userVehicles']['vehicleDetails'];
}

/**
Expand Down

0 comments on commit a13dd59

Please sign in to comment.