diff --git a/api.go b/api.go index 82151d4..1cdb25d 100644 --- a/api.go +++ b/api.go @@ -276,3 +276,31 @@ func RegisterVehicle(formParams map[string]string, propertyId uint, residentProf return false, nil } + +// RegisterEmailConfirmation sends a request to the server to send a confirmation email regarding a vehicle's registration. +// Example Parameters: email=xevion@xevion.dev, vehicleId=63283, propertyId=63184 +func RegisterEmailConfirmation(email string, vehicleId string, propertyId string) (bool, error) { + params := map[string]string{ + "email": email, + "vehicleId": vehicleId, + "propertyId": propertyId, + "propertySource": "parking-snap", + } + + req := BuildRequestWithBody("GET", "/register-vehicle-confirmation-process", params, nil) + SetTypicalHeaders(req, nil, nil, false) + + res, _ := doRequest(req) + if res.StatusCode != 200 { + return false, fmt.Errorf("unexpected status code: %d", res.StatusCode) + } + + html, _ := io.ReadAll(res.Body) + htmlString := string(html) + + if htmlString == "ok" { + return true, nil + } + + return false, fmt.Errorf("unexpected response: %s", htmlString) +} diff --git a/submit.go b/submit.go index 173e9dd..75da619 100644 --- a/submit.go +++ b/submit.go @@ -8,7 +8,7 @@ import ( func RegisterModalHandler(session *discordgo.Session, interaction *discordgo.InteractionCreate) { // TODO: Pull in all parameters from the form - // TOOD: Pull in all hidden parameters form database + // TODO: Pull in all hidden parameters form database // TODO: Pull in resident ID from database err := session.InteractionRespond(interaction.Interaction, &discordgo.InteractionResponse{ @@ -31,11 +31,11 @@ func RegisterModalHandler(session *discordgo.Session, interaction *discordgo.Int email := dataByCustomID["email"].(*discordgo.TextInput).Value log.Infof("Email: %s", email) - // TOOD: Submit registration request to API + // TODO: Submit registration request to API // TODO: Edit response to indicate success/failure - // TOOD: On success, provide a button to submit email confirmation - + // TODO: On success, provide a button to submit email confirmation // TODO: Validate license plate + // session.InteractionRespond(interaction.Interaction, &discordgo.InteractionResponse{ // Type: discordgo.InteractionResponseChannelMessageWithSource, // Data: &discordgo.InteractionResponseData{