import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders, HttpParams, HttpResponse } from '@angular/common/http';
import { Observable } from 'rxjs';

import { SERVER_API_URL } from 'app/app.constants';

export type ExerciseInfo = {
    title: string;
    gitLabProjectId: string;
    gitLabURI: string;
    keywords: Array<string>;
};
export type ShoppingBasket = {
    exerciseInfo: Array<ExerciseInfo>;
};

@Injectable({ providedIn: 'root' })
export class SharingDemoService {
    public resourceUrl = SERVER_API_URL + 'api/exercise/';

    constructor(private http: HttpClient) {}

    loadExerciseREADME(exerciseId: string, filePath: string): Observable<string> {
        const options: HttpParams = new HttpParams();
        options.append('filePath', filePath);

        return this.http.get<string>(this.resourceUrl + exerciseId + '/README.md', {
             params: new HttpParams().set('filePath', filePath)},);
    }
    
}