Commit 60a62969 authored by Nicolas Fella's avatar Nicolas Fella Committed by Volker Krause
Browse files

Add extractor for onepagebooking

parent d7d9b968
Pipeline #80750 passed with stage
in 10 minutes and 26 seconds
......@@ -94,6 +94,8 @@
<file>np4.js</file>
<file>oebb.json</file>
<file>oebb.js</file>
<file>onepagebooking.json</file>
<file>onepagebooking.js</file>
<file>regiojet.json</file>
<file>regiojet.js</file>
<file>regiondo.json</file>
......
/*
SPDX-FileCopyrightText: 2021 Nicolas Fella <nicolas.fella@gmx.de>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
function main(content) {
const resId = content.match(/Buchungsnummer:(.+)/)[1]
const arrivalDate = content.match(/Anreisetag: (.+)/)[1]
const departureDate = content.match(/Abreisetag: (.+)/)[1]
const guestName = content.match(/Gastname: (Herr|Frau) (.+)/)[2]
const addressBlock = content.match(/Ihr\n(.*)\n(.*)\n(.*)/)
const hotelName = addressBlock[1]
const street = addressBlock[2]
const cityLine = addressBlock[3].match(/([0-9]+) (.*)/)
const address = JsonLd.newObject("PostalAddress")
address.addressCountry = "DE"
address.addressLocality = cityLine[2]
address.postalCode = cityLine[1]
address.streetAddress = street
const telephone = content.match(/Tel.: (.*)/)[1]
const email = content.match(/E-Mail: (.*)/)[1]
const price = content.match(/Gesamtpreis: (.*) EUR/)[1].replace(',', '.')
const numberAdults = content.match(/Anzahl der Erwachsener: ([0-9]+)/)[1]
const numberChildren = content.match(/Anzahl der Kinder: ([0-9]+)/)[1]
var res = JsonLd.newLodgingReservation()
res.reservationFor.name = addressBlock[1]
res.reservationNumber = resId
res.checkinTime = JsonLd.toDateTime(arrivalDate, "dd.MM.yyyy", "de")
res.checkoutTime = JsonLd.toDateTime(departureDate, "dd.MM.yyyy", "de")
res.reservationFor.telephone = telephone
res.reservationFor.email = email
res.reservationFor.address = address
res.underName.name = guestName
res.totalPrice = price
res.priceCurrency = "EUR"
res.reservationFor.numAdults = numberAdults
res.reservationFor.numChildren = numberChildren
return res
}
{
"filter": [
{
"field": "From",
"match": "@onepagebooking.com",
"mimeType": "message/rfc822",
"scope": "Ancestors"
}
],
"function": "main",
"mimeType": "text/plain",
"script": "onepagebooking.js"
}
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