Răsfoiți Sursa

Use WHOSCOMING_SECTION for full guest name on Airbnb reservations

FACEPILE_SECTION only returns a first name; WHOSCOMING_SECTION carries
the full name. Fall back to FACEPILE_SECTION if WHOSCOMING is absent.
ZiB 4 luni în urmă
părinte
comite
0dc30df205
1 a modificat fișierele cu 5 adăugiri și 2 ștergeri
  1. 5 2
      room_cal/service_api/_airbnb.py

+ 5 - 2
room_cal/service_api/_airbnb.py

@@ -334,9 +334,12 @@ class _AirbnbClient:
             .get('hostingDetails', {}).get('stayHostingDetails', {})
             .get('hostingDetails', {}).get('stayHostingDetails', {})
             .get('rootPlacement', [])
             .get('rootPlacement', [])
       )
       )
+      whoscoming = next((s for s in sections if s.get('sectionId') == 'WHOSCOMING_SECTION'), None)
+      wc_groups = (whoscoming or {}).get('sectionData', {}).get('reservationGroups', [])
+      wc_guests = wc_groups[0].get('guests', []) if wc_groups else []
       facepile = next((s for s in sections if s.get('sectionId') == 'FACEPILE_SECTION'), None)
       facepile = next((s for s in sections if s.get('sectionId') == 'FACEPILE_SECTION'), None)
-      guests = (facepile or {}).get('sectionData', {}).get('guests', [])
-      name = guests[0].get('name') if guests else None
+      fp_guests = (facepile or {}).get('sectionData', {}).get('guests', [])
+      name = (wc_guests[0].get('name') if wc_guests else None) or (fp_guests[0].get('name') if fp_guests else None)
 
 
       checkinout = next((s for s in sections if s.get('sectionId') == 'CHECK_IN_CHECK_OUT_SECTION'), None)
       checkinout = next((s for s in sections if s.get('sectionId') == 'CHECK_IN_CHECK_OUT_SECTION'), None)
       ci_out_data = (checkinout or {}).get('sectionData') or {}
       ci_out_data = (checkinout or {}).get('sectionData') or {}