- Renamed project from PSA-Utils to Pulse - Moved all app files from autotask-app/ to root - Updated package.json name to 'pulse' - Updated Docker container names to pulse-app and pulse-redis - Updated Docker network name to pulse-network
26 lines
845 B
TypeScript
26 lines
845 B
TypeScript
import { AutotaskClient } from './autotask-client';
|
|
import { AutotaskConfig } from '@/lib/types/autotask';
|
|
|
|
let clientInstance: AutotaskClient | null = null;
|
|
|
|
export function getAutotaskClient(): AutotaskClient {
|
|
if (!clientInstance) {
|
|
const config: AutotaskConfig = {
|
|
apiUrl: process.env.AUTOTASK_API_URL || '',
|
|
username: process.env.AUTOTASK_USERNAME || '',
|
|
password: process.env.AUTOTASK_SECRET || '',
|
|
apiIntegrationCode: process.env.AUTOTASK_API_INTEGRATION_CODE || '',
|
|
};
|
|
|
|
// Validate configuration
|
|
if (!config.apiUrl || !config.username || !config.password || !config.apiIntegrationCode) {
|
|
throw new Error(
|
|
'Missing Autotask API configuration. Please check your environment variables.'
|
|
);
|
|
}
|
|
|
|
clientInstance = new AutotaskClient(config);
|
|
}
|
|
|
|
return clientInstance;
|
|
}
|