import type { AxiosRequestConfig } from 'axios' ; import type { HttpClient } from '../../http' ; import type { IdentityProvider } from './IdentityProvider' ; import type { IdentityProviders } from './IdentityProviders' ; export class IdentityProviderAPI { constructor ( private readonly client ) { } public static readonly URL = { METADATA : 'metadata' , PROVIDER : '/identity-providers' , SSO : '/sso' , } ; public async getIdentityProvider ( identityProviderId ) { const config = { method : 'get' , url : `${ IdentityProviderAPI . URL . PROVIDER }/${ identityProviderId }` , } ; const response = await this . client . sendJSON < IdentityProvider > ( config ) ; return response . data ; } public async getIdentityProviders ( ) { const config = { method : 'get' , url : `${ IdentityProviderAPI . URL . PROVIDER }` , } ; const response = await this . client . sendJSON < IdentityProviders > ( config ) ; return response . data ; } public async deleteIdentityProvider ( identityProviderId , force ? ) { const config = { method : 'delete' , url : `${ IdentityProviderAPI . URL . PROVIDER }/${ identityProviderId }` , } ; if ( force ) { config . params = { force } ; } await this . client . sendJSON ( config ) ; } public async postIdentityProvider ( identityData , replaceProviderId ? ) { const config = { data : identityData , method : 'post' , url : `${ IdentityProviderAPI . URL . PROVIDER }` , } ; if ( replaceProviderId ) { config . params = { replaces : replaceProviderId } ; } const response = await this . client . sendXML < IdentityProvider > ( config ) ; return response . data ; } public async putIdentityProvider ( identityData ) { const config = { data : identityData , method : 'put' , url : `${ IdentityProviderAPI . URL . PROVIDER }` , } ; const response = await this . client . sendXML < IdentityProvider > ( config ) ; return response . data ; } public async getMetadata ( ) { const config = { method : 'get' , url : `${ IdentityProviderAPI . URL . SSO }/${ IdentityProviderAPI . URL . METADATA }` , } ; const response = await this . client . sendJSON < string > ( config ) ; return response . data ; } }