@kontent-ai/delivery-sdk
Version:
Official Kontent.AI Delivery API SDK
70 lines (69 loc) • 2.38 kB
TypeScript
import { IHeader, IQueryParameter } from '@kontent-ai/core-sdk';
import { IDeliveryClientConfig } from '../../config';
import { ClientTypes, IDeliveryNetworkResponse, IKontentResponse, IQueryConfig } from '../../models';
import { QueryService } from '../../services';
export declare abstract class BaseQuery<TClientTypes extends ClientTypes, TResponse extends IKontentResponse, TQueryConfig extends IQueryConfig, TContract> {
protected config: IDeliveryClientConfig;
protected queryService: QueryService<TClientTypes>;
protected parameters: IQueryParameter[];
protected customUrl?: string;
protected abstract _queryConfig: TQueryConfig;
constructor(config: IDeliveryClientConfig, queryService: QueryService<TClientTypes>);
/**
* Gets URL of the query
*/
abstract getUrl(): string;
/**
* Gets promise for query execution
*/
abstract toPromise(): Promise<IDeliveryNetworkResponse<TResponse, TContract>>;
/**
* Maps json data to response
*/
abstract map(json: any): TResponse;
/**
* Adds custom parameter to query
* @param name Name of parameter
* @param value Value of parameter
*/
withCustomParameter(name: string, value: string): this;
/**
* Adds parameter to query
* @param name Name of parameter
* @param value Value of parameter
*/
withParameter(parameter: IQueryParameter): this;
/**
* Adds parameters to query
* @param parameters Array of parameters
*/
withParameters(parameters: IQueryParameter[]): this;
/**
* Gets headers used by this query
*/
getHeaders(): IHeader[];
/**
* Sets request headers
*/
withHeaders(headers: IHeader[]): this;
/**
* Sets request header
*/
withHeader(header: IHeader): this;
/**
* Sets custom URL of request (overrides default URL of the query)
*/
withCustomUrl(url: string): this;
/**
* Gets all query parameter currently applied to query
*/
getParameters(): IQueryParameter[];
/**
* Used to configure query
* @param queryConfig Query configuration
*/
queryConfig(queryConfig: TQueryConfig): this;
protected resolveUrlInternal(action: string): string;
protected processDefaultLanguageParameter(): void;
protected processExcludeArchivedItemsParameter(): void;
}