import { Injectable } from '@angular/core';
import { ConfigService } from '../../config/config.service';
import { FleioApiService } from '../fleio-api.service';
import { HttpClient } from '@angular/common/http';
import { ISaml2IdentityProviderModel } from '@fleio-api/core/model/saml2-identity-provider.model';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';

@Injectable({
  providedIn: 'root'
})
export class Saml2IdentityProvidersApiService extends FleioApiService<ISaml2IdentityProviderModel> {
  // noinspection JSUnusedGlobalSymbols
  constructor(protected httpClient: HttpClient, protected config: ConfigService) {
    super();
    this.setEndpoint(config.getPanelApiUrl('settings/saml2-identity-providers'));
  }

  fetchMetadataFromUrl(url: string): Observable<{ metadata: string; image_url: string }> {
    return this.postAction(
      'fetch-metadata-from-url', {url},
    );
  }
}
