Skip to content

Commit

Permalink
Lint Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
raphckrman committed Apr 3, 2024
1 parent af547b8 commit f784b7d
Show file tree
Hide file tree
Showing 33 changed files with 1,168 additions and 1,168 deletions.
38 changes: 19 additions & 19 deletions lib/api/balanceGet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@ import { GET_HOST_BALANCE } from "../utils/endpoints";
import { TurboselfFetcher } from "../utils/fetcher";

export const getBalance = async (token: string, id: number): Promise<Balance> => {
const response = await TurboselfFetcher("https://api-rest-prod.incb.fr" + GET_HOST_BALANCE(id), {
method: "GET",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer " + token
}
});

const raw = await response.json() as Array<BalanceGetResult>
const estimatedAt: Date = new Date();
estimatedAt.setFullYear(parseInt(raw[0].montantEstimeMsg.replace("Montant estimé au ", "").split("/")[2]))
estimatedAt.setMonth(parseInt(raw[0].montantEstimeMsg.replace("Montant estimé au ", "").split("/")[1])-1)
estimatedAt.setDate(parseInt(raw[0].montantEstimeMsg.replace("Montant estimé au ", "").split("/")[0]))
estimatedAt.setHours(12)
estimatedAt.setMinutes(0)
estimatedAt.setSeconds(0)
estimatedAt.setMilliseconds(0)
const response = await TurboselfFetcher("https://api-rest-prod.incb.fr" + GET_HOST_BALANCE(id), {
method: "GET",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer " + token
}
});

return new Balance(token, id, raw[0].montant, raw[0].montantEstime, estimatedAt);
}
const raw = await response.json() as Array<BalanceGetResult>;
const estimatedAt: Date = new Date();
estimatedAt.setFullYear(parseInt(raw[0].montantEstimeMsg.replace("Montant estimé au ", "").split("/")[2]));
estimatedAt.setMonth(parseInt(raw[0].montantEstimeMsg.replace("Montant estimé au ", "").split("/")[1])-1);
estimatedAt.setDate(parseInt(raw[0].montantEstimeMsg.replace("Montant estimé au ", "").split("/")[0]));
estimatedAt.setHours(12);
estimatedAt.setMinutes(0);
estimatedAt.setSeconds(0);
estimatedAt.setMilliseconds(0);

return new Balance(token, id, raw[0].montant, raw[0].montantEstime, estimatedAt);
};
174 changes: 87 additions & 87 deletions lib/api/bookDay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,95 +7,95 @@ import { TurboselfFetcher } from "../utils/fetcher";
import { getWeekNumber } from "../utils/weekNumber";

export const bookMeal = async (token: string, id: number, bookId: string, book: number, bookEvening: number, day: number): Promise<BookedMeal> => {
const response = await TurboselfFetcher("https://api-rest-prod.incb.fr" + PUT_BOOK_MEAL(id), {
method: "PUT",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer " + token
},
body: JSON.stringify({
dayOfWeek: day,
dayReserv: book,
web: {
id: bookId,
},
hasHoteResaSoirActive: bookEvening,
})
});
const response = await TurboselfFetcher("https://api-rest-prod.incb.fr" + PUT_BOOK_MEAL(id), {
method: "PUT",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer " + token
},
body: JSON.stringify({
dayOfWeek: day,
dayReserv: book,
web: {
id: bookId
},
hasHoteResaSoirActive: bookEvening
})
});


const raw = await response.json() as BookMealPut;
const establishment = new Establishment(
raw.web.hote.etab.code2p5,
raw.web.hote.etab.nom,
raw.web.hote.etab.versionTS,
raw.web.hote.etab.id,
raw.web.hote.etab.idTurboself,

raw.web.hote.etab.currencySymbol,
raw.web.hote.etab.configuration?.nbRepasMini ?? 0,
raw.web.hote.etab.configuration?.creanceMini?? 0,
raw.web.hote.etab.configuration?.montantCreditMini?? 0,
const raw = await response.json() as BookMealPut;
const establishment = new Establishment(
raw.web.hote.etab.code2p5,
raw.web.hote.etab.nom,
raw.web.hote.etab.versionTS,
raw.web.hote.etab.id,
raw.web.hote.etab.idTurboself,

raw.web.hote.etab.configuration?.msgAccueil ?? '',
raw.web.hote.etab.currencySymbol,
raw.web.hote.etab.configuration?.nbRepasMini ?? 0,
raw.web.hote.etab.configuration?.creanceMini?? 0,
raw.web.hote.etab.configuration?.montantCreditMini?? 0,

raw.web.hote.etab.desactive,
raw.web.hote.etab.numEtab,
raw.web.hote.etab.pcServeur,
raw.web.hote.etab.configurationsReservation?.map((data) => {
return {
id: data.id,
usage: data.usage,
elecom: data.elecom,
endReservation: data.finReserv
}
}),
{
address1: raw.web.hote.etab.adr1 ?? '',
address2: raw.web.hote.etab.adr2 ?? '',
zipCode: raw.web.hote.etab.cp ?? '',
city: raw.web.hote.etab.ville ?? ''
},
{
phoneNumber: raw.web.hote.etab.tel ?? '',
website: raw.web.hote.etab.configuration?.url ?? '',
email: raw.web.hote.etab.configuration?.email ?? ''
},
{
canStudentUseQrCode: raw.web.hote.etab.configuration?.autoriseQrCodeEleve?? false,
canCompanionUseQrCode: raw.web.hote.etab.configuration?.autoriseQrCodeCommensal?? false,
canInternUseQrCode: raw.web.hote.etab.configuration?.autoriseQrCodeStagiaire?? false,
canStudentSeeHistory: raw.web.hote.etab.configuration?.cacherHistorique?? false
},
{
firstSync: raw.web.hote.etab.datePremSynchro ?? '',
lastSync: raw.web.hote.etab.dateDernSynchro ?? '',
lastSelfSync: raw.web.hote.etab.configurationSelf?.dateDernSynchro ?? ''
}
);
const host = new Host(
raw.web.hote.id,
raw.web.hote.prenom,
raw.web.hote.nom,
raw.web.hote.qualite,
raw.web.hote.division,
raw.web.hote.prixDej,
establishment,
undefined,
{
lastSync: raw.web.hote.dateDernSynchro ?? ''
},
raw.web.hote.carteCodee ?? -1,
token
)
raw.web.hote.etab.configuration?.msgAccueil ?? "",

return new BookedMeal(
raw.id,
raw.dayReserv === 0 ? false : true,
raw.reservHorsKiosk === 0 ? false : true,
raw.reservDernSynchro === 0? false : true,
raw.rsvwebid,
raw.msg,
host
);
}
raw.web.hote.etab.desactive,
raw.web.hote.etab.numEtab,
raw.web.hote.etab.pcServeur,
raw.web.hote.etab.configurationsReservation?.map((data) => {
return {
id: data.id,
usage: data.usage,
elecom: data.elecom,
endReservation: data.finReserv
};
}),
{
address1: raw.web.hote.etab.adr1 ?? "",
address2: raw.web.hote.etab.adr2 ?? "",
zipCode: raw.web.hote.etab.cp ?? "",
city: raw.web.hote.etab.ville ?? ""
},
{
phoneNumber: raw.web.hote.etab.tel ?? "",
website: raw.web.hote.etab.configuration?.url ?? "",
email: raw.web.hote.etab.configuration?.email ?? ""
},
{
canStudentUseQrCode: raw.web.hote.etab.configuration?.autoriseQrCodeEleve?? false,
canCompanionUseQrCode: raw.web.hote.etab.configuration?.autoriseQrCodeCommensal?? false,
canInternUseQrCode: raw.web.hote.etab.configuration?.autoriseQrCodeStagiaire?? false,
canStudentSeeHistory: raw.web.hote.etab.configuration?.cacherHistorique?? false
},
{
firstSync: raw.web.hote.etab.datePremSynchro ?? "",
lastSync: raw.web.hote.etab.dateDernSynchro ?? "",
lastSelfSync: raw.web.hote.etab.configurationSelf?.dateDernSynchro ?? ""
}
);
const host = new Host(
raw.web.hote.id,
raw.web.hote.prenom,
raw.web.hote.nom,
raw.web.hote.qualite,
raw.web.hote.division,
raw.web.hote.prixDej,
establishment,
undefined,
{
lastSync: raw.web.hote.dateDernSynchro ?? ""
},
raw.web.hote.carteCodee ?? -1,
token
);

return new BookedMeal(
raw.id,
raw.dayReserv === 0 ? false : true,
raw.reservHorsKiosk === 0 ? false : true,
raw.reservDernSynchro === 0? false : true,
raw.rsvwebid,
raw.msg,
host
);
};
112 changes: 56 additions & 56 deletions lib/api/bookingGet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,68 +8,68 @@ import { GET_BOOKING_WEEK } from "../utils/endpoints";
import { TurboselfFetcher } from "../utils/fetcher";

export const getBookingWeek = async (token: string, id: number, weekNumber?: number): Promise<BookingWeek> => {
if (!weekNumber) {
weekNumber = getWeekNumber(new Date());
if (!weekNumber) {
weekNumber = getWeekNumber(new Date());
}

const response = await TurboselfFetcher("https://api-rest-prod.incb.fr" + GET_BOOKING_WEEK(id, weekNumber ?? 0), {
method: "GET",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer " + token
}
});

const response = await TurboselfFetcher("https://api-rest-prod.incb.fr" + GET_BOOKING_WEEK(id, weekNumber ?? 0), {
method: "GET",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer " + token
}
const raw = await response.json() as BookingWeekGetResult;
const weekDate = new Date(raw.dateSemaine);
const terminals = await Promise.all(raw.rsvWebDto.map(async (terminal) => {
let prices = terminal.borne.prix.map((price) => {
return new BookingPrice(
price.id,
price.borneId,
price.prix
);
});

const raw = await response.json() as BookingWeekGetResult;
const weekDate = new Date(raw.dateSemaine);
const terminals = await Promise.all(raw.rsvWebDto.map(async (terminal) => {
let prices = terminal.borne.prix.map((price) => {
return new BookingPrice(
price.id,
price.borneId,
price.prix
);
});

let days = await Promise.all(terminal.jours.map(async (day) => {
let month = weekDate.getMonth();
let dayNumber = parseInt(day.dayLabel.split(' ')[1])+1;
let firstDayOfWeek = parseInt(terminal.jours[0].dayLabel.split(' ')[1]);
let days = await Promise.all(terminal.jours.map(async (day) => {
let month = weekDate.getMonth();
let dayNumber = parseInt(day.dayLabel.split(" ")[1])+1;
let firstDayOfWeek = parseInt(terminal.jours[0].dayLabel.split(" ")[1]);

if (firstDayOfWeek > dayNumber) {
month = month+1
}
let date = new Date(weekDate.getFullYear(), month, dayNumber);
if (firstDayOfWeek > dayNumber) {
month = month+1;
}
let date = new Date(weekDate.getFullYear(), month, dayNumber);

return new BookingDay(
token,
id,
terminal.id,
day.dayReserv === 0 ? false : true,
day.reservDernSynchro === 0 ? false : true,
day.autorise,
day.msg ?? null,
date
);
}));
return new BookingTerminal(
terminal.borne.id,
terminal.id,
terminal.annee,
terminal.semaine,

terminal.borne.lib,
terminal.joursAutorises,
terminal.usage,
prices,
days
)
return new BookingDay(
token,
id,
terminal.id,
day.dayReserv === 0 ? false : true,
day.reservDernSynchro === 0 ? false : true,
day.autorise,
day.msg ?? null,
date
);
}));
return new BookingTerminal(
terminal.borne.id,
terminal.id,
terminal.annee,
terminal.semaine,

return new BookingWeek(
terminals,
raw.numSemaines,
raw.isResaSoirActive,
weekDate
terminal.borne.lib,
terminal.joursAutorises,
terminal.usage,
prices,
days
);
}
}));

return new BookingWeek(
terminals,
raw.numSemaines,
raw.isResaSoirActive,
weekDate
);
};
20 changes: 10 additions & 10 deletions lib/api/canBookEveningGet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import { GET_HOST_CAN_BOOK_EVENING } from "../utils/endpoints";
import { TurboselfFetcher } from "../utils/fetcher";

export const getCanBookEvening = async (token: string, id: number): Promise<boolean> => {
const response = await TurboselfFetcher("https://api-rest-prod.incb.fr" + GET_HOST_CAN_BOOK_EVENING(id), {
method: "GET",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer " + token
}
});
const response = await TurboselfFetcher("https://api-rest-prod.incb.fr" + GET_HOST_CAN_BOOK_EVENING(id), {
method: "GET",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer " + token
}
});

const raw = await response.json() as boolean;
return raw;
}
const raw = await response.json() as boolean;
return raw;
};
Loading

0 comments on commit f784b7d

Please sign in to comment.