import { MaybeCallback } from '../types'; import { Request } from './request'; import { Query } from './query'; export interface Settings { request: Request; query: Query; } /** * Defines an endpoint builder. */ export interface Endpoint { /** * Allows to pre-configure ajax request on the current endpoint. * This configuration settings are applied automatically when `get`, `post`, `put`, `patch` or `delete` * are called to generate an ajax configuration. * * If a configuration object is passed, the currently stored configuration is discarded. * * If a callback is passed, the callback will receive the currenty stored pre-configuration to merge * and return it with it's own modifications. * * @see get * @see post * @see put * @see patch * @see delete * * @param configuration Configuration or callback. */ configure(configuration: MaybeCallback): Endpoint; /** * Returns the URL of the current endpoint. * * @param withoutQuery Excludes any existing query params. */ url(withoutQuery?: boolean): string; /** * Creates a deeper nested endpoint based on the current endpoint. * * @param path Path to the deeper endpoint. */ many(path: string): Endpoint; /** * Creates a deeper nested endpoint based on the current endpoint, * pointing to a single identifiable resource. * * @param id ID of the resource. */ one(id: number | string): Endpoint; /** * Sets query parameters for the current endpoint. * * If a query object is passed, the currently stored query is discarded. * * If a callback is passed, the callback will receive the currenty stored query to merge * and return it with it's own modifications. * * @param query Query or callback */ query(query: MaybeCallback): Endpoint; /** * Generates a GET request configuration for the current endpoint. * * Optionally, an ajax configuration can be passed which will be mergen with the pre-configuration * as with the defaults of a GET request. * * @see configure */ get(): Request; /** * Generates a POST request configuration for the current endpoint. * * Optionally, an ajax configuration can be passed which will be mergen with the pre-configuration * as with the defaults of a POST request. * * @see configure * @param data Data. */ post(data: Data): Request; /** * Generates a POST request configuration for the current endpoint. * * Optionally, an ajax configuration can be passed which will be mergen with the pre-configuration * as with the defaults of a POST request. * * @see configure * * @param data Data. */ post(data: OverrideData): Request; /** * Generates a POST request configuration for the current endpoint. * * Optionally, an ajax configuration can be passed which will be mergen with the pre-configuration * as with the defaults of a POST request. * * @see configure * * @param data Data. */ post(data: OverrideData): Request; /** * Generates a PUT request configuration for the current endpoint. * * Optionally, an ajax configuration can be passed which will be mergen with the pre-configuration * as with the defaults of a PUT request. * * @see configure * @param data Data. */ put(data: Data): Request; /** * Generates a PUT request configuration for the current endpoint. * * Optionally, an ajax configuration can be passed which will be mergen with the pre-configuration * as with the defaults of a PUT request. * * @see configure * @param data Data. */ put(data: OverrideData): Request; /** * Generates a PUT request configuration for the current endpoint. * * Optionally, an ajax configuration can be passed which will be mergen with the pre-configuration * as with the defaults of a PUT request. * * @see configure * @param data Data. */ put(data: OverrideData): Request; /** * Generates a PATCH request configuration for the current endpoint. * * Optionally, an ajax configuration can be passed which will be mergen with the pre-configuration * as with the defaults of a PATCH request. * * @see configure */ patch(): Request; /** * Generates a PATCH request configuration for the current endpoint. * * Optionally, an ajax configuration can be passed which will be mergen with the pre-configuration * as with the defaults of a PATCH request. * * @see configure * @param data Data. */ patch(data: OverrideData): Request; /** * Generates a PATCH request configuration for the current endpoint. * * Optionally, an ajax configuration can be passed which will be mergen with the pre-configuration * as with the defaults of a PATCH request. * * @see configure * @param data Data. */ patch(data: OverrideData): Request; /** * Generates a DELETE request configuration for the current endpoint. * * Optionally, an ajax configuration can be passed which will be mergen with the pre-configuration * as with the defaults of a DELETE request. * * @see configure */ delete(): Request; /** * Generates a DELETE request configuration for the current endpoint. * * Optionally, an ajax configuration can be passed which will be mergen with the pre-configuration * as with the defaults of a DELETE request. * * @see configure */ request(): Request; } /** * Creates a new endpoint. * * @see Endpoint * @param url URL of the endpoint. * @param settings Initial settings. */ export declare function endpoint(url: string, settings?: Partial): Endpoint;