From e41878f0707da95529a6f18227e023970cd78f92 Mon Sep 17 00:00:00 2001 From: Xevion Date: Wed, 28 Feb 2024 04:35:33 -0600 Subject: [PATCH] Properly acquire resident profile Id for VIP forms --- api.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/api.go b/api.go index 1e30337..e9a316f 100644 --- a/api.go +++ b/api.go @@ -185,6 +185,7 @@ func GetForm(id uint) GetFormResult { } } + // TODO: Validate that vehicleInformationVIP is actually real for non-VIP properties // Get the resident profile nextButton := doc.Find("#vehicleInformationVIP").First() residentProfileId, _ := nextButton.Attr("data-resident-profile-id") @@ -236,11 +237,19 @@ func GetVipForm(id uint, guestCode string) GetFormResult { title := titleElement.Text() address := strings.TrimSpace(titleElement.Next().Text()) + // Acquire the resident profile ID + nextButton := doc.Find("#vehicleInformationVIP").First() + residentProfileId, exists := nextButton.Attr("data-resident-profile-id") + if !exists { + return GetFormResult{err: errors.New("resident profile ID not found")} + } + return GetFormResult{ - propertyName: title, - address: address, - fields: formFields, - hiddenInputs: hiddenInputs, + propertyName: title, + address: address, + fields: formFields, + hiddenInputs: hiddenInputs, + residentProfileId: residentProfileId, } }