47 lines
1.3 KiB
Go
47 lines
1.3 KiB
Go
package v1
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"github.com/gochat/gochat/internal/service"
|
|
"github.com/gochat/gochat/pkg/response"
|
|
)
|
|
|
|
// NotionIntegrationHandler handles Notion integration endpoints.
|
|
// Reference: Chatwoot Integrations::NotionController
|
|
type NotionIntegrationHandler struct {
|
|
svc *service.NotionIntegrationService
|
|
}
|
|
|
|
// NewNotionIntegrationHandler creates a new NotionIntegrationHandler.
|
|
func NewNotionIntegrationHandler(svc *service.NotionIntegrationService) *NotionIntegrationHandler {
|
|
return &NotionIntegrationHandler{svc: svc}
|
|
}
|
|
|
|
// Delete removes a Notion integration for an account.
|
|
// DELETE /api/v1/accounts/:account_id/integrations/notion
|
|
func (h *NotionIntegrationHandler) Delete(c *gin.Context) {
|
|
accountID, err := parseUintParam(c, "account_id")
|
|
if err != nil {
|
|
response.AbortWithStatusError(c, http.StatusBadRequest, response.ErrBadRequest, "invalid account_id")
|
|
return
|
|
}
|
|
|
|
if svcErr := h.svc.Delete(c.Request.Context(), accountID); svcErr != nil {
|
|
handleServiceError(c, svcErr)
|
|
return
|
|
}
|
|
c.Status(http.StatusOK)
|
|
}
|
|
|
|
// RegisterNotionIntegrationRoutes registers Notion integration routes.
|
|
func RegisterNotionIntegrationRoutes(g *gin.RouterGroup, h *NotionIntegrationHandler) {
|
|
g.DELETE("/notion", h.Delete)
|
|
notion := g.Group("/notion")
|
|
{
|
|
notion.DELETE("/", h.Delete)
|
|
}
|
|
}
|