Commit d6415ce7 authored by Volker Krause's avatar Volker Krause

Add Stansted Express ticket extractor

That's interesting as that's the first case of a pkpass train ticket.
parent 7c74b0df
......@@ -45,6 +45,8 @@
<file>sas-receipt.js</file>
<file>sncf.json</file>
<file>sncf.js</file>
<file>stansted-express.json</file>
<file>stansted-express.js</file>
<file>swiss.json</file>
<file>swiss.js</file>
<file>swiss-pkpass.js</file>
......
/*
Copyright (c) 2019 Volker Krause <vkrause@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
function expandStationName(name)
{
switch (name) {
case "SSD": return "Stansted";
case "LST": return "London Liverpool Street";
case "TOM": return "Tottenham Hale";
case "SRA": return "Stratford";
}
return name;
}
function parsePkPass(pass)
{
var res = JsonLd.newObject("TrainReservation");
res.reservationFor = JsonLd.newObject("TrainTrip");
res.reservationFor.departureDay = JsonLd.toDateTime(pass.field["travelDate"].value, "dd/MM/yyyy", "en");
res.reservationFor.departureStation = JsonLd.newObject("TrainStation");
res.reservationFor.departureStation.name = expandStationName(pass.field["from"].value);
res.reservationFor.arrivalStation = JsonLd.newObject("TrainStation");
res.reservationFor.arrivalStation.name = expandStationName(pass.field["to"].value);
return res;
}
[
{
"type": "pkpass",
"filter": [ { "field": "passTypeIdentifier", "match": "pass.com.stanstedexpress.ticket" } ],
"script": "stansted-express.js",
"function": "parsePkPass"
}
]
Markdown is supported
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