Initial
This commit is contained in:
parent
542ca5a14e
commit
aff781e04a
8 changed files with 548 additions and 37 deletions
26
endpoint_handlers/licenseinfo.js
Normal file
26
endpoint_handlers/licenseinfo.js
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
const LICENCEINFO_ENDPOINT = 'https://fp.trafikverket.se/Boka/licence-information'
|
||||
|
||||
async function getLicenceInfo(req, res) {
|
||||
// Check for the required parameters
|
||||
let response = await fetch(LICENCEINFO_ENDPOINT, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36'
|
||||
},
|
||||
// body: JSON.stringify({
|
||||
// licenceId: licenceId,
|
||||
// }),
|
||||
})
|
||||
if (!response.ok) {
|
||||
res.status(500).json({ message: 'Something went wrong' });
|
||||
return;
|
||||
}
|
||||
|
||||
let json = await response.json()
|
||||
// console.log(json)
|
||||
|
||||
res.json(json)
|
||||
}
|
||||
|
||||
module.exports = getLicenceInfo;
|
||||
52
endpoint_handlers/metadata.js
Normal file
52
endpoint_handlers/metadata.js
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
const METADATA_ENDPOINT = 'https://fp.trafikverket.se/boka/search-information'
|
||||
|
||||
const METADATA_TEMPLATE = {
|
||||
"bookingSession": {
|
||||
"socialSecurityNumber": "",
|
||||
"licenceId": "",
|
||||
"bookingModeId": 0,
|
||||
"ignoreDebt": false,
|
||||
"ignoreBookingHindrance": false,
|
||||
"examinationTypeId": 0,
|
||||
"excludeExaminationCategories": [],
|
||||
"rescheduleTypeId": 0,
|
||||
"paymentIsActive": false,
|
||||
"paymentReference": null,
|
||||
"paymentUrl": null,
|
||||
"searchedMonths": 0
|
||||
}
|
||||
}
|
||||
|
||||
async function getMetadataEndpoint(req, res) {
|
||||
// Check for the required parameters
|
||||
if (!req.body || !req.body.licenceId || !req.body.ssn) {
|
||||
res.status(400).json({ message: 'Missing required parameters' });
|
||||
return;
|
||||
}
|
||||
let ssn = req.body.ssn;
|
||||
let licenceId = req.body.licenceId;
|
||||
|
||||
let body = METADATA_TEMPLATE
|
||||
body.bookingSession.socialSecurityNumber = ssn
|
||||
body.bookingSession.licenceId = licenceId
|
||||
|
||||
let response = await fetch(METADATA_ENDPOINT, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36'
|
||||
},
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
if (!response.ok) {
|
||||
res.status(500).json({ message: 'Something went wrong' });
|
||||
return;
|
||||
}
|
||||
|
||||
let json = await response.json()
|
||||
// console.log(json)
|
||||
|
||||
res.json(json)
|
||||
}
|
||||
|
||||
module.exports = getMetadataEndpoint;
|
||||
77
endpoint_handlers/occasions.js
Normal file
77
endpoint_handlers/occasions.js
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
const OCCASION_ENDPOINT = 'https://fp.trafikverket.se/boka/occasion-bundles'
|
||||
|
||||
const OCCASION_TEMPLATE = {
|
||||
"bookingSession": {
|
||||
"socialSecurityNumber": "",
|
||||
"licenceId": 4,
|
||||
"bookingModeId": 0,
|
||||
"ignoreDebt": false,
|
||||
"ignoreBookingHindrance": false,
|
||||
"examinationTypeId": 0,
|
||||
"excludeExaminationCategories": [],
|
||||
"rescheduleTypeId": 0,
|
||||
"paymentIsActive": true,
|
||||
"paymentReference": null,
|
||||
"paymentUrl": null,
|
||||
"searchedMonths": 0
|
||||
},
|
||||
"occasionBundleQuery": {
|
||||
"startDate": "1970-01-01T00:00:00.000Z",
|
||||
"searchedMonths": 0,
|
||||
"locationId": 1000060,
|
||||
"nearbyLocationIds": [],
|
||||
"languageId": 13,
|
||||
"vehicleTypeId": 1,
|
||||
"tachographTypeId": 1,
|
||||
"occasionChoiceId": 1,
|
||||
"examinationTypeId": 50
|
||||
}
|
||||
}
|
||||
// "nearbyLocationIds": [1000121, 1000302, 1000047, 1000009, 1000096, 1000122, 1000066, 1000139, 1000077, 1000138, 1000317, 1000123, 1000069, 1000334, 1000106, 1000103, 1000012, 1000078, 1000318, 1000038, 1000005, 1000087, 1000130, 1000144],
|
||||
|
||||
async function getOccasionEndpoint(req, res) {
|
||||
// Check for the required parameters
|
||||
if (!req.body || !req.body.licenceId || !req.body.ssn || !req.body.locationId || !req.body.examType) {
|
||||
res.status(400).json({ message: 'Missing required parameters' });
|
||||
return;
|
||||
}
|
||||
let ssn = req.body.ssn;
|
||||
let licenceId = req.body.licenceId;
|
||||
let locationId = req.body.locationId;
|
||||
let nearbyIds = req.body.nearbyIds;
|
||||
let examType = req.body.examType;
|
||||
|
||||
if (!locationId.length > 0) {
|
||||
res.status(400).json({ message: 'Missing required parameters' });
|
||||
return;
|
||||
}
|
||||
|
||||
let body = OCCASION_TEMPLATE
|
||||
body.bookingSession.socialSecurityNumber = ssn
|
||||
body.bookingSession.licenceId = licenceId
|
||||
body.occasionBundleQuery.locationId = locationId
|
||||
body.occasionBundleQuery.nearbyLocationIds = nearbyIds
|
||||
body.occasionBundleQuery.examinationTypeId = examType
|
||||
|
||||
console.log(body)
|
||||
|
||||
let response = await fetch(OCCASION_ENDPOINT, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36'
|
||||
},
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
if (!response.ok) {
|
||||
res.status(500).json({ message: 'Something went wrong' });
|
||||
return;
|
||||
}
|
||||
|
||||
let json = await response.json()
|
||||
// console.log(json)
|
||||
|
||||
res.json(json)
|
||||
}
|
||||
|
||||
module.exports = getOccasionEndpoint;
|
||||
34
endpoint_handlers/suggested.js
Normal file
34
endpoint_handlers/suggested.js
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
const SUGGESTED_URL = 'https://fp.trafikverket.se/boka/get-suggested-reservations-by-licence-and-ssn'
|
||||
|
||||
async function getSuggestedEndpoint(req, res) {
|
||||
// Check for the required parameters
|
||||
if (!req.body || !req.body.licenceId || !req.body.ssn) {
|
||||
res.status(400).json({ message: 'Missing required parameters' });
|
||||
return;
|
||||
}
|
||||
let ssn = req.body.ssn;
|
||||
let licenceId = req.body.licenceId;
|
||||
|
||||
let response = await fetch(SUGGESTED_URL, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
ssn: ssn,
|
||||
licenceId: licenceId,
|
||||
}),
|
||||
})
|
||||
if (!response.ok) {
|
||||
res.status(500).json({ message: 'Something went wrong' });
|
||||
return;
|
||||
}
|
||||
|
||||
let json = await response.json()
|
||||
console.log(json)
|
||||
|
||||
res.json(json)
|
||||
}
|
||||
|
||||
module.exports = getSuggestedEndpoint;
|
||||
Loading…
Add table
Add a link
Reference in a new issue