mirror of
https://github.com/Xevion/r2park.git
synced 2025-12-06 19:16:01 -06:00
Add email confirmation API func, fix TODOs
This commit is contained in:
28
api.go
28
api.go
@@ -276,3 +276,31 @@ func RegisterVehicle(formParams map[string]string, propertyId uint, residentProf
|
|||||||
|
|
||||||
return false, nil
|
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)
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
|
|
||||||
func RegisterModalHandler(session *discordgo.Session, interaction *discordgo.InteractionCreate) {
|
func RegisterModalHandler(session *discordgo.Session, interaction *discordgo.InteractionCreate) {
|
||||||
// TODO: Pull in all parameters from the form
|
// 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
|
// TODO: Pull in resident ID from database
|
||||||
|
|
||||||
err := session.InteractionRespond(interaction.Interaction, &discordgo.InteractionResponse{
|
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
|
email := dataByCustomID["email"].(*discordgo.TextInput).Value
|
||||||
log.Infof("Email: %s", email)
|
log.Infof("Email: %s", email)
|
||||||
|
|
||||||
// TOOD: Submit registration request to API
|
// TODO: Submit registration request to API
|
||||||
// TODO: Edit response to indicate success/failure
|
// 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
|
// TODO: Validate license plate
|
||||||
|
|
||||||
// session.InteractionRespond(interaction.Interaction, &discordgo.InteractionResponse{
|
// session.InteractionRespond(interaction.Interaction, &discordgo.InteractionResponse{
|
||||||
// Type: discordgo.InteractionResponseChannelMessageWithSource,
|
// Type: discordgo.InteractionResponseChannelMessageWithSource,
|
||||||
// Data: &discordgo.InteractionResponseData{
|
// Data: &discordgo.InteractionResponseData{
|
||||||
|
|||||||
Reference in New Issue
Block a user