///
import { FileWrapper } from '@apimatic/file-wrapper';
import { ApiResponse, AuthenticatorInterface, HttpContext, HttpMethod, HttpRequest, HttpInterceptorInterface, RequestOptions, RetryConfiguration, ApiLoggerInterface, HttpClientInterface, PagedAsyncIterable } from '../coreInterfaces';
import { Schema } from '../schema';
import { PathTemplatePrimitiveTypes, PathTemplateTypes, SkipEncode } from './pathTemplate';
import { ArrayPrefixFunction } from './queryString';
import { prepareArgs } from './validate';
import { RequestRetryOption } from './retryConfiguration';
import { XmlSerializerInterface } from '../xml/xmlSerializer';
import { PathParam } from './pathParam';
export type RequestBuilderFactory = (httpMethod: HttpMethod, path?: string) => RequestBuilder;
export declare function skipEncode(value: T, key?: string): SkipEncode;
export declare function pathParam(value: T, key: string): PathParam;
export type ApiErrorConstructor = new (response: HttpContext, message: string) => any;
export interface ErrorType {
statusCode: number | [number, number];
errorConstructor: new (response: HttpContext, ...args: ErrorCtorArgs) => any;
isTemplate?: boolean;
args: ErrorCtorArgs;
}
export interface ApiErrorFactory {
apiErrorCtor: ApiErrorConstructor;
message?: string | undefined;
}
export interface RequestBuilder {
deprecated(methodName: string, message?: string): void;
prepareArgs: typeof prepareArgs;
method(httpMethodName: HttpMethod): void;
baseUrl(arg: BaseUrlParamType): void;
authenticate(params: AuthParams): void;
appendPath(path: string): void;
appendTemplatePath(strings: TemplateStringsArray, ...args: PathTemplateTypes[]): void;
acceptJson(): void;
accept(acceptHeaderValue: string): void;
contentType(contentTypeHeaderValue: string): void;
header(name: string, value?: unknown): void;
headers(headersToMerge: Record): void;
query(name: string, value: unknown | Record, prefixFormat?: ArrayPrefixFunction): void;
query(parameters?: Record | null, prefixFormat?: ArrayPrefixFunction): void;
form(parameters: Record, prefixFormat?: ArrayPrefixFunction): void;
formData(parameters: Record, prefixFormat?: ArrayPrefixFunction): void;
text(body: string | number | bigint | boolean | null | undefined): void;
json(data: unknown): void;
requestRetryOption(option: RequestRetryOption): void;
xml(argName: string, data: T, rootName: string, schema: Schema): void;
stream(file?: FileWrapper): void;
toRequest(): HttpRequest;
intercept(interceptor: HttpInterceptorInterface): void;
interceptRequest(interceptor: (request: HttpRequest) => HttpRequest): void;
interceptResponse(interceptor: (response: HttpContext) => HttpContext): void;
defaultToError(apiErrorCtor: ApiErrorConstructor, message?: string): void;
validateResponse(validate: boolean): void;
throwOn(statusCode: number | [number, number], errorConstructor: new (response: HttpContext, ...args: ErrorCtorArgs) => any, ...args: ErrorCtorArgs): void;
throwOn(statusCode: number | [number, number], errorConstructor: new (response: HttpContext, ...args: ErrorCtorArgs) => any, isTemplate: boolean, ...args: ErrorCtorArgs): void;
updateByJsonPointer(pointer: string | null, updater: (value: any) => any): RequestBuilder;
paginate(createPagedIterable: (req: this, updater: (req: this) => (pointer: string | null, setter: (value: any) => any) => this) => PagedAsyncIterable): PagedAsyncIterable;
call(requestOptions?: RequestOptions): Promise>;
callAsJson(schema: Schema, requestOptions?: RequestOptions): Promise>;
callAsStream(requestOptions?: RequestOptions): Promise>;
callAsText(requestOptions?: RequestOptions): Promise>;
callAsOptionalText(requestOptions?: RequestOptions): Promise>;
callAsXml(rootName: string, schema: Schema, requestOptions?: RequestOptions): Promise>;
callAsXml(rootName: string, schema: Schema, requestOptions?: RequestOptions): Promise>;
}
export declare class DefaultRequestBuilder implements RequestBuilder {
protected _httpClient: HttpClientInterface;
protected _baseUrlProvider: (arg?: BaseUrlParamType) => string;
protected _apiErrorCtr: ApiErrorConstructor;
protected _authenticationProvider: AuthenticatorInterface;
protected _httpMethod: HttpMethod;
protected _xmlSerializer: XmlSerializerInterface;
protected _retryConfig: RetryConfiguration;
protected _path?: string | undefined;
protected _apiLogger?: ApiLoggerInterface | undefined;
protected _queryParams: Record;
protected _pathParams: Record;
protected _headerParams: Record;
protected _body?: any;
protected _accept?: string;
protected _contentType?: string;
protected _contentTypeOptional?: string;
protected _bodyType?: 'text' | 'json' | 'xml' | 'form' | 'form-data';
protected _formPrefixFormat?: ArrayPrefixFunction;
protected _queryParamsPrefixFormat: Record;
protected _stream?: FileWrapper;
protected _pathStrings?: TemplateStringsArray;
protected _pathArgs?: PathTemplateTypes[];
protected _baseUrlArg?: BaseUrlParamType;
protected _validateResponse: boolean;
protected _interceptors: Array>;
protected _authParams?: AuthParams;
protected _retryOption: RequestRetryOption;
protected _apiErrorFactory: ApiErrorFactory;
protected _errorTypes: Array>;
prepareArgs: typeof prepareArgs;
constructor(_httpClient: HttpClientInterface, _baseUrlProvider: (arg?: BaseUrlParamType) => string, _apiErrorCtr: ApiErrorConstructor, _authenticationProvider: AuthenticatorInterface, _httpMethod: HttpMethod, _xmlSerializer: XmlSerializerInterface, _retryConfig: RetryConfiguration, _path?: string | undefined, _apiLogger?: ApiLoggerInterface | undefined);
authenticate(params: AuthParams): void;
requestRetryOption(option: RequestRetryOption): void;
deprecated(methodName: string, message?: string): void;
appendTemplatePath(strings: TemplateStringsArray, ...args: PathTemplateTypes[]): void;
method(httpMethodName: HttpMethod): void;
baseUrl(arg: BaseUrlParamType): void;
appendPath(path: string): void;
acceptJson(): void;
accept(acceptHeaderValue: string): void;
contentType(contentTypeHeaderValue: string): void;
header(name: string, value?: unknown): void;
headers(headersToMerge: Record): void;
query(name: string, value: unknown | Record, prefixFormat?: ArrayPrefixFunction): void;
query(parameters?: Record | null, prefixFormat?: ArrayPrefixFunction): void;
private setPrefixFormats;
private setQueryParams;
text(body: string | number | bigint | boolean | null | undefined): void;
json(data: unknown): void;
xml(argName: string, data: T, rootName: string, schema: Schema): void;
stream(file?: FileWrapper): void;
form(parameters: Record, prefixFormat?: ArrayPrefixFunction): void;
formData(parameters: Record, prefixFormat?: ArrayPrefixFunction): void;
toRequest(): HttpRequest;
intercept(interceptor: HttpInterceptorInterface): void;
interceptRequest(interceptor: (httpRequest: HttpRequest) => HttpRequest): void;
interceptResponse(interceptor: (response: HttpContext) => HttpContext): void;
defaultToError(apiErrorCtor: ApiErrorConstructor, message?: string): void;
validateResponse(validate: boolean): void;
throwOn(statusCode: number | [number, number], errorConstructor: new (response: HttpContext, ...args: ErrorCtorArgs) => any, ...args: ErrorCtorArgs): void;
call(requestOptions?: RequestOptions): Promise>;
callAsText(requestOptions?: RequestOptions): Promise>;
callAsOptionalText(requestOptions?: RequestOptions): Promise>;
callAsStream(requestOptions?: RequestOptions): Promise>;
callAsJson(schema: Schema, requestOptions?: RequestOptions): Promise>;
callAsXml(rootName: string, schema: Schema, requestOptions?: RequestOptions): Promise>;
paginate(createPagedIterable: (req: this, updater: (req: this) => (pointer: string | null, setter: (value: any) => any) => this) => PagedAsyncIterable): PagedAsyncIterable;
updateByJsonPointer(pointer: string | null, updater: (value: any) => any): RequestBuilder;
private _clone;
private cloneParameters;
private _addResponseValidator;
private _addApiLoggerInterceptors;
private _getQueryUrl;
private _buildPath;
private _getHttpRequestHeaders;
private _getHttpRequestBody;
private _addAuthentication;
private _addRetryInterceptor;
private _addErrorHandlingInterceptor;
}
export declare function createRequestBuilderFactory(httpClient: HttpClientInterface, baseUrlProvider: (arg?: BaseUrlParamType) => string, apiErrorConstructor: ApiErrorConstructor, authenticationProvider: AuthenticatorInterface, retryConfig: RetryConfiguration, xmlSerializer?: XmlSerializerInterface, apiLogger?: ApiLoggerInterface): RequestBuilderFactory;
//# sourceMappingURL=requestBuilder.d.ts.map