feat(api): 🎉 Add business profile and catalog management
* Implement endpoints for managing business profiles: - Get business profile - Update business profile * Add catalog management features: - List catalogs - List products in a catalog - Send catalog messages - Send single product messages - Send product list messages * Introduce media upload functionality for sending media files. * Add flow management capabilities: - Deprecate flows * Update API documentation to reflect new endpoints and features.
This commit is contained in:
@@ -193,6 +193,43 @@ func (h *Handlers) PublishFlow(w http.ResponseWriter, r *http.Request) {
|
||||
writeJSON(w, map[string]string{"status": "ok"})
|
||||
}
|
||||
|
||||
// DeprecateFlow transitions a PUBLISHED flow to DEPRECATED.
|
||||
// Deprecated flows block new sessions but remain usable by sessions already in progress.
|
||||
// POST /api/flows/deprecate {"account_id","flow_id"}
|
||||
func (h *Handlers) DeprecateFlow(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != http.MethodPost {
|
||||
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
|
||||
return
|
||||
}
|
||||
|
||||
var req struct {
|
||||
AccountID string `json:"account_id"`
|
||||
FlowID string `json:"flow_id"`
|
||||
}
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
if req.FlowID == "" {
|
||||
http.Error(w, "flow_id is required", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
baClient, err := h.getBusinessAPIClient(req.AccountID)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
if err := baClient.DeprecateFlow(r.Context(), req.FlowID); err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
writeJSON(w, map[string]string{"status": "ok"})
|
||||
}
|
||||
|
||||
// DeleteFlow permanently removes a flow.
|
||||
// POST /api/flows/delete {"account_id","flow_id"}
|
||||
func (h *Handlers) DeleteFlow(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
Reference in New Issue
Block a user