mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 05:16:07 +00:00
send and receive message
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpService } from 'src/app/services/http.service';
|
||||
import { MessageInputDTO, MessageInputDTOSchema } from '../../dto/message/messageInputDtO';
|
||||
import { ValidateSchema } from 'src/app/services/decorators/validate-schema.decorator';
|
||||
import { APIReturn } from 'src/app/services/decorators/api-validate-schema.decorator';
|
||||
import { MessageOutPutDTO, MessageOutPutDTOSchema } from '../../dto/message/messageOutputDTO';
|
||||
import { MessageListOutput } from '../../dto/message/messageListOutputDTO';
|
||||
import { DataSourceReturn } from 'src/app/services/Repositorys/type';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class MessageRemoteDataSourceService {
|
||||
|
||||
private baseUrl = 'https://gdapi-dev.dyndns.info/stage/api/v2/Chat'; // Your base URL
|
||||
|
||||
constructor(private httpService: HttpService) {}
|
||||
|
||||
@APIReturn(MessageOutPutDTOSchema, 'get/Messages')
|
||||
@ValidateSchema(MessageInputDTOSchema)
|
||||
async sendMessage(data: MessageInputDTO) {
|
||||
return await this.httpService.post<MessageOutPutDTO>(`${this.baseUrl}/Messages`, data);
|
||||
}
|
||||
|
||||
async reactToMessage(id: string, reaction: any) {
|
||||
return await this.httpService.post<any>(`${this.baseUrl}/Messages/${id}/React`, reaction);
|
||||
}
|
||||
|
||||
async getMessagesFromRoom(id: string): DataSourceReturn<MessageListOutput> {
|
||||
return await this.httpService.get(`${this.baseUrl}/Room/${id}/Messages`);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user