-
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.
Merge pull request #1995 from aliraza556/feature-ticket-review-webhook
Add Webhook Endpoint and `ProcessTicketReview` Handler for Stackwork Ticket Review Automation
- Loading branch information
Showing
3 changed files
with
86 additions
and
11 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) | ||
} |