/** Angular Imports */ import { Injectable } from '@angular/core'; import { HttpClient, HttpParams } from '@angular/common/http'; /** rxjs Imports */ import { Observable } from 'rxjs'; /** * Fixed Deposits Service. */ @Injectable({ providedIn: 'root' }) export class FixedDepositsService { /** * @param {HttpClient} http HttpClient */ constructor(private http: HttpClient) {} /** * @param accountId Account Id. * @returns {Observable} Fixed Deposits data. */ getFixedDepositsAccountData(accountId: string): Observable { const httpParams = new HttpParams().set('associations', 'all'); return this.http.get(`/fixeddepositaccounts/${accountId}`, { params: httpParams }); } /** * @param {string} accountId fixed deposits account Id * @returns {Observable} */ deleteFixedDepositsAccount(accountId: string): Observable { return this.http.delete(`/fixeddepositaccounts/${accountId}`); } /** * @param {string} accountId Account Id * @param {string} command Command * @param {any} data Data * @returns {Observable} */ executeFixedDepositsAccountCommand(accountId: string, command: string, data: any): Observable { const httpParams = new HttpParams().set('command', command); return this.http.post(`/fixeddepositaccounts/${accountId}`, data, { params: httpParams }); } /** * @param {string} accountId Fixed Deposits Account Id * @param {string} transactionId Transaction Id * @returns {Observable} */ getFixedDepositsAccountTransaction(accountId: string, transactionId: string): Observable { return this.http.get(`/fixeddepositaccounts/${accountId}/transactions/${transactionId}`); } /** * @param {string} accountId Fixed Deposits Account Id * @param {string} command Command * @param {any} data Data * @param {string} transactionId Transaction Id * @returns {Observable} */ executeFixedDepositsAccountTransactionsCommand(accountId: string, command: string, data: any, transactionId?: any): Observable { const httpParams = new HttpParams().set('command', command); return this.http.post(`/fixeddepositaccounts/${accountId}/transactions/${transactionId}`, data, { params: httpParams }); } /** * @param {string} accountId Fixed Deposits Account Id * @returns {Observable} */ getFixedDepositsAccountClosureTemplate(accountId: string): Observable { const httpParams = new HttpParams().set('command', 'close'); return this.http.get(`/fixeddepositaccounts/${accountId}/template`, { params: httpParams }); } /** * @param clientId Client Id assosciated with fixed deposits account. * @returns {Observable} Fixed Deposits account template. */ getFixedDepositsAccountTemplate(clientId: string, productId?: string): Observable { let httpParams = new HttpParams().set('clientId', clientId); httpParams = productId ? httpParams.set('productId', productId) : httpParams; return this.http.get('/fixeddepositaccounts/template', { params: httpParams }); } /** * @param {string} accountId Fixed Deposits Account Id * @returns {Observable} */ getFixedDepositsAccountAndTemplate(accountId: any) { const httpParams = new HttpParams().set('associations', 'charges,+linkedAccount') .set('template', 'true'); return this.http.get(`/fixeddepositaccounts/${accountId}`, { params: httpParams }); } /** * @param fixedDepositAccount Fixed Deposit Account * @returns {Observable} */ createFixedDepositAccount(fixedDepositAccount: any): Observable { return this.http.post(`/fixeddepositaccounts`, fixedDepositAccount); } /** * @param {any} accountId Account Id * @param {any} fixedDepositAccount Fixed Deposit Account * @returns {Observable} */ updateFixedDepositAccount(accountId: any, fixedDepositAccount: any): Observable { return this.http.put(`/fixeddepositaccounts/${accountId}`, fixedDepositAccount); } /** * @param clientId Client Id * @param clientName Client Name * @param fromAccountId Account Id * @param locale Locale * @param dateFormat Date Format * @returns {Observable} Standing Instructions */ getStandingInstructions( clientId: string, clientName: string, fromAccountId: string, locale: string, dateFormat: string): Observable { const httpParams = new HttpParams() .set('clientId', clientId) .set('clientName', clientName) .set('fromAccountId', fromAccountId) .set('fromAccountType', '2') .set('locale', locale) .set('dateFormat', dateFormat); return this.http.get(`/standinginstructions`, { params: httpParams }); } }