Add endpoints for LDBSVWS

This commit is contained in:
Fred Boniface
2023-06-11 21:43:01 +01:00
parent 43fd6db4b9
commit 4916c377c6
4 changed files with 97 additions and 7 deletions

View File

@@ -56,12 +56,15 @@ async function arrDepBoardStaff(CRS) {
const options = {
numRows: 25,
crs: CRS.toUpperCase(),
getNonPassengerServices: true
getNonPassengerServices: true,
time: await getDateTimeString(new Date),
timeWindow: 120
};
const api = new ldb(ldbsvKey,true);
return await api.call('GetArrDepBoardWithDetails', options, false, false);
return await api.call('GetArrivalDepartureBoardByCRS',options,false,false);
} catch (err) {
log.out(`ldbService.arrDepBoardStaff: Lookup Failed for: ${CRS}, "warn`);
log.out(`ldbService.arrDepBoardStaff: Lookup Failed for: ${CRS}`, 'warn');
log.out(`ldbService.arrDepBoardStaff: ${err}`);
return {
GetStationBoardResult: 'not available',
Reason: `The CRS code ${CRS} is not valid`
@@ -69,6 +72,55 @@ async function arrDepBoardStaff(CRS) {
}
}
async function getServiceByRID(rid) {
log.out(`ldbService.getServiceByRID: Finding RID: ${rid}`, 'dbug');
try {
const options = {
rid: String(rid)
};
const api = new ldb(ldbsvKey,true);
return await api.call('GetServiceDetailsByRID', options,false,false);
} catch (err) {
log.out(`ldbService.queryService: ${err}`, 'EROR');
}
}
async function getReasonCodeList() {
log.out('ldbService.getReasonCodeList: Fetching reason code list', 'eror');
try {
const api = new ldb(ldbsvKey,true);
const options = {};
return await api.call('GetReasonCodeList', options, true, false);
} catch (err) {
log.out(`ldbService.getReasonCodeList: ${err}`, 'eror');
}
}
async function getReasonCode(code) {
log.out(`ldbService.getReasonCode: Fetching reason code ${code}`, 'dbug');
try {
const api = new ldb(ldbsvKey, true);
return await api.call('GetReasonCode', {reasonCode: code}, true, false);
} catch (err) {
log.out(`ldbService.getReasonCode: ${err}`, 'eror');
}
}
async function getDateTimeString(date) {
const year = date.getFullYear(),
month = String(date.getMonth() + 1).padStart(2,'0'),
day = String(date.getDate()).padStart(2,'0'),
hour = String(date.getHours()).padStart(2,'0'),
minute = String(date.getMinutes()).padStart(2,'0'),
second = String(date.getSeconds()).padStart(2,'0');
const format = `${year}-${month}-${day}T${hour}:${minute}:${second}`;
return format;
}
module.exports = {
get
get,
getServiceByRID,
getReasonCodeList,
getReasonCode
};