import { apiClient } from '../client'; import { User, CreateUser, UpdateUser } from '../schemas/users'; export class UserService { static async listUsers(organizationId?: string): Promise { try { const params: Record = {}; if (organizationId) { params.organization_id = organizationId; } return await apiClient.get('/api/users', params); } catch (error) { console.error('Error fetching users:', error); throw error; } } static async getUser(userId: string): Promise { try { return await apiClient.get(`/api/users/${userId}`); } catch (error) { console.error(`Error fetching user ${userId}:`, error); throw error; } } static async createUser(userData: CreateUser): Promise { try { return await apiClient.post( '/api/users', userData as Record ); } catch (error) { console.error('Error creating user:', error); throw error; } } static async updateUser(userId: string, userData: UpdateUser): Promise { try { return await apiClient.put( `/api/users/${userId}`, userData as Record ); } catch (error) { console.error(`Error updating user ${userId}:`, error); throw error; } } static async deleteUser(userId: string): Promise { try { await apiClient.delete(`/api/users/${userId}`); } catch (error) { console.error(`Error deleting user ${userId}:`, error); throw error; } } }