
import { Injectable } from '@angular/core';
import { environment } from '../../../environments/environment';
import { Observable } from 'rxjs';
import { HttpHeaders, HttpClient } from '@angular/common/http';
import { Plugins } from './plugin';

@Injectable({
  providedIn: 'root'
})
export class PluginService {
  baseUrl: string = environment.serviceUrl;

  constructor(private httpClient: HttpClient) {
  }

  Get(): Observable<any> {
    return this.httpClient.get<any>(this.baseUrl + 'api/PluginApi');
  }
  GetActive(): Observable<any> {
    return this.httpClient.get<any>(this.baseUrl + 'api/PluginApi/GetActivePlugin');
  }
  Post(Plugin: Plugins): Observable<any> {
    let header = new HttpHeaders();
    header = header.set('Content-Type', 'application/json; charset=utf-8');
    return this.httpClient.post(this.baseUrl + 'api/PluginApi/add', Plugin, { headers: header, observe: 'response' });
  }
  Delete(Plugin: Plugins) {
    let header = new HttpHeaders();
    header = header.set('Content-Type', 'application/json; charset=utf-8');
    return this.httpClient.post(this.baseUrl + 'api/PluginApi/activeordeactive',
      Plugin, { headers: header, observe: 'response' });
  }
  Put(Plugin: Plugins): Observable<any> {
    let header = new HttpHeaders();
    header = header.set('Content-Type', 'application/json; charset=utf-8');
    return this.httpClient.post(this.baseUrl + 'api/PluginApi/Update', Plugin, { headers: header, observe: 'response' });
  }
}

