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

@Injectable({
  providedIn: 'root'
})
export class FeatureService {
  baseUrl: string = environment.serviceUrl;
  constructor(private httpClient: HttpClient) { }

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