import { Injectable } from '@angular/core' import { HttpClient, HttpParams } from '@angular/common/http' import { PaperlessDocumentComment } from 'src/app/data/paperless-document-comment' import { AbstractPaperlessService } from './abstract-paperless-service' import { Observable } from 'rxjs' @Injectable({ providedIn: 'root', }) export class DocumentCommentService extends AbstractPaperlessService { constructor(http: HttpClient) { super(http, 'documents') } getComments(id: number): Observable { return this.http.get( this.getResourceUrl(id, 'comments') ) } addComment(id: number, comment): Observable { return this.http.post( this.getResourceUrl(id, 'comments'), { payload: comment } ) } deleteComment( documentId: number, commentId: number ): Observable { let httpParams = new HttpParams() httpParams = httpParams.set('commentId', commentId.toString()) return this.http.delete( this.getResourceUrl(documentId, 'comments'), { params: httpParams } ) } }