import { api } from '@/core/services/api'
import type {
  ImpersonateLeaveResponse,
  ImpersonateStatusResponse,
  ImpersonateTakeResponse,
} from '../types/impersonate.types'

export async function takeImpersonation(userId: string): Promise<ImpersonateTakeResponse> {
  const { data } = await api.get<ImpersonateTakeResponse>(`/v1/impersonate/take/${userId}`)
  return data
}

export async function leaveImpersonation(): Promise<ImpersonateLeaveResponse> {
  const { data } = await api.get<ImpersonateLeaveResponse>('/v1/impersonate/leave')
  return data
}

export async function fetchImpersonationStatus(): Promise<ImpersonateStatusResponse> {
  const { data } = await api.get<ImpersonateStatusResponse>('/v1/impersonate/status')
  return data
}
