Commit daab5598 authored by Volker Krause's avatar Volker Krause
Browse files

Add ical extractor for Swiss booking confirmations

parent 9488a1fa
/*
SPDX-FileCopyrightText: 2017 Volker Krause <vkrause@kde.org>
SPDX-FileCopyrightText: 2017-2022 Volker Krause <vkrause@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
......@@ -40,3 +40,21 @@ function main(text) {
return reservations;
}
function parseEvent(event)
{
let res = JsonLd.newFlightReservation();
res.reservationFor.departureTime = JsonLd.readQDateTime(event, 'dtStart');
res.reservationFor.arrivalTime = JsonLd.readQDateTime(event, 'dtEnd');
res.reservationNumber = event.description.match(/Booking reference: (.*)\n/)[1];
const flight = event.description.match(/Airline: (.*)\nFlight number: (.{2}) (.*)\n/);
res.reservationFor.airline.name = flight[1];
res.reservationFor.airline.iataCode = flight[2];
res.reservationFor.flightNumber = flight[3];
res.reservationFor.departureAirport.name = event.location;
res.reservationFor.arrivalAirport.name = event.description.match(/At: (.*)\n/)[1];
return res;
}
......@@ -3,5 +3,18 @@
"mimeType": "text/plain",
"filter": [ { "field": "From", "match": "noreply@swiss.com", "mimeType": "message/rfc822", "scope": "Ancestors" } ],
"script": "swiss.js"
},
{
"filter": [
{
"field": "uid",
"match": "@swiss.com$",
"mimeType": "internal/event",
"scope": "Current"
}
],
"function": "parseEvent",
"mimeType": "internal/event",
"script": "swiss.js"
}
]
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment