import ModelCollection from '../ModelCollection'; import type Model from '../Model'; import type { QueryParams } from './BuildsQuery'; import BuildsQuery from './BuildsQuery'; import type { Attributes, SimpleAttributes } from './HasAttributes'; import type { MaybeArray, StaticToThis } from '../../Support/type'; /** * The request methods. */ export type Method = 'CONNECT' | 'connect' | 'DELETE' | 'delete' | 'GET' | 'get' | 'HEAD' | 'head' | 'OPTIONS' | 'options' | 'PATCH' | 'patch' | 'POST' | 'post' | 'PUT' | 'put' | 'TRACE' | 'trace'; /** * Key-value pairs of headers where the values can be an array of values. * Each value is appended to the outgoing headers. */ export type CustomHeaders = Record>; export default class CallsApi extends BuildsQuery { /** * The basic endpoint that model queries. * * @type {string} * * @protected */ protected get endpoint(): string; /** * The endpoint used when querying the api. * * @protected */ protected mutatedEndpoint: string; /** * Boolean flag indicating whether there is an ongoing request or not. * * @type {boolean} */ get loading(): boolean; /** * Indication of the number of request currently ongoing on this class. * * @private * * @type {number} */ private requestCount; constructor(); /** * The call method that mediates between the model and api handlers. * * @param {Method} method * @param {object=} data * @param {object=} customHeaders * * @protected * * @return {Promise} */ call(method: 'GET' | 'get' | 'HEAD' | 'head' | 'OPTIONS' | 'options' | 'TRACE' | 'trace', data?: QueryParams | SimpleAttributes, customHeaders?: CustomHeaders): Promise; call(method: Exclude, data?: FormData | SimpleAttributes | SimpleAttributes, customHeaders?: CustomHeaders): Promise; /** * Access the data property if exists. * * @param {any} response * * @private * * @return {any} */ private getDataFromResponse; /** * Send a GET request to the endpoint. * * @param {object=} queryParameters - append and/or overwrite query parameter values. * * @return {Promise} - of Model|ModelCollection * @ts-expect-error - despite TS2526, it still infers correctly */ get | T), T extends Model = this>(queryParameters?: QueryParams & Record): Promise; /** * The get method made available as a static method. * * @param {object=} queryParameters - append and/or overwrite query parameter values. * * @see CallsApi.prototype.get */ static get(this: T, queryParameters?: QueryParams & Record): Promise | T['prototype']>; /** * Send a POST request to the endpoint. * * @param {object} data * * @return {Promise} * @ts-expect-error - despite TS2526, it still infers correctly */ post(data: FormData | SimpleAttributes | SimpleAttributes): Promise; /** * Send a PUT request to the endpoint. * * @param {object} data * * @return {Promise} * @ts-expect-error - despite TS2526, it still infers correctly */ put(data: FormData | SimpleAttributes | SimpleAttributes): Promise; /** * Send a PATCH request to the endpoint. * * @param {object} data * * @return {Promise} * @ts-expect-error - despite TS2526, it still infers correctly */ patch(data: FormData | SimpleAttributes | SimpleAttributes): Promise; /** * Send a DELETE request to the endpoint. * Returns true on success otherwise false. * * @param {object=} data * * @return {Promise} * @ts-expect-error - despite TS2526, it still infers correctly */ delete(data?: FormData | SimpleAttributes | SimpleAttributes): Promise; /** * Determine whether to return this or a new model from the response. * * @param {object|any} responseData * * @private * * @return {Model|this} */ private getResponseModel; /** * Parse the data into a model or model collection. * * @param {object} data * * @protected * * @return {Model} */ protected newInstanceFromResponseData(data: Attributes[]): ModelCollection; protected newInstanceFromResponseData(data: Attributes): T; protected newInstanceFromResponseData(data: MaybeArray>): ModelCollection | T; /** * Set the last synced at attribute. * This is only expected to be used * when mocking model to look * like it exists. * * @param {any} to * * @protected * * @return {this} */ setLastSyncedAt(to?: unknown): this; /** * Set the endpoint for the model. * * @param {string} url * * @return {string} */ setEndpoint(url: string): this; /** * Set the correct endpoint with the id for the next request. * * @return this */ setModelEndpoint(): this; /** * Get the endpoint for the model. * * @return {string} */ getEndpoint(): string; /** * Reset the endpoint to the original expected string. * * @return {this} */ resetEndpoint(): this; /** * Add a string to the end of the string. * * @param string * * @return {this} */ appendToEndpoint(string: string): this; } //# sourceMappingURL=CallsApi.d.ts.map