import apiClient from './client'
import type { RFFlowFile, FlowImportResponse } from '@/types'

export const flowTransferApi = {
  async exportFlow(treeId: string): Promise<Blob> {
    const response = await apiClient.get(`/trees/${treeId}/export`, {
      responseType: 'blob',
    })
    return response.data
  },

  async importFlow(data: RFFlowFile, nameOverride?: string): Promise<FlowImportResponse> {
    const params = nameOverride ? { name_override: nameOverride } : undefined
    const response = await apiClient.post('/trees/import', data, { params })
    return response.data
  },
}
