Espone API JSON e MCP HTTP per far lavorare gli agenti sul CRM.
Gli agenti autenticati con token Bearer possono leggere today/pipeline e annotare attività, con host MCP allineati a quelli di produzione. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
module Api
|
||||
module V1
|
||||
class ActivitiesController < BaseController
|
||||
def create
|
||||
render_agent Crm::AgentSession.new(current_user).create_activity(params[:project_code], activity_params)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def activity_params
|
||||
source = params[:activity].presence || params
|
||||
source.permit(:organization_id, :activity_type, :subject, :description, :happened_at, :contact_id, :opportunity_id, :lost_reason)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,11 @@
|
||||
module Api
|
||||
module V1
|
||||
class BaseController < Api::BaseController
|
||||
private
|
||||
|
||||
def render_agent(result)
|
||||
render json: result.body, status: result.status
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,16 @@
|
||||
module Api
|
||||
module V1
|
||||
class OpportunitiesController < BaseController
|
||||
def update_stage
|
||||
source = params[:opportunity].presence || params
|
||||
render_agent Crm::AgentSession.new(current_user).update_opportunity_stage(
|
||||
params[:project_code],
|
||||
params[:id],
|
||||
pipeline_stage: source[:pipeline_stage],
|
||||
lost_reason: source[:lost_reason],
|
||||
notes: source[:notes]
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
module Api
|
||||
module V1
|
||||
class OrganizationsController < BaseController
|
||||
def show
|
||||
render_agent Crm::AgentSession.new(current_user).organization(params[:project_code], params[:id])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
module Api
|
||||
module V1
|
||||
class ProjectsController < BaseController
|
||||
def index
|
||||
render_agent Crm::AgentSession.new(current_user).projects
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
module Api
|
||||
module V1
|
||||
class SearchController < BaseController
|
||||
def show
|
||||
render_agent Crm::AgentSession.new(current_user).search(params[:project_code], params[:q])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,23 @@
|
||||
module Api
|
||||
module V1
|
||||
class TasksController < BaseController
|
||||
def create
|
||||
render_agent Crm::AgentSession.new(current_user).create_task(params[:project_code], task_params)
|
||||
end
|
||||
|
||||
def complete
|
||||
render_agent Crm::AgentSession.new(current_user).complete_task(params[:project_code], params[:id])
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def task_params
|
||||
source = params[:task].presence || params
|
||||
source.permit(
|
||||
:title, :description, :organization_id, :contact_id, :opportunity_id,
|
||||
:assigned_user_id, :due_at, :priority, :task_type
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
module Api
|
||||
module V1
|
||||
class TodayController < BaseController
|
||||
def show
|
||||
render_agent Crm::AgentSession.new(current_user).today(params[:project_code])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user