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

import { ApiService } from '../api.service';
import { DropZoneByOaci, DropZoneByYear } from '@models';

@Injectable({ providedIn: 'root' })
export class DropZonesService {
    private _apiVersion = '/v1';
    constructor(
        private apiService: ApiService
    ) { }

    getAllByOaci(): Observable<Array<DropZoneByOaci>> {
        return this.apiService.get(`${this._apiVersion}/dropzones/allByOaci`)
            .pipe(map(data => data.dropzones));
    }

    getAllByOaciByYear(): Observable<Array<DropZoneByYear>> {
        return this.apiService.get(`${this._apiVersion}/dropzones/allByOaciByYear`)
            .pipe(map(data => data.dropzones));
    }

}