/** Angular Imports */ import { Injectable } from '@angular/core'; import { HttpClient, HttpParams } from '@angular/common/http'; /** rxjs Imports */ import { Observable } from 'rxjs'; /** * Clients service. */ @Injectable({ providedIn: 'root' }) export class ClientsService { /** * @param {HttpClient} http Http Client to send requests. */ constructor(private http: HttpClient) { } getFilteredClients(orderBy: string, sortOrder: string, orphansOnly: boolean, displayName: string, officeId?: any): Observable { let httpParams = new HttpParams() .set('displayName', displayName) .set('orphansOnly', orphansOnly.toString()) .set('sortOrder', sortOrder) .set('orderBy', orderBy); if (officeId) { httpParams = httpParams.set('officeId', officeId); } return this.http.get('/clients', { params: httpParams }); } getClients(orderBy: string, sortOrder: string, offset: number, limit: number): Observable { const httpParams = new HttpParams() .set('offset', offset.toString()) .set('limit', limit.toString()) .set('sortOrder', sortOrder) .set('orderBy', orderBy); return this.http.get('/clients', { params: httpParams }); } getClientTemplate(): Observable { return this.http.get('/clients/template'); } getClientData(clientId: string) { return this.http.get(`/clients/${clientId}`); } getClientDataAndTemplate(clientId: string) { const httpParams = new HttpParams() .set('template', 'true') .set('staffInSelectedOfficeOnly', 'true'); return this.http.get(`/clients/${clientId}`, { params: httpParams }); } getClientDatatables() { const httpParams = new HttpParams().set('apptable', 'm_client'); return this.http.get(`/datatables`, { params: httpParams }); } getClientDatatable(clientId: string, datatableName: string) { const httpParams = new HttpParams().set('genericResultSet', 'true'); return this.http.get(`/datatables/${datatableName}/${clientId}`, { params: httpParams }); } addClientDatatableEntry(clientId: string, datatableName: string, data: any) { const httpParams = new HttpParams().set('genericResultSet', 'true'); return this.http.post(`/datatables/${datatableName}/${clientId}`, data, { params: httpParams }); } editClientDatatableEntry(clientId: string, datatableName: string, data: any) { const httpParams = new HttpParams().set('genericResultSet', 'true'); return this.http.put(`/datatables/${datatableName}/${clientId}`, data, { params: httpParams }); } deleteDatatableContent(clientId: string, datatableName: string) { const httpParams = new HttpParams().set('genericResultSet', 'true'); return this.http.delete(`/datatables/${datatableName}/${clientId}`, { params: httpParams }); } getClientAccountData(clientId: string) { return this.http.get(`/clients/${clientId}/accounts`); } getClientChargesData(clientId: string) { const httpParams = new HttpParams().set('pendingPayment', 'true'); return this.http.get(`/clients/${clientId}/charges`, { params: httpParams }); } /** * @param chargeData Charge Data to be waived. */ waiveClientCharge(chargeData: any) { const httpParams = new HttpParams().set('command', 'waive'); return this.http.post(`/clients/${chargeData.clientId}/charges/${chargeData.resourceType}`, chargeData, { params: httpParams }); } /** * Get All Client Cgarges. * @param clientId Client Id of the user. */ getAllClientCharges(clientId: string) { return this.http.get(`/clients/${clientId}/charges`); } getClientSummary(clientId: string) { const httpParams = new HttpParams().set('R_clientId', clientId) .set('genericResultSet', 'false'); return this.http.get(`/runreports/ClientSummary`, { params: httpParams }); } getClientProfileImage(clientId: string) { const httpParams = new HttpParams().set('maxHeight', '150'); return this.http.skipErrorHandler().get(`/clients/${clientId}/images`, { params: httpParams, responseType: 'text' }); } getClientFamilyMembers(clientId: string) { return this.http.get(`/clients/${clientId}/familymembers`); } getClientFamilyMember(clientId: string, familyMemberId: string) { return this.http.get(`/clients/${clientId}/familymembers/${familyMemberId}`); } addFamilyMember(clientId: string, familyMemberData: any) { return this.http.post(`/clients/${clientId}/familymembers`, familyMemberData); } editFamilyMember(clientId: string, familyMemberId: any, familyMemberData: any) { return this.http.put(`/clients/${clientId}/familymembers/${familyMemberId}`, familyMemberData); } deleteFamilyMember(clientId: string, familyMemberId: string) { return this.http.delete(`/clients/${clientId}/familymembers/${familyMemberId}`); } getClientIdentifiers(clientId: string) { return this.http.get(`/clients/${clientId}/identifiers`); } getClientIdentifierTemplate(clientId: string) { return this.http.get(`/clients/${clientId}/identifiers/template`); } addClientIdentifier(clientId: string, identifierData: any) { return this.http.post(`/clients/${clientId}/identifiers`, identifierData); } deleteClientIdentifier(clientId: string, identifierId: string) { return this.http.delete(`/clients/${clientId}/identifiers/${identifierId}`); } getClientIdentificationDocuments(documentId: string) { return this.http.get(`/client_identifiers/${documentId}/documents`); } downloadClientIdentificationDocument(parentEntityId: string, documentId: string) { return this.http.get(`/client_identifiers/${parentEntityId}/documents/${documentId}/attachment`, { responseType: 'blob' }); } uploadClientIdentifierDocument(identifierId: string, documentData: any) { return this.http.post(`/client_identifiers/${identifierId}/documents`, documentData); } getClientDocuments(clientId: string) { return this.http.get(`/clients/${clientId}/documents`); } downloadClientDocument(parentEntityId: string, documentId: string) { return this.http.get(`/clients/${parentEntityId}/documents/${documentId}/attachment`, { responseType: 'blob' }); } uploadClientDocument(clientId: string, documentData: any) { return this.http.post(`/clients/${clientId}/documents`, documentData); } deleteClientDocument(parentEntityId: string, documentId: string) { return this.http.delete(`/clients/${parentEntityId}/documents/${documentId}`); } getClientNotes(clientId: string) { return this.http.get(`/clients/${clientId}/notes`); } createClientNote(clientId: string, noteData: any) { return this.http.post(`/clients/${clientId}/notes`, noteData); } editClientNote(clientId: string, noteId: string, noteData: any) { return this.http.put(`/clients/${clientId}/notes/${noteId}`, noteData); } deleteClientNote(clientId: string, noteId: string) { return this.http.delete(`/clients/${clientId}/notes/${noteId}`); } getAddressFieldConfiguration() { return this.http.get(`/fieldconfiguration/ADDRESS`); } getClientAddressData(clientId: string) { return this.http.get(`/client/${clientId}/addresses`); } getClientAddressTemplate() { return this.http.get(`/client/addresses/template`); } createClientAddress(clientId: string, addressTypeId: string, addressData: any) { return this.http.post(`/client/${clientId}/addresses?type=${addressTypeId}`, addressData); } editClientAddress(clientId: string, addressTypeId: string, addressData: any) { return this.http.put(`/client/${clientId}/addresses?type=${addressTypeId}`, addressData); } executeClientCommand(clientId: string, command: string, data: any): Observable { const httpParams = new HttpParams().set('command', command); return this.http.post(`/clients/${clientId}`, data, { params: httpParams }); } }