import { Injectable, Inject } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';

import { Observable } from 'rxjs';
import { User } from '../model/user.model';
import { API_BASE_URL } from 'src/modules/common/type/injection-token.type';

@Injectable({
  providedIn: 'root'
})
export class UserService {
  constructor(
    @Inject(API_BASE_URL) private apiBaseUrl: string,
    private httpClient: HttpClient
  ) {}

  public getUsers(): Observable<User[]> {
    const headers = new HttpHeaders({
      'Content-Type': 'application/json',
      Accept: 'application/json'
    });

    return this.httpClient.get<User[]>(`${this.apiBaseUrl}/users`, {
      headers: headers
    });
  }
}
