add message repository

This commit is contained in:
Peter Maquiran
2024-06-04 13:12:38 +01:00
parent e8d68c45d7
commit 4fb5bfc4d0
2 changed files with 81 additions and 0 deletions
@@ -0,0 +1,28 @@
import { Injectable } from '@angular/core';
import { HttpService } from 'src/app/services/http.service';
import { MessageOutPutDTO } from '../../dto/message/messageOutputDTO';
import { MessageListInputDTO } from '../../dto/message/messageListInputDTO';
@Injectable({
providedIn: 'root'
})
export class MessageRemoteDataSourceService {
private baseUrl = 'https://gdapi-dev.dyndns.info/stage/api/v2/Chat'; // Your base URL
constructor(private httpService: HttpService) {}
async sendMessage(message: any) {
return await this.httpService.post<any>(`${this.baseUrl}/Messages`, message);
}
async reactToMessage(id: string, reaction: any) {
return await this.httpService.post<any>(`${this.baseUrl}/Messages/${id}/React`, reaction);
}
async getMessagesFromRoom(id: MessageListInputDTO) {
return await this.httpService.get<MessageOutPutDTO>(`${this.baseUrl}/Room/${id}/Messages`);
}
}