Commit 85c216cb authored by Volker Krause's avatar Volker Krause
Browse files

Parse DB cancellation confirmation emails

parent 49487179
......@@ -258,3 +258,15 @@ function parsePdf(pdf) {
return reservations;
}
function parseCancellation(html) {
var title = html.eval('//title')[0];
var pnr = title.content.match(/Stornierungsbestätigung \(Auftrag (.*)\)/);
if (!pnr)
return null;
var res = JsonLd.newTrainReservation();
res.reservationNumber = pnr[1];
res.reservationStatus = "ReservationCancelled";
res.reservationFor = 1;
return res;
}
[
{
"type": "pdf",
"filter": [
{ "header": "From", "match": "buchungsbestaetigung@bahn.de" },
{ "property": "reservationFor.provider.identifier", "match": "uic:0080" },
{ "property": "reservationFor.provider.identifier", "match": "vdv:6260" }
{
"header": "From",
"match": "buchungsbestaetigung@bahn.de",
"type": "Email"
},
{
"match": "uic:0080",
"property": "reservationFor.provider.identifier",
"type": "JsonLd"
},
{
"match": "vdv:6260",
"property": "reservationFor.provider.identifier",
"type": "JsonLd"
}
],
"function": "parsePdf",
"script": "deutschebahn.js",
"function": "parsePdf"
"type": "Pdf"
},
{
"type": "text",
"filter": [ { "header": "From", "match": "UNITTEST-buchungsbestaetigung@bahn.de" } ],
"filter": [
{
"header": "From",
"match": "UNITTEST-buchungsbestaetigung@bahn.de",
"type": "Email"
}
],
"function": "parseText",
"script": "deutschebahn.js",
"type": "Text"
},
{
"filter": [
{
"header": "From",
"match": "buchungsbestaetigung@bahn.de",
"type": "Email"
}
],
"function": "parseCancellation",
"script": "deutschebahn.js",
"function": "parseText"
"type": "Html"
}
]
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