import { Injectable } from '@angular/core'; import { ActionsCreateInput } from 'src/app/core/actions/use-case/actions-create-use-case.service'; import { ActionGetAllOutPut } from 'src/app/core/actions/use-case/actions-get-all-use-case.service'; import { ActionsUpdateInput } from 'src/app/core/actions/use-case/actions-update-use-case.service'; import { PublicationGetDocumentByProcessIdOutPut } from 'src/app/core/actions/use-case/publication-get-documents-by-document-id.service'; import { PublicationListByProcessIdOutPut } from 'src/app/core/actions/use-case/publication-list-by-process-id.service'; import { HttpService } from 'src/app/infra/http/http.service'; import { ApiResponse } from 'src/app/infra/http/type'; import { environment } from 'src/environments/environment'; @Injectable({ providedIn: 'root' }) export class ActionRemoteRepositoryService { private baseUrl = `${environment.apiURLStage.slice(0, -1)}/PresidentialActions`; // Your base URL constructor( private http: HttpService ) { } async actionGetAll() { return await this.http.get>(`${this.baseUrl}`); } async create(input: ActionsCreateInput) { return await this.http.post>(`${this.baseUrl}`, input); } async update(input: ActionsUpdateInput) { return await this.http.put>(`${this.baseUrl}/${input.processId}`, input); } async postGetListByProcessId(processId: string) { return await this.http.get>(`${this.baseUrl}/${processId}/Posts`); } async postGetDocumentListByProcessId(documentId: number) { var result = await this.http.get>(`${this.baseUrl}/Posts/${documentId}/file`); return result.map((e) => { // Add a new attribute to each item e.data.data = e.data.data.map((item) => ({ ...item, documentId, })); return e; }); } }