Skip to content

Commit

Permalink
remove useless things
Browse files Browse the repository at this point in the history
  • Loading branch information
raphckrman committed Apr 7, 2024
1 parent 935be30 commit 89889fb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 20 deletions.
10 changes: 3 additions & 7 deletions lib/authenticate/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,9 @@ export const authenticateWithCredentials = async (options: AuthFlowBody): Promis
const raw = await response.json() as AuthFlowResult;

return new Turboself(raw.access_token, {
hoteId: raw.hoteId,
userId: raw.userId,
username: options.username,
password: options.password,
extra: {
userId: raw.userId,
hoteId: raw.hoteId,
username: options.username,
password: options.password
}
password: options.password
});
};
22 changes: 9 additions & 13 deletions lib/client/Turboself.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@ export default class Turboself {
tokenExpires: number = 0;
constructor(
public token: string,
private loginData: {
username: string;
password: string;
extra: AuthFlowData;
}
private loginData: AuthFlowData
) {
this.token = token;
this.tokenExpires = Date.now() + 55 * 60 * 1000;
Expand Down Expand Up @@ -65,7 +61,7 @@ export default class Turboself {
if (Date.now() > this.tokenExpires) {
await this.refreshToken();
}
return await getHost(this.token, this.loginData.extra.hoteId);
return await getHost(this.token, this.loginData.hoteId);
}

/** This method is used to get the balance of a Turboself user.
Expand All @@ -74,7 +70,7 @@ export default class Turboself {
if (Date.now() > this.tokenExpires) {
await this.refreshToken();
}
return await getBalance(this.token, this.loginData.extra.hoteId);
return await getBalance(this.token, this.loginData.hoteId);
}

/** This method is used to get the siblings of a Turboself user.
Expand All @@ -83,7 +79,7 @@ export default class Turboself {
if (Date.now() > this.tokenExpires) {
await this.refreshToken();
}
return await getSiblings(this.token, this.loginData.extra.hoteId);
return await getSiblings(this.token, this.loginData.hoteId);
}

/** This method is used to get the latest payment of a Turboself user.
Expand All @@ -92,7 +88,7 @@ export default class Turboself {
if (Date.now() > this.tokenExpires) {
await this.refreshToken();
}
return await getHistory(this.token, this.loginData.extra.hoteId);
return await getHistory(this.token, this.loginData.hoteId);
}

/** This method is used to get the latest payment of a Turboself user.
Expand All @@ -101,7 +97,7 @@ export default class Turboself {
if (Date.now() > this.tokenExpires) {
await this.refreshToken();
}
return await getLatestPayment(this.token, this.loginData.extra.hoteId);
return await getLatestPayment(this.token, this.loginData.hoteId);
}

/** This method is used to get if the user can book evening.
Expand All @@ -110,7 +106,7 @@ export default class Turboself {
if (Date.now() > this.tokenExpires) {
await this.refreshToken();
}
return await getCanBookEvening(this.token, this.loginData.extra.hoteId);
return await getCanBookEvening(this.token, this.loginData.hoteId);
}

/** This method is used to get a booking week.
Expand All @@ -120,7 +116,7 @@ export default class Turboself {
if (Date.now() > this.tokenExpires) {
await this.refreshToken();
}
return await getBookingWeek(this.token, this.loginData.extra.hoteId, weekNumber);
return await getBookingWeek(this.token, this.loginData.hoteId, weekNumber);
}

/** This method is used to book a meal.
Expand All @@ -135,6 +131,6 @@ export default class Turboself {
}
if (!dayOfWeek) dayOfWeek = ((new Date()).getDay()) - 1;
if (!bookEvening) bookEvening = false;
return await bookMeal(this.token, this.loginData.extra.hoteId, id, book === false ? 0 : 1, bookEvening === false ? 0 : 1, dayOfWeek);
return await bookMeal(this.token, this.loginData.hoteId, id, book === false ? 0 : 1, bookEvening === false ? 0 : 1, dayOfWeek);
}
}

0 comments on commit 89889fb

Please sign in to comment.