import { Injectable, Inject } from '@angular/core';
import { HttpClient, HttpParams } from '@angular/common/http';
import { DirUser } from '../../models/user-management.api.models';
import { ApiService } from './user-management.api.service';
import { Observable } from 'rxjs/internal/Observable';
import { UrlService } from './url.service';

@Injectable({
  providedIn: 'root'
})
export class DirUserService extends ApiService<DirUser> {
  constructor(http: HttpClient, urlService : UrlService) {
    super(http, urlService.apiRoute.dirUser);
  }

  override getAll(groupName?: string): Observable<DirUser[]> {
    let params = new HttpParams();
    if (groupName) {
      params = params.set('groupName', groupName);
    }

    return this.http.get<DirUser[]>(this.baseUrl, { params, withCredentials: true });
  }
}