import apiClient from './client'
import type {
  CopilotStartRequest,
  CopilotStartResponse,
  CopilotMessageRequest,
  CopilotMessageResponse,
  CopilotConversation,
} from '@/types/copilot'

export const copilotApi = {
  async startConversation(data: CopilotStartRequest): Promise<CopilotStartResponse> {
    const response = await apiClient.post<CopilotStartResponse>('/copilot/conversations', data)
    return response.data
  },

  async sendMessage(conversationId: string, data: CopilotMessageRequest): Promise<CopilotMessageResponse> {
    const response = await apiClient.post<CopilotMessageResponse>(
      `/copilot/conversations/${conversationId}/messages`,
      data
    )
    return response.data
  },

  async getConversation(conversationId: string): Promise<CopilotConversation> {
    const response = await apiClient.get<CopilotConversation>(`/copilot/conversations/${conversationId}`)
    return response.data
  },
}

export default copilotApi
