import { HttpClient, HttpParams } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; import { EventInputDTO } from './model/eventInputDTO'; import { SessionStore } from 'src/app/store/session.service'; import { SharedCalendarListOutputDTO, SharedCalendarListOutputDTOSchema } from './model/sharedCalendarOutputDTO'; import { HttpService } from '../../http.service'; import { APIReturn } from '../../decorator/api-validate-schema.decorator'; import { TracingType } from '../../monitoring/opentelemetry/tracer'; import { EventListOutputDTO, EventListOutputDTOSchema } from './model/eventListDTOOutput'; import { EventOutputDTO } from './model/eventDTOOutput'; @Injectable({ providedIn: 'root' }) export class AgendaDataService { private baseUrl = 'https://gdapi-dev.dyndns.info/stage/api/v2'; // Your base URL constructor( private http: HttpClient, private httpService: HttpService ) { } getContacts(value: string): Observable { const params = new HttpParams().set('value', value); return this.http.get(`${this.baseUrl}/Contacts`, { params }); } // Documents Endpoints getAttachments(subject: string, applicationType: number): Observable { const params = new HttpParams() .set('Subject', subject) .set('ApplicationType', applicationType.toString()); return this.http.get(`${this.baseUrl}/Documents/Attachments`, { params }); } viewDocument(userId: number, docId: number, applicationId: number): Observable { const params = new HttpParams() .set('userId', userId.toString()) .set('docId', docId.toString()) .set('applicationId', applicationId.toString()); return this.http.get(`${this.baseUrl}/Documents/view`, { params }); } // Events Endpoints createEvent(eventData: EventInputDTO) { return this.http.post(`${this.baseUrl}/Events`, eventData); } // @APIReturn(EventListOutputDTOSchema, 'get/Events') getEvents(userId: number, startDate: string, endDate: string, status: number, category: string, type: string, tracing?: TracingType): Observable { let params = new HttpParams() .set('UserId', userId) if(userId == null || userId == undefined) { throw('userId '+ userId) } if(status != null || status != undefined) { params = params.set('status', status); } if (startDate !== null && startDate !== undefined) { params = params.set('startDate', startDate); } if (endDate !== null && endDate !== undefined) { params = params.set('endDate', endDate); } return this.http.get(`${this.baseUrl}/Events`, { params }); } getEvent(id: string): Observable { return this.http.get(`${this.baseUrl}/Events/${id}`); } updateEvent(id: string, eventData: any): Observable { return this.http.put(`${this.baseUrl}/Events/${id}`, eventData); } approveEvent(id: string): Observable { return this.http.patch(`${this.baseUrl}/Events/${id}/Approval`, {}); } deleteEvent(id: string, deleteAllEvents: boolean): Observable { const params = new HttpParams().set('DeleteAllEvents', deleteAllEvents.toString()); return this.http.delete(`${this.baseUrl}/Events/${id}`, { params }); } updateEventStatus(id: string, statusData: any): Observable { return this.http.patch(`${this.baseUrl}/Events/${id}/Status`, statusData); } addEventAttendee(id: string, attendeeData: any): Observable { return this.http.post(`${this.baseUrl}/Events/${id}/Attendee`, attendeeData); } removeEventAttendee(id: string, attendeeData: any): Observable { return this.http.delete(`${this.baseUrl}/Events/${id}/Attendee`, { body: attendeeData }); } addEventAttachment(id: string, attachmentData: any): Observable { return this.http.post(`${this.baseUrl}/Events/${id}/Attachment`, attachmentData); } removeEventAttachment(id: string, attachmentData: any): Observable { return this.http.delete(`${this.baseUrl}/Events/${id}/Attachment`, { body: attachmentData }); } communicateEvent(id: string, communicationData: any): Observable { return this.http.post(`${this.baseUrl}/Events/${id}/Communicate`, communicationData); } // Users Endpoints getUsers(value: string): Observable { const params = new HttpParams().set('value', value); return this.http.get(`${this.baseUrl}/Users`, { params }); } getToken(): Observable { return this.http.get(`${this.baseUrl}/Users/token`); } getDocumentAttachment(aplicationId,userId,value,PageNumber,PageSize): Observable { const params = new HttpParams() .set('userId', userId) .set('Value', value) .set('PageNumber', PageNumber) .set('PageSize', PageSize); return this.http.get(`${this.baseUrl}/Documents/Attachments${aplicationId}`, {params}); } // @APIReturn(SharedCalendarListOutputDTOSchema, 'Users/${SessionStore.user.UserId}/ShareCalendar') async getSharedCalendar() { return await this.httpService.get(`${this.baseUrl}/Users/${SessionStore.user.UserId}/ShareCalendar`); } }