/**
* Provides APIs for making Pega's REST API calls.
* These APIs can be used for different purposes such as validation messages, network failure messages etc.
* @module RestClient
*/
import type { AxiosResponse } from 'axios';
import type { Interceptor, FetchOptions } from '../globals';
import CaseAPIs from './case-apis';
import type { RestAPIPayload } from './types';
/**
* This API provides an entry point to the {@link module:HeaderProcessor} API object.
* This exposes APIs that include:
*
* PCore.getRestClient().getHeaderProcessor().getRegisteredHeaders()
* @function
* @public
*/
export declare const getHeaderProcessor: () => {
registerHeader: (args_0: string) => boolean;
unRegisterHeader: (args_0: string) => void;
getRegisteredHeaders: () => {
[key: string]: string | null | undefined;
};
};
/**
* this function helps to invoke a Pega REST API
* @function invokeRestApi
* @public
* @param routeKey - Route key for REST API e.g. "getFeedMessages"
* @param restAPIPayload - object containing body, header and queryPayload provided for REST API call
* @param context - name of the context eq., primary
* @param options - object containing additional information for invoking a rest endpoint.
* @returns Promise
*
* @example invokeRestApi()
* Below example shows how to use invokeRestApi api to make REST API call to get Feed messages.
* ```
* const { invokeRestApi } = PCore.getRestClient();
* const cancelTokenSource = getCancelTokenSource();
* invokeRestApi('getFeedMessages', {
* queryPayload: {
* filterForContext: 'DATA-PORTAL $SpaceTra',
* filterByContext: 'context'
* },
* body: {},
* headers: {},
* // passing cancel token so that we can cancel the request using cancelTokenSource
* cancelTokenSource: cancelTokenSource.token
* })
* .then(() => {
* // handle the response
* })
* .catch((error) => {
* // handle error
* if(isRequestCanceled(error)) {
* // handle the canceled request using cancelTokenSource.cancel();
* }
* });
*```
*/
export declare const invokeRestApi: (routeKey: string, { body, queryPayload, cancelTokenSource, headers, responseType }: RestAPIPayload, context?: string, options?: FetchOptions) => Promise>;
type RestApiConfigObject = {
/** request method(GET, POST, PUT, PATCH, DELETE) to be used when making the request. Default is 'GET' */
method: string;
/** the custom headers to be sent along with the request. */
headers?: object;
/** data to be sent as the request body. Only applicable for request methods 'PUT', 'POST', and 'PATCH' */
body?: object;
/** The flag that indicates whether default request headers must be sent along with the request. */
withoutDefaultHeaders: boolean;
};
/**
* Invokes a custom REST API using an endpoint URL.
* The custom REST APIs can include external APIs or Pega APIs.
* @function invokeCustomRestApi
* @public
* @param endpointUrl - URL of the REST endpoint. URL can be relative e.g. '/api/dev/v1/insights' or absolute e.g. 'https://cs.rpega.com/prweb/api/dev/v1/insights'
* @param config - The object containing the information required to invoke the custom REST API
* @param context - name of the context e.g. primary
* @returns Promise
*
* @example
Example for invokeCustomRestApi api
* const { invokeCustomRestApi } = PCore.getRestClient();
* invokeCustomRestApi("/api/dev/v1/insights", {
* method: "GET",
* body: {},
* headers: {},
* })
* .then(() => {
* // handle the response
* })
* .catch((error) => {
* // handle error
* });
* // above example shows how to use invokeCustomRestApi api to make REST API call to get Feed messages.
*
*/
export declare const invokeCustomRestApi: (endpointUrl: string, { method, body, headers, withoutDefaultHeaders }: RestApiConfigObject, context: string) => Promise