Commit 5e655e43 authored by Volker Krause's avatar Volker Krause

Handle Google's format for ticket tokens too, next to the schema.org one

parent 3d0fc18a
......@@ -30,6 +30,7 @@
"reservationNumber": "XXX007",
"reservedTicket": {
"@type": "Ticket",
"ticketToken": "aztecCode:somerandomdata DOE JOHN111110 00000",
"ticketedSeat": {
"@type": "Seat",
"seatNumber": "71",
......@@ -69,6 +70,7 @@
"reservationNumber": "XXX007",
"reservedTicket": {
"@type": "Ticket",
"ticketToken": "aztecCode:somerandomdata DOE JOHN111110 00000",
"ticketedSeat": {
"@type": "Seat",
"seatNumber": "62",
......
......@@ -169,6 +169,7 @@ class Reservation
// Google extension
SEMANTIC_PROPERTY(QUrl, cancelReservationUrl)
SEMANTIC_PROPERTY(QUrl, modifyReservationUrl)
SEMANTIC_PROPERTY(QString, ticketToken)
SEMANTIC_PROPERTY(QUrl, url)
};
......
......@@ -157,6 +157,7 @@ QVariant ExtractorPostprocessor::processReservation(QVariant res) const
const auto viewUrl = JsonLdDocument::readProperty(res, "url").toUrl();
const auto modUrl = JsonLdDocument::readProperty(res, "modifyReservationUrl").toUrl();
const auto cancelUrl = JsonLdDocument::readProperty(res, "cancelReservationUrl").toUrl();
// remove duplicated urls
if (modUrl.isValid() && viewUrl == modUrl) {
JsonLdDocument::removeProperty(res, "modifyReservationUrl");
}
......@@ -164,6 +165,19 @@ QVariant ExtractorPostprocessor::processReservation(QVariant res) const
JsonLdDocument::removeProperty(res, "cancelReservationUrl");
}
// move ticketToken to Ticket (Google vs. schema.org difference)
const auto token = JsonLdDocument::readProperty(res, "ticketToken").toString();
if (!token.isEmpty()) {
auto ticket = JsonLdDocument::readProperty(res, "reservedTicket");
if (ticket.isNull()) {
ticket = QVariant::fromValue(Ticket{});
}
if (JsonLdDocument::readProperty(ticket, "ticketToken").toString().isEmpty()) {
JsonLdDocument::writeProperty(ticket, "ticketToken", token);
JsonLdDocument::writeProperty(res, "reservedTicket", ticket);
}
}
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