import { Injectable } from '@angular/core'; import { HttpClient, HttpParams } from '@angular/common/http'; import { Observable } from 'rxjs'; import { Playthrough, PlaythroughCreate } from './campaign.model'; export interface PlaythroughDeletionImpact { sessions: number; characters: number; flags: number; progressions: number; } @Injectable({ providedIn: 'root' }) export class PlaythroughService { private apiUrl = '/api/playthroughs'; constructor(private http: HttpClient) {} listByCampaign(campaignId: string): Observable { const params = new HttpParams().set('campaignId', campaignId); return this.http.get(this.apiUrl, { params }); } getById(id: string): Observable { return this.http.get(`${this.apiUrl}/${id}`); } create(payload: PlaythroughCreate): Observable { return this.http.post(this.apiUrl, payload); } update(id: string, payload: Playthrough): Observable { return this.http.put(`${this.apiUrl}/${id}`, payload); } delete(id: string): Observable { return this.http.delete(`${this.apiUrl}/${id}`); } deletionImpact(id: string): Observable { return this.http.get(`${this.apiUrl}/${id}/deletion-impact`); } }