UNPKG

@pact-foundation/pact

Version:
34 lines (33 loc) 1.92 kB
import type { ConsumerInteraction } from '@pact-foundation/pact-core'; import type { Rules, TemplateHeaders, TemplateQuery } from '../../v3'; import type { V4RequestBuilder } from './types'; export declare class RequestBuilder implements V4RequestBuilder { protected interaction: ConsumerInteraction; constructor(interaction: ConsumerInteraction); query(query: TemplateQuery): V4RequestBuilder; headers(headers: TemplateHeaders): V4RequestBuilder; jsonBody(body: unknown): V4RequestBuilder; xmlBody(body: unknown): V4RequestBuilder; binaryFile(contentType: string, file: string): V4RequestBuilder; /** * Sets the request body as multipart/form-data content. * This is useful for testing APIs that accept file uploads or multipart form submissions. * * @param contentType - The content type of the multipart body (e.g., 'multipart/form-data') * @param file - Path to the file containing the multipart body content * @param mimePartName - The name of the mime part in the multipart body * @param boundary - Optional boundary string for the multipart content. If not provided, will be passed as undefined. * @returns The V4RequestBuilder instance for method chaining */ multipartBody(contentType: string, file: string, mimePartName: string, boundary?: string): V4RequestBuilder; /** * Applies matching rules to the consumer request. * Matching rules allow you to define flexible matching criteria for request attributes * beyond exact equality (e.g., regex patterns, type matching, number ranges). * * @param rules - The matching rules as a strongly typed Rules object. Rules should follow the Pact matching rules format. * @returns The V4RequestBuilder instance for method chaining */ matchingRules(rules: Rules): V4RequestBuilder; body(contentType: string, body: Buffer): V4RequestBuilder; }