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

import { ApiService } from '../api.service';
import { AeronefByImat, AeronefByYear } from '@models';

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

    getAllByImat(): Observable<Array<AeronefByImat>> {
        return this.apiService.get(`${this._apiVersion}/aeronefs/allByImat`)
            .pipe(map(data => data.aeronefs));
    }

    getAllByImatByYear(): Observable<Array<AeronefByYear>> {
        return this.apiService.get(`${this._apiVersion}/aeronefs/allByImatByYear`)
            .pipe(map(data => data.aeronefs));
    }

}