import { HttpClient } from '@angular/common/http';
import { inject, Injectable } from '@angular/core';
import { Book } from '../models/book';

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

  constructor() { }

  private http = inject(HttpClient)

  private backPath = "http://localhost:8080/books"

  addBook(b: Book){
    return this.http.post<number>(`${this.backPath}/addBook`, b)
  }

  likeBook(b: Book){
    return this.http.post<number>(`${this.backPath}/likeBook`, b)
  }

  deleteBook(b: Book){
    return this.http.post<number>(`${this.backPath}/deleteBook`, b)
  }

  getAllBooks(){
    return this.http.get<Book[]>(`${this.backPath}/getAllBooks`)
  }
}
