import api, { authorizeApi } from './api';

export const authService = {
  // Authentication
  login: (data: { username: string; password: string }) =>
    api.post('/auth/login', data),

  register: (data: any) =>
    api.post('/auth/register', data),

  logout: () =>
    api.post('/auth/logout'),

  whoami: () =>
    api.get('/auth/whoami'),

  // Password management
  changePassword: (data: { old_password: string; new_password: string }) =>
    api.put('/auth/change-password', data),

  adminChangePassword: (data: { user_id: number; new_password: string }) =>
    api.put('/auth/admin-change-password', data),

  unlockAccount: (data: any) =>
    api.post('/auth/unlock-account', data),

  // Authorize.net account management
  authorize: {
    checkAccount: (customerId: number) =>
      authorizeApi.get(`/user/check-authorize-account/${customerId}`),

    createAccount: (customerId: number, data?: any) =>
      authorizeApi.post(`/user/create-account/${customerId}`, data),

    deleteAccount: (customerId: number) =>
      authorizeApi.delete(`/user/delete-account/${customerId}`),
  },
};

export default authService;
