import { Injectable } from '@angular/core';
import { ConfigService } from '../../../config/config.service';
import { FleioApiService } from '../../fleio-api.service';
import { HttpClient } from '@angular/common/http';
import { ITodoModel } from './model/todo.model';
import { Observable } from 'rxjs';
import { FleioId } from '@fleio-api/base-model/base-fleio-object.model';

@Injectable({
  providedIn: 'root'
})
export class TodoApiService extends FleioApiService<ITodoModel> {
  // noinspection JSUnusedGlobalSymbols
  constructor(protected httpClient: HttpClient, protected config: ConfigService) {
    super();
    this.setEndpoint(config.getPanelApiUrl('plugins/todo/todo'));
  }

  addComment(todoId: FleioId, commentText: string, closeTodo: boolean): Observable<any> {
    return this.objectPostAction(todoId, 'add_comment', {
      comment_text: commentText,
      close_todo: closeTodo,
    });
  }
}
