import { apiClient } from './apiClient'
import { logger } from '../utils/logger'

interface AuthResponse {
  token: string
  expires_at: string
}

export interface AuthLoginPayload {
  username: string
  password: string
}

export const authService = {
  login: async (payload: AuthLoginPayload) => {
    logger.info('🔐 [authService] Making request to /v1/auth/login with:', payload)
    const data = await apiClient.post<AuthResponse>('/v1/auth/login', payload)
    logger.info('🔐 [authService] Response data:', data)
    return { token: data.token, expiresAt: data.expires_at }
  },
  logout: async () => {
    await apiClient.post('/v1/auth/logout')
  }
}
