diff --git a/cmd/web/docs/docs.go b/cmd/web/docs/docs.go index cc18805..8ce73fc 100644 --- a/cmd/web/docs/docs.go +++ b/cmd/web/docs/docs.go @@ -4309,64 +4309,6 @@ const docTemplate = `{ } } } - }, - "/api/v1/profile/with-companies": { - "get": { - "security": [ - { - "BearerAuth": [] - } - ], - "description": "Retrieve current customer profile information along with their assigned companies.", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Authorization" - ], - "summary": "Get customer profile with companies", - "responses": { - "200": { - "description": "Profile retrieved successfully", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/response.APIResponse" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/customer.CustomerResponse" - } - } - } - ] - } - }, - "401": { - "description": "Unauthorized - Invalid or missing token", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "404": { - "description": "Not found - Customer not found", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - } - } - } } }, "definitions": { diff --git a/cmd/web/docs/swagger.json b/cmd/web/docs/swagger.json index 8544250..c4d2695 100644 --- a/cmd/web/docs/swagger.json +++ b/cmd/web/docs/swagger.json @@ -4303,64 +4303,6 @@ } } } - }, - "/api/v1/profile/with-companies": { - "get": { - "security": [ - { - "BearerAuth": [] - } - ], - "description": "Retrieve current customer profile information along with their assigned companies.", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "Authorization" - ], - "summary": "Get customer profile with companies", - "responses": { - "200": { - "description": "Profile retrieved successfully", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/response.APIResponse" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/customer.CustomerResponse" - } - } - } - ] - } - }, - "401": { - "description": "Unauthorized - Invalid or missing token", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "404": { - "description": "Not found - Customer not found", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - }, - "500": { - "description": "Internal server error", - "schema": { - "$ref": "#/definitions/response.APIResponse" - } - } - } - } } }, "definitions": { diff --git a/cmd/web/docs/swagger.yaml b/cmd/web/docs/swagger.yaml index 749bc50..4000560 100644 --- a/cmd/web/docs/swagger.yaml +++ b/cmd/web/docs/swagger.yaml @@ -3762,41 +3762,6 @@ paths: summary: Refresh customer access token tags: - Authorization - /api/v1/profile/with-companies: - get: - consumes: - - application/json - description: Retrieve current customer profile information along with their - assigned companies. - produces: - - application/json - responses: - "200": - description: Profile retrieved successfully - schema: - allOf: - - $ref: '#/definitions/response.APIResponse' - - properties: - data: - $ref: '#/definitions/customer.CustomerResponse' - type: object - "401": - description: Unauthorized - Invalid or missing token - schema: - $ref: '#/definitions/response.APIResponse' - "404": - description: Not found - Customer not found - schema: - $ref: '#/definitions/response.APIResponse' - "500": - description: Internal server error - schema: - $ref: '#/definitions/response.APIResponse' - security: - - BearerAuth: [] - summary: Get customer profile with companies - tags: - - Authorization securityDefinitions: BearerAuth: description: 'Type "Bearer" followed by a space and JWT token. Example: "Bearer diff --git a/cmd/web/router/routes.go b/cmd/web/router/routes.go index bc39c5b..710857b 100644 --- a/cmd/web/router/routes.go +++ b/cmd/web/router/routes.go @@ -100,7 +100,6 @@ func RegisterPublicRoutes(e *echo.Echo, customerHandler *customer.Handler) { profileGP := customerGP.Group("") profileGP.Use(customerHandler.AuthMiddleware()) profileGP.GET("", customerHandler.GetProfile) - profileGP.GET("/with-companies", customerHandler.GetProfileWithCompanies) profileGP.DELETE("/logout", customerHandler.Logout) } diff --git a/internal/customer/handler.go b/internal/customer/handler.go index 6ee07bc..f6def24 100644 --- a/internal/customer/handler.go +++ b/internal/customer/handler.go @@ -777,7 +777,7 @@ func (h *Handler) GetProfile(c echo.Context) error { return response.Unauthorized(c, "Customer not authenticated") } - customer, err := h.service.GetProfile(c.Request().Context(), customerID) + resp, err := h.service.GetProfileWithCompanies(c.Request().Context(), customerID) if err != nil { if err.Error() == "customer not found" { return response.NotFound(c, "Customer not found") @@ -785,37 +785,7 @@ func (h *Handler) GetProfile(c echo.Context) error { return response.InternalServerError(c, "Failed to get customer profile") } - return response.Success(c, customer.ToResponse(), "Profile retrieved successfully") -} - -// GetProfileWithCompanies retrieves customer profile with companies (Mobile) -// @Summary Get customer profile with companies -// @Description Retrieve current customer profile information along with their assigned companies. -// @Tags Authorization -// @Accept json -// @Produce json -// @Security BearerAuth -// @Success 200 {object} response.APIResponse{data=CustomerResponse} "Profile retrieved successfully" -// @Failure 401 {object} response.APIResponse "Unauthorized - Invalid or missing token" -// @Failure 404 {object} response.APIResponse "Not found - Customer not found" -// @Failure 500 {object} response.APIResponse "Internal server error" -// @Router /api/v1/profile/with-companies [get] -func (h *Handler) GetProfileWithCompanies(c echo.Context) error { - // Extract customer ID from JWT token context - customerID, err := GetCustomerIDFromContext(c) - if err != nil { - return response.Unauthorized(c, "Customer not authenticated") - } - - customer, err := h.service.GetProfileWithCompanies(c.Request().Context(), customerID) - if err != nil { - if err.Error() == "customer not found" { - return response.NotFound(c, "Customer not found") - } - return response.InternalServerError(c, "Failed to get customer profile with companies") - } - - return response.Success(c, customer, "Profile retrieved successfully") + return response.Success(c, resp, "Profile retrieved successfully") } // Logout handles customer logout (Mobile)