Commit 4b58675a authored by Volker Krause's avatar Volker Krause
Browse files

Add initial support for Ouigo tickets

CCBUG: 404451
parent 3e0c57ce
......@@ -121,7 +121,7 @@ function parsePdf(pdf) {
return reservations;
}
function parseHtmlConfirmation(html)
function parseOuigoConfirmation(html)
{
var reservations = new Array();
......@@ -169,3 +169,25 @@ function parseHtmlConfirmation(html)
return reservations;
}
function parseOuigoTicket(pdf) {
var text = pdf.pages[0].textInRect(0, 0, 0.5, 1);
var res = JsonLd.newTrainReservation();
res.reservationNumber = text.match(/numéro de réservation est\s*:\s*([\w]{6})\n/)[1];
var trip = text.match(/(\d{2} .+ \d{4})\n\s*(\d{2}h\d{2})\s*(.*?)\n\s*(\d{2}h\d{2})\s*(.*?)\n/);
res.reservationFor.departureStation.name = trip[3];
res.reservationFor.departureTime = JsonLd.toDateTime(trip[1] + trip[2], "dd MMMM yyyyhh'h'mm", "fr");
res.reservationFor.arrivalStation.name = trip[5];
res.reservationFor.arrivalTime = JsonLd.toDateTime(trip[1] + trip[4], "dd MMMM yyyyhh'h'mm", "fr");
res.reservationFor.trainNumber = text.match(/N°\s*(\S+)/)[1];
var seat = text.match(/Voiture\s*(\S+)\s*Place\s*(\S+)/);
res.reservedTicket.ticketedSeat.seatSection = seat[1];
res.reservedTicket.ticketedSeat.seatNumber = seat[2];
if (Context.barcode) {
res.reservedTicket.ticketToken = "acteccode:" + Context.barcode;
}
return res;
}
[
{
"type": "pdf",
"filter": [
{ "header": "From", "match": "e-billet@sncf.fr" },
{ "type": "Barcode", "match": "^i0CV" }
{
"header": "From",
"match": "e-billet@sncf.fr",
"type": "Email"
},
{
"match": "^i0CV",
"type": "Barcode"
}
],
"function": "parsePdf",
"script": "sncf.js",
"function": "parsePdf"
"type": "Pdf"
},
{
"type": "text",
"filter": [ { "header": "From", "match": "UNITTEST-e-billet@sncf.fr" } ],
"filter": [
{
"header": "From",
"match": "UNITTEST-e-billet@sncf.fr",
"type": "Email"
}
],
"function": "parseText",
"script": "sncf.js",
"function": "parseText"
"type": "Text"
},
{
"type": "html",
"filter": [ { "header": "From", "match": "oui.sncf" } ],
"filter": [
{
"header": "From",
"match": "oui.sncf",
"type": "Email"
}
],
"function": "parseOuigoConfirmation",
"script": "sncf.js",
"type": "Html"
},
{
"filter": [
{
"header": "From",
"match": "ne-pas-repondre@pasngr.ouigo.com",
"type": "Email"
}
],
"function": "parseOuigoTicket",
"script": "sncf.js",
"function": "parseHtmlConfirmation"
"type": "Pdf"
}
]
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