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

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

  constructor(private httpClient: HttpClient) {
  }

  Get(): Observable<any> {
    let header = new HttpHeaders();
    header = header.set('Content-Type', 'application/json; charset=utf-8');
    return this.httpClient.get<any>(this.baseUrl + 'api/AppUrlApi', { headers: header, observe: 'response' });
  }
  GetActive(): Observable<any> {
    return this.httpClient.get<any>(this.baseUrl + 'api/AppUrlApi/GetActiveAppUrl');
  }
  Post(appurl: AppUrl): Observable<any> {

    let header = new HttpHeaders();
    header = header.set('Content-Type', 'application/json; charset=utf-8');
    return this.httpClient.post(this.baseUrl + 'api/AppUrlApi/add', appurl, { headers: header, observe: 'response' });
  }
  Delete(appurl: AppUrl) {
    let header = new HttpHeaders();
    header = header.set('Content-Type', 'application/json; charset=utf-8');
    return this.httpClient.post(this.baseUrl + 'api/AppUrlApi/activeordeactive',
    appurl, { headers: header, observe: 'response' });
  }
  Put(appurl: AppUrl): Observable<any> {
    let header = new HttpHeaders();
    header = header.set('Content-Type', 'application/json; charset=utf-8');
    return this.httpClient.post(this.baseUrl + 'api/AppUrlApi/Update', appurl, { headers: header, observe: 'response' });
  }

}
