From fd132b9b1d0ef5ee1c9a740f96a61fd34b021039 Mon Sep 17 00:00:00 2001 From: github-cicd Date: Fri, 20 Sep 2024 14:07:41 +0530 Subject: [PATCH] TP-55555/houston-integration --- internal/transport/router/houston.go | 2 +- service/HoustonService.go | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/internal/transport/router/houston.go b/internal/transport/router/houston.go index 131aa14..ba04a59 100644 --- a/internal/transport/router/houston.go +++ b/internal/transport/router/houston.go @@ -10,7 +10,7 @@ func HoustonRouter(r *gin.Engine, dep *dependencies.Dependencies) { hh := dep.Handler.HoustonHandler houstonRouterGroup := r.Group("/api") { - houstonRouterGroup.POST("/v1/create", hh.CreateHouston) + houstonRouterGroup.POST("/v1/create-houston", hh.CreateHouston) houstonRouterGroup.GET("/v1/products", hh.GetProducts) houstonRouterGroup.GET("/v1/responderTeam", hh.GetResponderTeam) } diff --git a/service/HoustonService.go b/service/HoustonService.go index b8e3014..ac96578 100644 --- a/service/HoustonService.go +++ b/service/HoustonService.go @@ -1,6 +1,7 @@ package service import ( + "cybertron/constants" "cybertron/models/db" "cybertron/pkg/houstonClient" "cybertron/pkg/kafka/producer" @@ -41,11 +42,14 @@ func NewHoustonService(logger *log.Logger, dbClient *gorm.DB, kafkaProducer prod func (houstonService *HoustonService) CreateHouston(c *gin.Context) { var request CreateHoustonRequest + userEmail := c.GetHeader(constants.EMAIL_HEADER_NAME) if err := c.BindJSON(&request); err != nil { fmt.Println("Error binding JSON:", err) createErrorResponse(c, http.StatusBadRequest, "Invalid request payload") return } + request.CreatedBy = userEmail + request.ErrorID = "" fmt.Println("Received request payload:", request) @@ -108,7 +112,7 @@ func (houstonService *HoustonService) GetProducts(c *gin.Context) { func (houstonService *HoustonService) GetResponderTeam(c *gin.Context) { // read query params - productID := c.QueryArray("productID") + productID := c.QueryArray("productId") // Get the responder team using the houstonClient responderTeam, err := houstonService.houstonClient.GetReportingAndResponder(productID) @@ -145,12 +149,6 @@ func validateCreateHoustonRequest(request CreateHoustonRequest) []string { if len(request.ProductIds) == 0 { missingFields = append(missingFields, "productIds") } - if request.CreatedBy == "" { - missingFields = append(missingFields, "createdBy") - } - if request.ErrorID == "" { - missingFields = append(missingFields, "errorId") - } return missingFields }