[ACS-7688] Reduce the usage of LogService and TranslateModule (tests) (#9567)

This commit is contained in:
Denys Vuika
2024-04-19 12:14:33 -04:00
committed by GitHub
parent caa2166151
commit 54c3e12ad8
275 changed files with 4090 additions and 5551 deletions

View File

@@ -22,85 +22,81 @@ import { BaseCloudService } from './base-cloud.service';
@Injectable({ providedIn: 'root' })
export class UserPreferenceCloudService extends BaseCloudService implements PreferenceCloudServiceInterface {
/**
* Gets user preferences
*
* @param appName Name of the target app
* @returns List of user preferences
*/
getPreferences(appName: string): Observable<any> {
if (appName) {
const url = `${this.getBasePath(appName)}/preference/v1/preferences`;
return this.get(url);
} else {
this.logService.error('Appname is mandatory for querying preferences');
return throwError('Appname not configured');
/**
* Gets user preferences
*
* @param appName Name of the target app
* @returns List of user preferences
*/
getPreferences(appName: string): Observable<any> {
if (appName) {
const url = `${this.getBasePath(appName)}/preference/v1/preferences`;
return this.get(url);
} else {
return throwError('Appname not configured');
}
}
}
/**
* Gets user preference.
*
* @param appName Name of the target app
* @param key Key of the target preference
* @returns Observable of user preference
*/
getPreferenceByKey(appName: string, key: string): Observable<any> {
if (appName) {
const url = `${this.getBasePath(appName)}/preference/v1/preferences/${key}`;
return this.get(url);
} else {
this.logService.error('Appname and key are mandatory for querying preference');
return throwError('Appname not configured');
/**
* Gets user preference.
*
* @param appName Name of the target app
* @param key Key of the target preference
* @returns Observable of user preference
*/
getPreferenceByKey(appName: string, key: string): Observable<any> {
if (appName) {
const url = `${this.getBasePath(appName)}/preference/v1/preferences/${key}`;
return this.get(url);
} else {
return throwError('Appname not configured');
}
}
}
/**
* Creates user preference.
*
* @param appName Name of the target app
* @param key Key of the target preference
* @param newPreference Details of new user preference
* @returns Observable of created user preferences
*/
createPreference(appName: string, key: string, newPreference: any): Observable<any> {
if (appName) {
const url = `${this.getBasePath(appName)}/preference/v1/preferences/${key}`;
const payload = JSON.stringify(newPreference);
/**
* Creates user preference.
*
* @param appName Name of the target app
* @param key Key of the target preference
* @param newPreference Details of new user preference
* @returns Observable of created user preferences
*/
createPreference(appName: string, key: string, newPreference: any): Observable<any> {
if (appName) {
const url = `${this.getBasePath(appName)}/preference/v1/preferences/${key}`;
const payload = JSON.stringify(newPreference);
return this.put(url, payload);
} else {
this.logService.error('Appname and key are mandatory for creating preference');
return throwError('Appname not configured');
return this.put(url, payload);
} else {
return throwError('Appname not configured');
}
}
}
/**
* Updates user preference.
*
* @param appName Name of the target app
* @param key Key of the target preference
* @param updatedPreference Details of updated preference
* @returns Observable of updated user preferences
*/
updatePreference(appName: string, key: string, updatedPreference: any): Observable<any> {
return this.createPreference(appName, key, updatedPreference);
}
/**
* Deletes user preference by given preference key.
*
* @param appName Name of the target app
* @param key Key of the target preference
* @returns Observable of delete operation status
*/
deletePreference(appName: string, key: string): Observable<any> {
if (appName) {
const url = `${this.getBasePath(appName)}/preference/v1/preferences/${key}`;
return this.delete(url);
} else {
this.logService.error('Appname and key are mandatory to delete preference');
return throwError('Appname not configured');
/**
* Updates user preference.
*
* @param appName Name of the target app
* @param key Key of the target preference
* @param updatedPreference Details of updated preference
* @returns Observable of updated user preferences
*/
updatePreference(appName: string, key: string, updatedPreference: any): Observable<any> {
return this.createPreference(appName, key, updatedPreference);
}
/**
* Deletes user preference by given preference key.
*
* @param appName Name of the target app
* @param key Key of the target preference
* @returns Observable of delete operation status
*/
deletePreference(appName: string, key: string): Observable<any> {
if (appName) {
const url = `${this.getBasePath(appName)}/preference/v1/preferences/${key}`;
return this.delete(url);
} else {
return throwError('Appname not configured');
}
}
}
}