import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Version, VersionRevision } from '../core/entities';
import { Observable } from 'rxjs/Observable';

import { environment } from '../../environments/environment';

const VERSION_REVISIONS_URL = environment.apiUrl + '/api/versionrevisions';

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

	getVersions(): Observable<Array<Version>> {
		return this.http.get<Array<Version>>(`${VERSION_REVISIONS_URL}/versions`);
	}

	findByVersionNumber(versionNumber: string): Observable<Array<VersionRevision>> {
		return this.http.get<Array<VersionRevision>>(`${VERSION_REVISIONS_URL}/${versionNumber}`);
	}
}
