import { Injectable } from '@angular/core'; import { HttpService } from 'src/app/services/http.service'; import { MessageListInputDTO } from '../../dto/message/messageListInputDTO'; import { DataSourceReturn } from '../../../type'; import { MessageInputDTO, MessageInputDTOSchema } from '../../dto/message/messageInputDtO'; import { ValidateSchema } from 'src/app/services/decorators/validate-schema.decorator'; import { MessageOutPutDTO } from '../../dto/message/messageOutputDTO'; @Injectable({ providedIn: 'root' }) export class MessageRemoteDataSourceService { private baseUrl = 'https://gdapi-dev.dyndns.info/stage/api/v2/Chat'; // Your base URL constructor(private httpService: HttpService) {} @ValidateSchema(MessageInputDTOSchema) async sendMessage(data: MessageInputDTO) { return await this.httpService.post(`${this.baseUrl}/Messages`, data); } async reactToMessage(id: string, reaction: any) { return await this.httpService.post(`${this.baseUrl}/Messages/${id}/React`, reaction); } async getMessagesFromRoom(id: MessageListInputDTO): DataSourceReturn { return await this.httpService.get(`${this.baseUrl}/Room/${id}/Messages`); } }