feat(inboxes): align chatwoot inbox serializers
This commit is contained in:
@@ -46,16 +46,13 @@ func (h *InboxHandler) List(c *gin.Context) {
|
||||
perPage := getPageSize(c)
|
||||
offset := (page - 1) * perPage
|
||||
|
||||
inboxes, total, svcErr := h.svc.ListByAccount(c.Request.Context(), accountID, offset, perPage)
|
||||
inboxes, _, svcErr := h.svc.ListByAccount(c.Request.Context(), accountID, offset, perPage)
|
||||
if svcErr != nil {
|
||||
c.JSON(http.StatusUnprocessableEntity, gin.H{"error": "failed to list inboxes"})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"inboxes": inboxes,
|
||||
"meta": gin.H{"count": total, "page": page, "page_size": perPage},
|
||||
})
|
||||
c.JSON(http.StatusOK, inboxListResponse(inboxes))
|
||||
}
|
||||
|
||||
// @Summary Get a single inbox
|
||||
@@ -93,7 +90,7 @@ func (h *InboxHandler) Get(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, inbox)
|
||||
c.JSON(http.StatusOK, serializeInbox(inbox))
|
||||
}
|
||||
|
||||
// @Summary Create a new inbox
|
||||
@@ -130,7 +127,7 @@ func (h *InboxHandler) Create(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusCreated, inbox)
|
||||
c.JSON(http.StatusOK, serializeInbox(inbox))
|
||||
}
|
||||
|
||||
// @Summary Update an inbox
|
||||
@@ -176,7 +173,7 @@ func (h *InboxHandler) Update(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, inbox)
|
||||
c.JSON(http.StatusOK, serializeInbox(inbox))
|
||||
}
|
||||
|
||||
// @Summary Delete an inbox
|
||||
@@ -214,7 +211,7 @@ func (h *InboxHandler) Delete(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"id": inboxID, "deleted": true})
|
||||
c.JSON(http.StatusOK, gin.H{"message": "Your inbox deletion request will be processed in some time."})
|
||||
}
|
||||
|
||||
// ========================================
|
||||
@@ -413,13 +410,13 @@ func (h *InboxHandler) DeleteAvatar(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
inbox, svcErr := h.svc.DeleteAvatar(c.Request.Context(), accountID, inboxID)
|
||||
_, svcErr := h.svc.DeleteAvatar(c.Request.Context(), accountID, inboxID)
|
||||
if svcErr != nil {
|
||||
handleServiceError(c, svcErr)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, inbox)
|
||||
c.Status(http.StatusOK)
|
||||
}
|
||||
|
||||
// ListCampaigns retrieves all campaigns for a specific inbox.
|
||||
@@ -474,5 +471,5 @@ func (h *InboxHandler) ResetSecret(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, inbox)
|
||||
c.JSON(http.StatusOK, serializeInbox(inbox))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user