@@ -638,16 +638,49 @@ export default {
638638 loadMore () {
639639 this .max_entries += 10 ;
640640 },
641- airlineLink (departure ) {
642- let dep = DateTime .fromFormat (departure .date , " yyyy-LL-dd" , " UTC" );
643- let loc = departure .departure + " -" + departure .arrival ;
644- let link =
645- " https://booking.skyalps.com/flight-results/" +
646- loc +
647- " /" +
648- dep .toFormat (" yyyy-LL-dd" ) +
649- " /NA/1/0/0" ;
650- return link;
641+ airlineLink (flight ) {
642+ if (! flight || ! flight .departure || ! flight .arrival || ! flight .date ) {
643+ return " " ;
644+ }
645+
646+ const departureDate = DateTime .fromFormat (
647+ flight .date ,
648+ " yyyy-LL-dd" ,
649+ { zone: " utc" }
650+ );
651+
652+ if (! departureDate .isValid ) {
653+ return " " ;
654+ }
655+
656+ const url = " https://book-skyalps.crane.aero/ibe/availability" ;
657+ const params = new URLSearchParams ();
658+
659+ const language = (this .options .lang || " en" ).toLowerCase ();
660+
661+ const passengers = this .options .bookingPassengers || {
662+ adults: 1 ,
663+ children: 0 ,
664+ infants: 0 ,
665+ };
666+
667+ params .set (" tripType" , " ONE_WAY" );
668+ params .set (" depPort" , flight .departure );
669+ params .set (" arrPort" , flight .arrival );
670+ params .set (" departureDate" , departureDate .toFormat (" dd LLL yyyy" ));
671+ params .set (" currency" , this .options .bookingCurrency || " EUR" );
672+ params .set (" lang" , language);
673+
674+ params .set (" passengerQuantities[0][passengerType]" , " ADLT" );
675+ params .set (" passengerQuantities[0][quantity]" , String (passengers .adults || 0 ));
676+
677+ params .set (" passengerQuantities[1][passengerType]" , " CHLD" );
678+ params .set (" passengerQuantities[1][quantity]" , String (passengers .children || 0 ));
679+
680+ params .set (" passengerQuantities[2][passengerType]" , " INFT" );
681+ params .set (" passengerQuantities[2][quantity]" , String (passengers .infants || 0 ));
682+
683+ return ` ${ url} ?${ params .toString ()} ` ;
651684 },
652685 asZoneTime (time = " 00:00" , source_zone = " UTC" , date = false ) {
653686 if (time == " " || ! date) return " " ;
@@ -801,59 +834,48 @@ export default {
801834 where: where,
802835 origin: " webcomp-flightdata" ,
803836 };
804-
805- params = new URLSearchParams (params).toString ();
806-
807- let data = await axios .get (this .options .rest_endpoint + params);
808-
809- // we can assume with reasonable certainty that the following data type is "data" :)
810- data = data .data .data .map ((o ) => {
811- const arrival = o .smetadata .fromdestination != airport;
812-
813- let datetime = DateTime .fromFormat (
814- o .smetadata .fltsfromperiod +
815- " " +
816- (arrival ? o .smetadata .sta : o .smetadata .std ),
817- " yyyy-LL-dd T" ,
818- {
819- zone: " UTC" ,
820- }
821- );
822-
823- let rate = o .smetadata .fares ? o .smetadata .fares [" SKY_LIGHT" ] : null ;
824-
825- if (rate) {
826- rate =
827- rate .fare .adultFareOW +
828- rate .fare .tax1OW +
829- rate .fare .tax2OW +
830- rate .fare .tax3OW +
831- rate .fare .tax4OW ;
832- }
833-
834- if (isNaN (rate) || rate == 0 ) rate = false ;
835-
836- return {
837- gate: " 1" ,
838- // we assume that fltsfromperiod = fltstoperiod / "flat" endpoint
839- date: o .smetadata .fltsfromperiod .replace (/ \/ / g , " -" ),
840- time: arrival ? o .smetadata .sta : o .smetadata .std ,
841- sta: o .smetadata .arrival_timestamp ,
842- std: o .smetadata .departure_timestamp ,
843- type: arrival ? " ARRIVAL" : " DEPARTURE" ,
844- remark: o .smetadata .remark ? o .smetadata .remark : " SCHEDULED" ,
845- arrival: o .smetadata .todestination ,
846- company: o .sorigin ,
847- departure: o .smetadata .fromdestination ,
848- flight_number: o .smetadata .fltnumber ,
849- timestamp: datetime .toMillis (),
850- rates: rate
851- ? {
852- basic_adult_oneway_withtaxes: rate,
853- }
854- : null ,
855- };
856- });
837+ params = new URLSearchParams (params).toString ();
838+
839+ let response = await axios .get (this .options .rest_endpoint );
840+ let trips = response .data .Items ;
841+
842+ let data = trips .map ((trip ) => {
843+
844+ if (! trip .StopTimes || trip .StopTimes .length < 2 ) return null ;
845+
846+ let origin = trip .StopTimes [0 ].Shortname ;
847+ let destination = trip .StopTimes [1 ].Shortname ;
848+
849+ let departureDT = DateTime .fromISO (
850+ trip .StopTimes [0 ].DepartureTime ,
851+ { zone: " UTC" }
852+ );
853+
854+ let arrivalDT = DateTime .fromISO (
855+ trip .StopTimes [1 ].ArrivalTime ,
856+ { zone: " UTC" }
857+ );
858+
859+ let type = origin === airport ? " DEPARTURE" : " ARRIVAL" ;
860+ let relevantDT = type === " DEPARTURE" ? departureDT : arrivalDT;
861+
862+ return {
863+ gate: " 1" ,
864+ date: relevantDT .toFormat (" yyyy-LL-dd" ),
865+ time: relevantDT .toFormat (" HH:mm" ),
866+ sta: arrivalDT .toSeconds (),
867+ std: departureDT .toSeconds (),
868+ type: type,
869+ remark: " SCHEDULED" ,
870+ arrival: destination,
871+ departure: origin,
872+ flight_number: trip .Shortname ,
873+ timestamp: relevantDT .toMillis (),
874+ rates: null
875+ };
876+
877+ }).filter (Boolean );
878+
857879 // clientside filtering
858880 data = data .filter ((json ) => {
859881 const flightdate = DateTime .fromFormat (json .date , " yyyy-LL-dd" , {
0 commit comments