Commit 5d6f3915 authored by Volker Krause's avatar Volker Krause
Browse files

Extract Indian Railways SMS confirmations

parent b4d7ed66
[
{
"@context": "http://schema.org",
"@type": "TrainReservation",
"reservationFor": {
"@type": "TrainTrip",
"arrivalStation": {
"@type": "TrainStation",
"address": {
"@type": "PostalAddress",
"addressCountry": "IN"
},
"geo": {
"@type": "GeoCoordinates",
"latitude": 28.411500930786133,
"longitude": 77.30729675292969
},
"identifier": "ir:FDB",
"name": "FDB"
},
"departureDay": "2012-08-25",
"departureStation": {
"@type": "TrainStation",
"address": {
"@type": "PostalAddress",
"addressCountry": "IN"
},
"geo": {
"@type": "GeoCoordinates",
"latitude": 28.64229965209961,
"longitude": 77.22000122070312
},
"identifier": "ir:NDLS",
"name": "NDLS"
},
"departureTime": {
"@type": "QDateTime",
"@value": "2012-08-25T05:15:00+05:30",
"timezone": "Asia/Kolkata"
},
"trainNumber": "12138"
},
"reservationNumber": "2438941616",
"reservedTicket": {
"@type": "Ticket",
"ticketedSeat": {
"@type": "Seat",
"seatNumber": "S7 49 S7 52 S7 55",
"seatingType": "SL"
}
},
"underName": {
"@type": "Person",
"name": "RAMESH KUMAR"
}
}
]
// TODO
/*
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 main(content) {
console.log(content);
var res = JsonLd.newTrainReservation();
var m = content.match(/PNR:(\d+),TRAIN:(.+?),DOJ:(.+?),TIME:(.+?),(.+?),(.+?) TO (.+?),(.*?)(\+\d)?,(.*?),/);
res.reservationNumber = m[1];
res.reservationFor.trainNumber = m[2];
res.reservationFor.departureTime = JsonLd.toDateTime(m[3] + m[4], "dd-MM-yyyyhh:mm", "en");
res.reservedTicket.ticketedSeat.seatingType = m[5];
res.reservationFor.departureStation.name = m[6];
res.reservationFor.departureStation.identifier = "ir:" + m[6];
res.reservationFor.arrivalStation.name = m[7];
res.reservationFor.arrivalStation.identifier = "ir:" + m[7];
res.underName.name = m[8];
res.reservedTicket.ticketedSeat.seatNumber = m[10];
return res;
}
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