feat: new tourment and add bot

This commit is contained in:
Lala, Shahd
2026-05-31 21:28:40 +00:00
parent bae4958776
commit e3b87a7a1a
29 changed files with 1771 additions and 85 deletions
+27
View File
@@ -0,0 +1,27 @@
import { Injectable, inject } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable, map } from 'rxjs';
import { Bot, BotWithToken } from '../models/bot.models';
@Injectable({ providedIn: 'root' })
export class BotService {
private readonly http = inject(HttpClient);
private readonly base = '/api/account/bots';
list(): Observable<Bot[]> {
return this.http.get<Bot[]>(this.base);
}
create(name: string): Observable<BotWithToken> {
return this.http.post<BotWithToken>(this.base, { name });
}
rotateToken(botId: string): Observable<string> {
return this.http.post<{ token: string }>(`${this.base}/${botId}/rotate-token`, null)
.pipe(map(r => r.token));
}
delete(botId: string): Observable<void> {
return this.http.delete<void>(`${this.base}/${botId}`);
}
}