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 { return this.http.get(this.base); } create(name: string): Observable { return this.http.post(this.base, { name }); } rotateToken(botId: string): Observable { return this.http.post<{ token: string }>(`${this.base}/${botId}/rotate-token`, null) .pipe(map(r => r.token)); } delete(botId: string): Observable { return this.http.delete(`${this.base}/${botId}`); } }