import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';

import { ApiService } from './api.service';
import { Canopy, CanopyBySize, CanopyByYear, CanopyModelBySize, CanopyModelByYear } from 'src/app/core/models';

@Injectable({ providedIn: 'root' })
export class CanopiesService {
    constructor(
        private apiService: ApiService
    ) { }

    getAllBySize(): Observable<Array<CanopyBySize>> {
        return this.apiService.get('/canopies/allBySize')
            .pipe(map(data => data.canopies));
    }

    getAllByYear(): Observable<Array<CanopyByYear>> {
        return this.apiService.get('/canopies/allByYear')
            .pipe(map(data => data.canopies));
    }

    getAllModelBySize(): Observable<Array<CanopyModelBySize>> {
        return this.apiService.get('/canopies/allModelBySize')
            .pipe(map(data => data.canopies));
    }

    getAllModelByYear(): Observable<Array<CanopyModelByYear>> {
        return this.apiService.get('/canopies/allModelByYear')
            .pipe(map(data => data.canopies));
    }

}