-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add ticket review webhook endpoint and ProcessTicketReview handler
- Loading branch information
1 parent
3d51ab7
commit 73f7e97
Showing
3 changed files
with
89 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package utils | ||
|
||
import ( | ||
"encoding/json" | ||
"errors" | ||
"net/http" | ||
) | ||
|
||
type TicketReviewRequest struct { | ||
FeatureUUID string `json:"featureUUID" validate:"required"` | ||
PhaseUUID string `json:"phaseUUID" validate:"required"` | ||
TicketUUID string `json:"ticketUUID" validate:"required"` | ||
TicketDescription string `json:"ticketDescription" validate:"required"` | ||
} | ||
|
||
func ValidateTicketReviewRequest(req *TicketReviewRequest) error { | ||
if req.FeatureUUID == "" { | ||
return errors.New("featureUUID is required") | ||
} | ||
if req.PhaseUUID == "" { | ||
return errors.New("phaseUUID is required") | ||
} | ||
if req.TicketUUID == "" { | ||
return errors.New("ticketUUID is required") | ||
} | ||
if req.TicketDescription == "" { | ||
return errors.New("ticketDescription is required") | ||
} | ||
return nil | ||
} | ||
|
||
func RespondWithJSON(w http.ResponseWriter, code int, payload interface{}) { | ||
w.Header().Set("Content-Type", "application/json") | ||
w.WriteHeader(code) | ||
json.NewEncoder(w).Encode(payload) | ||
} |