diff --git a/src/extractors/easyairportparking-pkpass.js b/src/extractors/easyairportparking-pkpass.js new file mode 100644 --- /dev/null +++ b/src/extractors/easyairportparking-pkpass.js @@ -0,0 +1,28 @@ +/* + Copyright (c) 2019 Nicolas Fella + + 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(pass) +{ + var res = JsonLd.newEventReservation(); + res.reservationFor.startDate = JsonLd.toDateTime(pass.field["reservation_time_from"].value, "dd.MM.yyyy", "de"); + res.reservationFor.endDate = JsonLd.toDateTime(pass.field["reservation_time_till"].value, "dd.MM.yyyy", "de"); + + return res; +} + diff --git a/src/extractors/easyairportparking.json b/src/extractors/easyairportparking.json new file mode 100644 --- /dev/null +++ b/src/extractors/easyairportparking.json @@ -0,0 +1,6 @@ +[{ + "type": "pkpass", + "filter": [ { "field": "passTypeIdentifier", "match": "pass.com.blueend.customer.eap.ticket" } ], + "script": "easyairportparking-pkpass.js" +}] + diff --git a/src/extractors/extractors.qrc b/src/extractors/extractors.qrc --- a/src/extractors/extractors.qrc +++ b/src/extractors/extractors.qrc @@ -25,6 +25,8 @@ deutschebahn.js dinnerbooking.json dinnerbooking.js + easyairportparking.json + easyairportparking-pkpass.js easyjet.json easyjet.js eurowings.json diff --git a/src/jsapi/jsonld.h b/src/jsapi/jsonld.h --- a/src/jsapi/jsonld.h +++ b/src/jsapi/jsonld.h @@ -56,6 +56,8 @@ * This can be used by extractor scripts to fill in the extracted information. */ Q_INVOKABLE QJSValue newLodgingReservation() const; + + Q_INVOKABLE QJSValue newEventReservation() const; // TODO add the same for other reservation types /** Convert a date/time string to a date/time value. diff --git a/src/jsapi/jsonld.cpp b/src/jsapi/jsonld.cpp --- a/src/jsapi/jsonld.cpp +++ b/src/jsapi/jsonld.cpp @@ -132,6 +132,20 @@ return res; } +QJSValue KItinerary::JsApi::JsonLd::newEventReservation() const +{ + auto resFor = newObject(QStringLiteral("Event")); + + auto res = newObject(QStringLiteral("EventReservation")); + res.setProperty(QStringLiteral("reservationFor"), resFor); + + const auto ticket = newObject(QStringLiteral("Ticket")); + res.setProperty(QStringLiteral("reservedTicket"), ticket); + + return res; +} + + QDateTime JsApi::JsonLd::toDateTime(const QString &dtStr, const QString &format, const QString &localeName) const { QLocale locale(localeName);