import { Injectable, inject } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; import { Filament } from '../models/filament.model'; /** * API base URL — matches the Extrudex backend default. * TODO: Move to environment config when multi-environment support is added. */ const API_BASE_URL = '/api'; /** * Service for CRUD operations on filament spools. * Communicates with the Extrudex backend SpoolsController. */ @Injectable({ providedIn: 'root' }) export class FilamentService { private readonly http = inject(HttpClient); /** * Fetch all filament spools from the backend. * GET /api/spools */ getFilaments(): Observable { return this.http.get(`${API_BASE_URL}/spools`); } /** * Soft-delete a filament spool by ID. * DELETE /api/spools/{id} * Returns 204 No Content on success. */ deleteFilament(id: string): Observable { return this.http.delete(`${API_BASE_URL}/spools/${id}`); } }