Skip to content

Commit 5cdcbbe

Browse files
temp: adding api for checkin
1 parent 16aff68 commit 5cdcbbe

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

‎apps/api/internal/api/handlers/admissions.go‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package handlers
22

33
import (
4+
"encoding/json"
45
"errors"
56
"net/http"
67

8+
"github.com/google/uuid"
79
"github.com/rs/zerolog"
810
res "github.com/swamphacks/core/apps/api/internal/api/response"
911
"github.com/swamphacks/core/apps/api/internal/services"
@@ -96,3 +98,23 @@ func (h *AdmissionHandler) HandleCalculateAdmissionsRequest(w http.ResponseWrite
9698
w.WriteHeader(http.StatusCreated)
9799

98100
}
101+
102+
type EventCheckInRequest struct {
103+
UserID uuid.UUID `json:"user_id"`
104+
RFID string `json:"rfid"`
105+
}
106+
107+
func (h *AdmissionHandler) HandleEventCheckIn(w http.ResponseWriter, r *http.Request) {
108+
eventId, err := web.PathParamToUUID(r, "eventId")
109+
if err != nil {
110+
res.SendError(w, http.StatusBadRequest, res.NewError("missing_param", "Missing event id"))
111+
return
112+
}
113+
114+
var req EventCheckInRequest
115+
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
116+
res.SendError(w, http.StatusBadRequest, res.NewError("invalid_request", "Could not parse request body"))
117+
return
118+
}
119+
120+
}

‎apps/api/internal/services/bat.go‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ var (
3737
ErrFailedToSendDecisionEmails = errors.New("Failed to send decision emails")
3838
ErrTestErr = errors.New("Err while testing")
3939
ErrFailedToGetContactEmail = errors.New("Failed to get contact email")
40+
Err
4041
)
4142

4243
type BatService struct {
@@ -359,3 +360,15 @@ func (s *BatService) mapToCandidates(engine *bat.BatEngine, applications []sqlc.
359360

360361
return appAdmissionsData, nil
361362
}
363+
364+
func (s *BatService) CheckInAttendee(ctx context.Context, eventId, userId uuid.UUID, RFID string) error {
365+
// Retrieve user with their current event role
366+
role, err := s.eventRepo.GetEventRoleByIds(ctx, userId, eventId)
367+
if err != nil {
368+
return ErrUserNotFound
369+
}
370+
371+
if role.Role != sqlc.EventRoleTypeAttendee {
372+
return
373+
}
374+
}

0 commit comments

Comments
 (0)