File indexing completed on 2024-12-29 04:51:06
0001 /* 0002 SPDX-FileCopyrightText: 2023 Kai Uwe Broulik <kde@broulik.de> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 function main(pass, node) 0008 { 0009 let res = JsonLd.newRentalCarReservation(); 0010 0011 res.reservationNumber = pass.serialNumber; 0012 0013 res.underName.name = pass.field["driver-name"].value; 0014 0015 res.pickupTime = pass.relevantDate; 0016 res.dropoffTime = pass.expirationDate; 0017 // TODO also consider pickup-datetime.value and dropoff-datetime.value for dates. 0018 0019 res.pickupLocation.name = pass.field["pickup-info"].value; 0020 0021 const pickupAddress = pass.field["pickup-address"].value; 0022 const pickupAddressParts = pickupAddress.split("\n"); 0023 0024 if (!res.pickupLocation.name) { 0025 res.pickupLocation.name = pickupAddressParts[0]; 0026 } 0027 0028 res.pickupLocation.address.streetAddress = pickupAddressParts[1]; 0029 0030 const telPrefix = "Tel: "; 0031 if (pickupAddressParts[3].startsWith(telPrefix)) { 0032 res.pickupLocation.telephone = pickupAddressParts[3].substring(telPrefix.length); 0033 } 0034 // TODO pickup-meeting-details 0035 0036 const location = pass.locations[0]; 0037 res.pickupLocation.geo.latitude = location.latitude; 0038 res.pickupLocation.geo.longitude = location.longitude; 0039 0040 // TODO drop-off location. We currently do not have enough samples 0041 // to tell whether the absence of a drop-off location indicates 0042 // that it is identical to the pickup location. 0043 0044 res.reservationFor.model = pass.field["vehicle-group-detail"].value; 0045 0046 // TODO res.reservationFor.rentalCompany.name but Sunny Cars isn't 0047 // the actual rental car operator. partner-rate-code might help here. 0048 0049 return [res]; 0050 }