/** * Copyright since 2025 Mifos Initiative * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ import { Injectable, inject } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; import { environment } from '../../environments/environment'; import { SimPushComplaintRequest, SimPushComplaintResponse, SimHoldDirectiveRequest, SimHoldDirectiveResponse, SimBulkPushRequest, SimBulkPushResponse, SimBankUpdateRequest, SimBankUpdateResponse, SimVerifyAccountRequest, SimVerifyAccountResponse, SimVerifyTransactionRequest, SimVerifyTransactionResponse, SimComplaintStatusResponse, SimBankPerformanceResponse } from './models/cfcfrms.models'; @Injectable({ providedIn: 'root' }) export class CfcfrmsSimulatorService { private http = inject(HttpClient); private baseUrl = environment.cfcfrmsApiUrl ? environment.cfcfrmsApiUrl.replace('/cfcfrms', '/simulator/cfcfrms') : `${environment.serverUrl}/simulator/cfcfrms`; /** I4C pushes a complaint to the bank (creates a real ticket) */ pushComplaint(payload: SimPushComplaintRequest): Observable { return this.http.post(`${this.baseUrl}/push-complaint`, payload); } /** I4C pushes an urgent hold/freeze directive */ pushHoldDirective(payload: SimHoldDirectiveRequest): Observable { return this.http.post(`${this.baseUrl}/push-hold-directive`, payload); } /** I4C pushes a batch of complaints (max 10) */ pushBulkComplaints(payload: SimBulkPushRequest): Observable { return this.http.post(`${this.baseUrl}/push-bulk-complaints`, payload); } /** Bank reports action taken on a complaint */ receiveBankUpdate(payload: SimBankUpdateRequest): Observable { return this.http.post(`${this.baseUrl}/receive-bank-update`, payload); } /** Bank reports that funds have been moved/escalated */ receiveEscalation(payload: { ticketId: string }): Observable { return this.http.post(`${this.baseUrl}/receive-escalation`, payload); } /** Verify if an account is known/flagged */ verifyAccount(payload: SimVerifyAccountRequest): Observable { return this.http.post(`${this.baseUrl}/verify-account`, payload); } /** Verify a transaction for risk/fraud flags */ verifyTransaction(payload: SimVerifyTransactionRequest): Observable { return this.http.post(`${this.baseUrl}/verify-transaction`, payload); } /** CFCFRMS-side status view for a complaint by reference */ getComplaintStatus(ref: string): Observable { return this.http.get(`${this.baseUrl}/complaint-status/${ref}`); } /** Bank TAT / compliance performance metrics */ getBankPerformance(): Observable { return this.http.get(`${this.baseUrl}/bank-performance`); } }