Remove deprecated /api/v1/profile/with-companies endpoint and update related documentation
- Deleted the `/api/v1/profile/with-companies` endpoint from the API documentation, Swagger files, and router to streamline the API structure. - Updated the `GetProfile` handler to utilize the `GetProfileWithCompanies` service method for improved data retrieval. - Enhanced overall API documentation consistency by removing obsolete references and ensuring accurate representation of the current API structure.
This commit is contained in:
@@ -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": {
|
||||
|
||||
@@ -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": {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user