-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Expand file tree
/
Copy pathsettings.service.ts
More file actions
31 lines (23 loc) · 919 Bytes
/
settings.service.ts
File metadata and controls
31 lines (23 loc) · 919 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { InstanceDto } from '@api/dto/instance.dto';
import { SettingsDto } from '@api/dto/settings.dto';
import { Logger } from '@config/logger.config';
import { WAMonitoringService } from './monitor.service';
export class SettingsService {
constructor(private readonly waMonitor: WAMonitoringService) {}
private readonly logger = new Logger('SettingsService');
public async create(instance: InstanceDto, data: SettingsDto) {
await this.waMonitor.waInstances[instance.instanceName].setSettings(data);
return { settings: { ...instance, settings: data } };
}
public async find(instance: InstanceDto): Promise<SettingsDto> {
try {
const result = await this.waMonitor.waInstances[instance.instanceName].findSettings();
if (Object.keys(result).length === 0) {
throw new Error('Settings not found');
}
return result;
} catch {
return null;
}
}
}