@o3r/apis-manager
Version:
This module provides services to help you communicate with your APIs. Its responsibility is to provide an API configuration to a service factory so that it could instantiate an API with the right configurations. It contains a default configuration and a m
39 lines • 1.8 kB
TypeScript
import type { ApiClient, ApiName } from '@ama-sdk/core';
/**
* Api manager is responsible to provide an api configuration to a service factory, so that it could instantiate an API
* with the right parameters. It contains a default configuration and a map of specific configurations for API / set of
* API. Configurations are only exposed through the method getConfiguration, which will merge the default configuration
* and the requested one.
*/
export declare class ApiManager {
private defaultConfiguration;
private apiConfigurations;
/**
* Map of registered Api Client associated to specific API
* Warning: This should not be used to get the ApiClient for an API, the function getConfiguration() should be used instead
*/
get registeredApiConfigurations(): {
readonly [key: string]: ApiClient;
};
/**
* Create an API manager using a custom ApiClient
* @param defaultConfiguration
*/
constructor(defaultConfiguration: ApiClient, apiConfigurations?: {
[key: string]: ApiClient;
});
/**
* Retrieve a configuration for a specific API
* @param api API to get the configuration for
* @note When passing a string the configuration is expecting to exist else an error is thrown
* @note when passing an Api instance that does not match a registered configuration, the default one will be returned
*/
getConfiguration(api?: string | ApiName): ApiClient;
/**
* Set or override API configuration
* @param apiClient API configuration to override to the given api
* @param api API name to override, the default configuration will be used if not specified
*/
setConfiguration(apiClient: ApiClient, api?: string | ApiName): void;
}
//# sourceMappingURL=api-manager.d.ts.map