// Questo file fa parte di MyTown.
// MyTown è software libero: puoi ridistribuirlo e/o modificarlo secondo
// i termini della GNU Affero General Public License come pubblicata dalla
// Free Software Foundation, versione 3.
// Distribuito senza ALCUNA GARANZIA; vedi la GNU AGPL v3 per i dettagli.
// Copyright (C) Kondor Consulting & Services S.r.l.
// SPDX-License-Identifier: AGPL-3.0-or-later

import { Injectable } from '@angular/core';
import { MonoTypeOperatorFunction, finalize, Observable, of, OperatorFunction, Subject} from 'rxjs'; // necessario per leggere e contenere 
import { catchError, map, tap, switchMap } from 'rxjs/operators'; // permette di rintracciare errori 
import { HttpClient } from '@angular/common/http';

import { ConfigService } from './config.service';

@Injectable({
  providedIn: 'root'
})
export class MediaService {

   constructor(private config: ConfigService,
              private http: HttpClient,) {}

            // TO DO (manca anche il get servizio)
  
    uploadImg(formdata: FormData): Observable<any> {
        return this.http.post(`${this.config.bakekaUrl}bakeka/images/upload`, formdata, {  observe: "response" }).pipe(
        map(response => response.body),
    ); }

    removeImg(bk_id: number, deletelist: number[]): Observable<any> {
        return this.http.post(`${this.config.bakekaUrl}bakeka/images/remove/${bk_id}`, deletelist, {  observe: "response" }).pipe(
        map(response => response.body),
    ); }

    getImg(bk_id: number): Observable<any> {
        return this.http.get(`${this.config.bakekaUrl}bakeka/images/get/${bk_id}`, {  observe: "response" }).pipe(
        map(response => response.body),
    ); }
}