- 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
28 lines
774 B
TypeScript
28 lines
774 B
TypeScript
import { AddigyClient } from './addigy-client';
|
|
import { AddigyConfig } from '@/lib/types/addigy';
|
|
|
|
let cachedAddigyClient: AddigyClient | null = null;
|
|
|
|
export function getAddigyClient(): AddigyClient {
|
|
if (cachedAddigyClient) {
|
|
return cachedAddigyClient;
|
|
}
|
|
|
|
const config: AddigyConfig = {
|
|
apiUrl: process.env.ADDIGY_API_URL || 'https://api.addigy.com/api/v2',
|
|
apiToken: process.env.ADDIGY_API_TOKEN || '',
|
|
organizationId: process.env.ADDIGY_ORG_ID,
|
|
};
|
|
|
|
// Validate required config
|
|
if (!config.apiToken) {
|
|
throw new Error('ADDIGY_API_TOKEN environment variable is required');
|
|
}
|
|
|
|
cachedAddigyClient = new AddigyClient(config);
|
|
return cachedAddigyClient;
|
|
}
|
|
|
|
export function clearAddigyClientCache(): void {
|
|
cachedAddigyClient = null;
|
|
}
|