/** Angular Imports */ import { Injectable } from '@angular/core'; import { HttpClient, HttpParams } from '@angular/common/http'; /** rxjs Imports */ import { Observable } from 'rxjs'; import { RunJobWithParamPayloadType } from './manage-jobs/scheduler-jobs/custom-parameters-popover/custom-parameters-popover.component'; /** * System service. */ @Injectable({ providedIn: 'root' }) export class SystemService { emptyPayload: any = {}; /** * @param {HttpClient} http Http Client to send requests. */ constructor(private http: HttpClient) {} /** * @returns {Observable} Data tables. */ getDataTables(): Observable { return this.http.get('/datatables'); } /** * @returns {Observable} Hooks. */ getHooks(): Observable { return this.http.get('/hooks'); } /** * @param {string} hookId Hook ID of Hook. * @returns {Observable} */ getHook(hookId: string): Observable { return this.http.get(`/hooks/${hookId}`); } /** * @returns {Observable} Hooks Template. */ getHooksTemplate(): Observable { return this.http.get('/hooks/template'); } /** * @param {any} hook Hook to be created. * @returns {Observable} */ createHook(hook: any): Observable { return this.http.post('/hooks', hook); } /** * @param {string} hookId Hook ID of Hook to be updated. * @param {any} hook Hook to be updated. * @returns {Observable} */ updateHook(hookId: string, hook: any): Observable { return this.http.put(`/hooks/${hookId}`, hook); } /** * @param {string} hookId Hook ID of Hook to be deleted. * @returns {Observable} */ deleteHook(hookId: string): Observable { return this.http.delete(`/hooks/${hookId}`); } /** * @returns {Observable} Fetches Roles and Permissions */ getRoles(): Observable { return this.http.get('/roles'); } /** * @returns {Observable} Fetches Roles and Permissions */ getRole(roleId: any): Observable { return this.http.get(`/roles/${roleId}/permissions`); } /** * @param role Role. * @param roleId Role ID. * @returns {Observable} */ updateRole(role: any, roleId: string): Observable { return this.http.put(`/roles/${roleId}`, role); } /** * @param roleID Role ID. * @param roleValueChanges Role value changes. * @returns {Observable} */ updateRolePermission(roleId: any, roleValueChanges: any): Observable { return this.http.put(`/roles/${roleId}/permissions`, roleValueChanges); } /** * @param roleId Role ID. * @returns {Observable} */ deleteRole(roleId: string): Observable { return this.http.delete(`/roles/${roleId}`); } /** * @param {any} role Role to be created. * @returns {Observable} */ createRole(role: any): Observable { return this.http.post('/roles', role); } /** * @param roleId Role ID. * @returns {Observable} */ enableRole(roleId: string): Observable { const httpParams = new HttpParams().set('command', 'enable'); return this.http.post(`/roles/${roleId}`, {}, { params: httpParams }); } /** * @param roleId Role ID. * @returns {Observable} */ disableRole(roleId: string): Observable { const httpParams = new HttpParams().set('command', 'disable'); return this.http.post(`/roles/${roleId}`, {}, { params: httpParams }); } /** * @returns {Observable} Fetches Codes. */ getCodes(): Observable { return this.http.get('/codes'); } /** * @param codeId Code ID. * @returns {Observable} Fetches Code. */ getCode(codeId: string): Observable { return this.http.get(`/codes/${codeId}`); } /** * @param code Code. * @param codeId Code ID. * @returns {Observable} */ updateCode(code: any, codeId: string): Observable { return this.http.put(`/codes/${codeId}`, code); } /** * @param codeId Code ID. * @returns {Observable} Code Values. */ getCodeValues(codeId: string): Observable { return this.http.get(`/codes/${codeId}/codevalues`); } /** * @param codeId Code ID. * @param codeValueId Code value ID. * @returns {Observable} */ deleteCodeValue(codeId: string, codeValueId: string): Observable { return this.http.delete(`/codes/${codeId}/codevalues/${codeValueId}`); } /** * @param codeId Code ID. * @param codeValueId Code value ID. * @param codeValueChanges Code value changes. * @returns {Observable} */ updateCodeValue(codeId: string, codeValueId: string, codeValueChanges: any): Observable { return this.http.put(`/codes/${codeId}/codevalues/${codeValueId}`, codeValueChanges); } /** * @param codeId Code ID. * @param codeValueId Code value. * @returns {Observable} */ createCodeValue(codeId: string, codeValue: any): Observable { return this.http.post(`/codes/${codeId}/codevalues`, codeValue); } /** * @param codeId Code ID. * @returns {Observable} */ deleteCode(codeId: string): Observable { return this.http.delete(`/codes/${codeId}`); } /** * @returns {Observable} Fetches Surveys. */ getSurveys(): Observable { return this.http.get('/surveys'); } /** * @param {any} survey Survey to be created. * @returns {Observable} */ createSurvey(survey: any): Observable { return this.http.post('/surveys', survey); } /** * @param {string} reportId Survey ID. * @returns {Observable} Survey. */ getSurvey(surveyId: string): Observable { return this.http.get(`/surveys/${surveyId}?template=true`); } /** * @param {string} surveyId Survey ID. * @param {any} survey Survey Data. * @returns {Observable} */ editSurvey(surveyId: string, survey: any): Observable { return this.http.put(`/surveys/${surveyId}`, survey); } /** * Activates a survey. * @param {number} surveyId Survey ID. * @returns {Observable} */ activateSurvey(surveyId: number): Observable { return this.http.post(`/surveys/${surveyId}?command=activate`, null); } /** * Deactivates a survey. * @param {number} surveyId Survey ID. * @returns {Observable} */ deactivateSurvey(surveyId: number): Observable { return this.http.post(`/surveys/${surveyId}?command=deactivate`, null); } /** * @returns {Observable} Fetches Jobs. */ getJobs(): Observable { return this.http.get('/jobs'); } /** * @returns {Observable} Fetches Jobs. */ getWorkflowJobNames(): Observable { return this.http.get('/jobs/names'); } /** * @returns {Observable} Fetches Jobs. */ getWorkflowJobSteps(jobName: String): Observable { return this.http.get(`/jobs/${jobName}/steps`); } /** * @returns {Observable} Updates Jobs. */ putWorkflowJobSteps(jobName: String, payload: any): Observable { return this.http.put(`/jobs/${jobName}/steps`, payload); } /** * @returns {Observable} Updates Jobs. */ runInlineCOB(jobName: String, payload: any): Observable { return this.http.post(`/jobs/${jobName}/inline`, payload); } /** * @returns {Observable} Fetches Steps. */ getAvailablesJobSteps(jobCategory: String): Observable { return this.http.get(`/jobs/${jobCategory}/available-steps`); } /** * @returns {Observable} Fetches Scheduler. */ getScheduler(): Observable { return this.http.get('/scheduler'); } /** * @param jobId Job Id to be edited * @returns {Observable} Fetches Scheduler Job. */ getSelectedJob(jobId: string): Observable { return this.http.get(`/jobs/${jobId}`); } /** * @param {string} jobId Job ID of Job to be updated. * @param {any} Job Job to be updated. * @returns {Observable} */ runCommandOnScheduler(command: string): Observable { return this.http.post(`/scheduler?command=` + command, this.emptyPayload); } /** * @param {string} jobId Job ID of Job to be updated. * @param {any} Job Job to be updated. * @returns {Observable} */ updateScheduler(jobId: string, job: any): Observable { return this.http.put(`/jobs/${jobId}`, job); } /** * @param {string} jobId Job Id on which jobs to run * @returns {Observable} */ runSelectedJob(jobId: string): Promise { return this.http.post(`/jobs/${jobId}?command=executeJob`, this.emptyPayload, { observe: 'response' }).toPromise(); } /** * @param {string} jobId Job Id on which jobs to run * @returns {Observable} */ runSelectedJobWithParameters(jobId: string, jobParameters: RunJobWithParamPayloadType): Promise { return this.http.post(`/jobs/${jobId}?command=executeJob`, jobParameters, { observe: 'response' }).toPromise(); } /* * @param jobId Job Id to view the history. * @returns {Observable} Fetches History of the Job. */ getHistoryScheduler(jobId: string): Observable { return this.http.get(`/jobs/${jobId}/runhistory`); } /** * @param {any} code Code to be created. * @returns {Observable} */ createCode(code: any): Observable { return this.http.post('/codes', code); } /** * @param {any} dataTable Data Table to be created. * @return {Observable} */ createDataTable(dataTable: any): Observable { return this.http.post('/datatables', dataTable); } /** * @param dataTableName Data Table Name. * @return {Observable} */ getDataTable(dataTableName: string): Observable { return this.http.get(`/datatables/${dataTableName}`); } /** * @param dataTableName Data Table Name. * @return {Observable} */ deleteDataTable(dataTableName: string): Observable { return this.http.delete(`/datatables/${dataTableName}`); } /** * @param dataTable Data Table. * @param dataTableName Data Table Name. * @return {Observable} */ updateDataTable(dataTable: any, dataTableName: string): Observable { return this.http.put(`/datatables/${dataTableName}`, dataTable); } /** * @returns {Observable} Business Date data. */ getBusinessDates(): Observable { return this.http.get('/businessdate'); } /** * @returns {Observable} Business Date data using a type BUSINESS_DATE / COB_DATE. */ getBusinessDate(dateType: string): Observable { return this.http.get(`/businessdate/${dateType}`); } /** * @param {any} dateData Business Date data to be updated. * @returns {Observable} */ updateBusinessDate(dateData: any): Observable { return this.http.post(`/businessdate`, dateData); } /** * @returns {Observable} Configurations data. */ getConfigurations(): Observable { return this.http.get('/configurations'); } /** * @param {string} configurationId Configuration ID of configuration. * @returns {Observable} Configuration. */ getConfiguration(configurationId: string): Observable { return this.http.get(`/configurations/${configurationId}`); } /** * @param {string} configurationId Configuration ID of configuration. * @returns {Observable} Configuration. */ getConfigurationByName(configurationName: string): Observable { return this.http.get(`/configurations/name/${configurationName}`); } /** * @param {string} configurationId Configuration ID of configuration to be updated. * @param {any} configuration Configuration to be updated. * @returns {Observable} */ updateConfiguration(configurationId: string, configuration: any): Observable { return this.http.put(`/configurations/${configurationId}`, configuration); } /** * @param {string} externalConfigurationName External Configuration Name. * @returns {Observable} External Configuration. */ getExternalConfiguration(externalConfigurationName: string): Observable { return this.http.get(`/externalservice/${externalConfigurationName}`); } /** * @param {string} externalConfigurationName External Configuration Name. * @param {any} externalConfiguration External Configuration. * @returns {Observable} */ updateExternalConfiguration(externalConfigurationName: string, externalConfiguration: any): Observable { return this.http.put(`/externalservice/${externalConfigurationName}`, externalConfiguration); } /** * @returns {Observable} Account number preferences. */ getAccountNumberPreferences(): Observable { return this.http.get('/accountnumberformats'); } /** * @returns {Observable} Fetches Account Number Preferences Template. */ getAccountNumberPreferencesTemplate(): Observable { return this.http.get('/accountnumberformats/template'); } /** * @param {string} accountNumberPreferenceId Account Number Preference ID. * @returns {Observable} Fetches Account Number Preference. */ getAccountNumberPreference(accountNumberPreferenceId: string): Observable { return this.http.get(`/accountnumberformats/${accountNumberPreferenceId}`); } /** * @param accountNumberPreference Account Number Preference. * @returns {Observable} */ createAccountNumberPreference(accountNumberPreference: any): Observable { return this.http.post('/accountnumberformats', accountNumberPreference); } /** * @param {string} accountNumberPreferenceId Account Number Preference ID. * @returns {Observable} */ deleteAccountNumberPreference(accountNumberPreferenceId: string): Observable { return this.http.delete(`/accountnumberformats/${accountNumberPreferenceId}`); } /** * @param {string} accountNumberPreferenceId Account Number Preference ID. * @param {any} accountNumberPreferenceChanges Changes in Account Number Preference. * @returns {Observable} */ updateAccountNumberPreference( accountNumberPreferenceId: string, accountNumberPreferenceChanges: any ): Observable { return this.http.put(`/accountnumberformats/${accountNumberPreferenceId}`, accountNumberPreferenceChanges); } /** * @returns {Observable} Reports. */ getReports(): Observable { return this.http.get('/reports'); } /** * @param {string} reportId Report ID. * @returns {Observable} Report. */ getReport(reportId: string): Observable { return this.http.get(`/reports/${reportId}?template=true`); } /** * @returns {Observable} Report Template. */ getReportTemplate(): Observable { return this.http.get('/reports/template'); } /** * @param {any} report Report. * @returns {Observable} */ createReport(report: any): Observable { return this.http.post('/reports', report); } /** * @param {string} reportId Report ID. * @param {any} report Report. * @returns {Observable} */ updateReport(reportId: string, report: any): Observable { return this.http.put(`/reports/${reportId}`, report); } /** * @param {string} reportId Report ID. * @returns {Observable} */ deleteReport(reportId: string): Observable { return this.http.delete(`/reports/${reportId}`); } /** * @param {any} filterBy Properties by which entries should be filtered. * @param {string} orderBy Property by which entries should be sorted. * @param {string} sortOrder Sort order: ascending or descending. * @param {number} offset Page offset. * @param {number} limit Number of entries within the page. * @returns {Observable} Audit Trails. */ getAuditTrails(filterBy: any, orderBy: string, sortOrder: string, offset: number, limit: number): Observable { let httpParams = new HttpParams() .set('offset', offset.toString()) .set('limit', limit.toString()) .set('sortOrder', sortOrder) .set('orderBy', orderBy) .set('paged', 'true'); // filterBy: actionName, entityName, resourceId, makerId, makerDateTimeFrom, makerDateTimeTo, checkerId, checkerDateTimeFrom, checkerDateTimeTo, processingResult filterBy.forEach(function (filter: any) { if (filter.value !== '') { httpParams = httpParams.set(filter.type, filter.value); } }); return this.http.get('/audits', { params: httpParams }); } /** * @param {string} auditTrailId Audit Trail ID. * @returns {Observable} */ getAuditTrail(auditTrailId: string): Observable { return this.http.get(`/audits/${auditTrailId}`); } /** * @returns {Observable} Audit Trail Search Template. */ getAuditTrailSearchTemplate(): Observable { return this.http.get('/audits/searchtemplate'); } /** * @returns {Observable} Fetches Mapping Data. */ getEntityMappings(): Observable { return this.http.get('/entitytoentitymapping'); } /** * @param mappingId Mapping Id. * @param fromId From Entity ID. * @param toId To Entity ID. * @returns {Observable} fetches the list of mappings for particular mapping type */ getEntitytoEntityData(mappingId: number, fromId: number, toId: number): Observable { return this.http.get(`/entitytoentitymapping/${mappingId}/${fromId}/${toId}`); } /** * Get particular Map Data * @param mapId Mapping Id */ getMapIdData(mapId: number): Observable { return this.http.get(`/entitytoentitymapping/${mapId}`); } /** * Creates a new mapping * @param {any} mapType Map id to be created. * @param {any} mapData Map data to be added * @returns {Observable} resolved data */ createMapping(mapType: any, mapData: any): Observable { return this.http.post(`/entitytoentitymapping/${mapType}`, mapData); } /** * Edit a mapping * @param {any} mapType Map id to be edited. * @param {any} mapData Map data to be added * @returns {Observable} resolved data */ editMapping(mapId: any, mapData: any): Observable { return this.http.put(`/entitytoentitymapping/${mapId}`, mapData); } /** * Delete the Map Id * @param mapId Map Id */ deleteMapping(mapId: any): Observable { return this.http.delete(`/entitytoentitymapping/${mapId}`); } /** * @returns {Observable} Offices data */ getOffices(): Observable { return this.http.get('/offices'); } /** * @returns {Observable} Loan products data. */ getLoanProducts(): Observable { return this.http.get('/loanproducts'); } /** * @returns {Observable} Saving products data */ getSavingProducts(): Observable { return this.http.get('/savingsproducts'); } /** * @returns {Observable} Charges data */ getCharges(): Observable { return this.http.get('/charges'); } /** * @returns {Observable} */ getMakerCheckerPermissions(): Observable { const httpParams = new HttpParams().set('makerCheckerable', 'true'); return this.http.get('/permissions', { params: httpParams }); } /** * @param data Maker Checker data * @returns {Observable} */ updateMakerCheckerPermission(data: any): Observable { const httpParams = new HttpParams().set('makerCheckerable', 'true'); return this.http.put('/permissions', data, { params: httpParams }); } /** * @returns {Observable} */ getExternalEventConfiguration(): Observable { return this.http.get('/externalevents/configuration'); } /** * @returns {Observable} */ putExternalEventConfiguration(payload: any): Observable { return this.http.put('/externalevents/configuration', payload); } /** Datatable Entries for Entities */ getEntityDatatables(appTable: string) { const httpParams = new HttpParams().set('apptable', appTable); return this.http.get(`/datatables`, { params: httpParams }); } getEntityDatatable(entityId: string, datatableName: string) { const httpParams = new HttpParams().set('genericResultSet', 'true'); return this.http.get(`/datatables/${datatableName}/${entityId}`, { params: httpParams }); } addEntityDatatableEntry(entityId: string, datatableName: string, data: any) { const httpParams = new HttpParams().set('genericResultSet', 'true'); return this.http.post(`/datatables/${datatableName}/${entityId}`, data, { params: httpParams }); } editEntityDatatableEntry(entityId: string, datatableName: string, data: any) { const httpParams = new HttpParams().set('genericResultSet', 'true'); return this.http.put(`/datatables/${datatableName}/${entityId}`, data, { params: httpParams }); } deleteDatatableContent(entityId: string, datatableName: string) { const httpParams = new HttpParams().set('genericResultSet', 'true'); return this.http.delete(`/datatables/${datatableName}/${entityId}`, { params: httpParams }); } deleteDatatableEntry(entityId: string, rowId: string, datatableName: string) { const httpParams = new HttpParams().set('genericResultSet', 'true'); return this.http.delete(`/datatables/${datatableName}/${entityId}/${rowId}`, { params: httpParams }); } getCOBCatchUpStatus() { return this.http.get(`/loans/is-catch-up-running`); } runCOBCatchUp() { const emptyData = {}; return this.http.post(`/loans/catch-up`, emptyData); } }