mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
create room
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Result } from 'neverthrow';
|
||||
import { HttpService } from 'src/app/services/http.service';
|
||||
import { RoomListOutPutDTO } from '../../dto/room/roomListOutputDTO';
|
||||
import { RoomInputDTO, RoomInputDTOSchema } from '../../dto/room/roomInputDTO';
|
||||
import { RoomOutPutDTO } from '../../dto/room/roomOutputDTO';
|
||||
import { AddMemberToRoomInputDTO, AddMemberToRoomInputDTOSchema } from '../../dto/room/addMemberToRoomInputDto';
|
||||
import { ValidateSchema } from 'src/app/services/decorators/validate-schema.decorator';
|
||||
import { DataSourceReturn } from '../../../type';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class RoomRemoteDataSourceService {
|
||||
|
||||
private baseUrl = 'https://gdapi-dev.dyndns.info/stage/api/v2/Chat'; // Your base URL
|
||||
|
||||
constructor(private httpService: HttpService) {}
|
||||
|
||||
|
||||
@ValidateSchema(RoomInputDTOSchema)
|
||||
async createRoom(data: RoomInputDTO): DataSourceReturn<RoomOutPutDTO> {
|
||||
return await this.httpService.post<RoomOutPutDTO>(`${this.baseUrl}/Room`, data);
|
||||
}
|
||||
|
||||
async getRoomList(): Promise<Result<RoomListOutPutDTO ,any>> {
|
||||
return await this.httpService.get<any>(`${this.baseUrl}/Room`);
|
||||
}
|
||||
|
||||
async getRoom(id: string): Promise<Result<any ,any>> {
|
||||
return await this.httpService.get<any>(`${this.baseUrl}/Room/${id}`);
|
||||
}
|
||||
|
||||
async updateRoom(id: string, room: any): Promise<Result<any ,any>> {
|
||||
return await this.httpService.put<any>(`${this.baseUrl}/Room/${id}`, room);
|
||||
}
|
||||
|
||||
async deleteRoom(id: string): Promise<Result<any ,any>> {
|
||||
return await this.httpService.delete<any>(`${this.baseUrl}/Room/${id}`);
|
||||
}
|
||||
|
||||
@ValidateSchema(AddMemberToRoomInputDTOSchema)
|
||||
async addMemberToRoom(data: AddMemberToRoomInputDTO): DataSourceReturn<AddMemberToRoomInputDTO> {
|
||||
return await this.httpService.post<any>(`${this.baseUrl}/Room/${data.id}/Member`, data.member);
|
||||
}
|
||||
|
||||
async removeMemberFromRoom(id: string, member: any): Promise<Result<any ,any>> {
|
||||
return await this.httpService.delete<any>(`${this.baseUrl}/Room/${id}/Member`);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user