feat(crm): complete contact label avatar gaps
This commit is contained in:
@@ -175,6 +175,55 @@ func (h *CompanyHandler) Delete(c *gin.Context) {
|
||||
c.Status(http.StatusOK)
|
||||
}
|
||||
|
||||
func (h *CompanyHandler) DestroyCustomAttributes(c *gin.Context) {
|
||||
accountID := getAccountID(c)
|
||||
if accountID == 0 {
|
||||
response.AbortWithStatusError(c, http.StatusUnauthorized, response.ErrUnauthorized, "account not identified")
|
||||
return
|
||||
}
|
||||
companyID, err := strconv.ParseUint(c.Param("company_id"), 10, 32)
|
||||
if err != nil {
|
||||
response.AbortWithStatusError(c, http.StatusBadRequest, response.ErrBadRequest, "invalid company id")
|
||||
return
|
||||
}
|
||||
var req struct {
|
||||
CustomAttributes []string `json:"custom_attributes"`
|
||||
}
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
if req.CustomAttributes == nil {
|
||||
c.JSON(http.StatusUnprocessableEntity, gin.H{"error": "custom_attributes must be an array"})
|
||||
return
|
||||
}
|
||||
company, svcErr := h.svc.DestroyCustomAttributes(c.Request.Context(), uint(companyID), accountID, req.CustomAttributes)
|
||||
if svcErr != nil {
|
||||
handleServiceError(c, svcErr)
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, companyPayloadResponse(c.Request.Context(), h.svc.DB(), company))
|
||||
}
|
||||
|
||||
func (h *CompanyHandler) DeleteAvatar(c *gin.Context) {
|
||||
accountID := getAccountID(c)
|
||||
if accountID == 0 {
|
||||
response.AbortWithStatusError(c, http.StatusUnauthorized, response.ErrUnauthorized, "account not identified")
|
||||
return
|
||||
}
|
||||
companyID, err := strconv.ParseUint(c.Param("company_id"), 10, 32)
|
||||
if err != nil {
|
||||
response.AbortWithStatusError(c, http.StatusBadRequest, response.ErrBadRequest, "invalid company id")
|
||||
return
|
||||
}
|
||||
company, svcErr := h.svc.DeleteAvatar(c.Request.Context(), uint(companyID), accountID)
|
||||
if svcErr != nil {
|
||||
handleServiceError(c, svcErr)
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, companyPayloadResponse(c.Request.Context(), h.svc.DB(), company))
|
||||
}
|
||||
|
||||
// ListContacts retrieves contacts associated with a company.
|
||||
// GET /api/v1/accounts/:id/companies/:company_id/contacts?page=1&per_page=25
|
||||
func (h *CompanyHandler) ListContacts(c *gin.Context) {
|
||||
|
||||
Reference in New Issue
Block a user