import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Quote } from '../_models/index';
import { environment } from '../../environments/environment';

@Injectable()
export class QuotesService {
    constructor(private http: HttpClient) { }


    getById(id: number){
        return this.http.get(environment.apiUrl + 'quotes/' + id);
    }

    getProccessedQuotes(data: any){
        return this.http.get(environment.apiUrl + 'quotes?perPage=' + data.perPage + '&page=' + data.page);
    }

    getProccessedQuotesByDate(data: any){
        return this.http.get(environment.apiUrl + 'quotes?from='+data.from+"&to="+data.to+'&perPage=' + data.perPage + '&page=' + data.page);
    }

    getQuotesByDate(data: any){
        return this.http.get(environment.apiUrl + 'quotes/pending/date?from='+data.from+"&to="+data.to+'&perPage=' + data.perPage + '&page=' + data.page);
    }

    getPendingQuotes(data: any){
        return this.http.get(environment.apiUrl + 'quotes/pending?perPage=' + data.perPage + '&page=' + data.page);
    }

    getFilteredQuotes(data: any){
        return this.http.get(environment.apiUrl + 'quotes/pending?id='+data.id+"&email="+data.email+'&status='+data.status+'&perPage='+data.perPage+'&searchTo='+data.searchTo+'&searchFrom='+data.searchFrom+'&page='+data.page);
    }

    updateQuote(data: any){
        return this.http.post(environment.apiUrl + 'quotes/update', data);
    }

    unlistQuote(data: any){
        console.log(data);
        return this.http.post(environment.apiUrl + 'quotes/unlist', data);
    }

}