import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { IPopularRequest } from '@typings/popular-request';
import { EndpointService } from '@shared/services/api/endpoint.service';

@Injectable()
export class PopularRequestsApiService {
    constructor(
        private endpointService: EndpointService,
        private http: HttpClient,
    ) {}

    getPopularRequests() {
        const url = this.endpointService.buildCommonURL(
            'getpopular',
            '1',
            'Requests',
        );

        return this.http.get<IPopularRequest[]>(url).toPromise();
    }
}
