import apiClient from './client'
import type {
  AllResolutionOutputsResponse,
  ResolutionOutputResponse,
  ResolutionOutputEditRequest,
  ResolutionOutputPushRequest,
} from '@/types/branching'

export const resolutionsApi = {
  async getOutputs(sessionId: string): Promise<AllResolutionOutputsResponse> {
    const response = await apiClient.get<AllResolutionOutputsResponse>(
      `/ai-sessions/${sessionId}/outputs`
    )
    return response.data
  },

  async editOutput(
    sessionId: string,
    outputId: string,
    data: ResolutionOutputEditRequest
  ): Promise<ResolutionOutputResponse> {
    const response = await apiClient.patch<ResolutionOutputResponse>(
      `/ai-sessions/${sessionId}/outputs/${outputId}`,
      data
    )
    return response.data
  },

  async pushOutput(
    sessionId: string,
    outputId: string,
    data: ResolutionOutputPushRequest
  ): Promise<ResolutionOutputResponse> {
    const response = await apiClient.post<ResolutionOutputResponse>(
      `/ai-sessions/${sessionId}/outputs/${outputId}/push`,
      data
    )
    return response.data
  },
}

export default resolutionsApi
