Files
cbsnexora/src/app/clients/clients.service.ts
T
Jivjyot SinghandAbhay Chawla 0cd987cabf feat: client notes page
- add notes-tab.component
- add edit-note-dialog.coponent

fixes: #111
2019-12-01 23:20:51 +03:00

107 lines
3.5 KiB
TypeScript

/** 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) { }
getClients(): Observable<any> {
const httpParams = new HttpParams().set('orderBy', 'id');
return this.http.get('/clients', { params: httpParams });
}
getClientTemplate(): Observable<any> {
return this.http.get('/clients/template');
}
getClientData(clientId: string) {
return this.http.get(`/clients/${clientId}`);
}
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 });
}
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.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`);
}
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);
}
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}`);
}
}