import { QueryParams, RequestOptions } from './potion'; export interface ItemOptions { 'readonly'?: string[]; } export declare type ItemFetchOptions = Pick; export declare type ItemQueryOptions = Pick; export interface ItemInitArgs { [key: string]: any; } /** * Base resource class for API resources. * Extending this class will make all resource operations available on the child classes. * NOTE: This is an abstract class and cannot be directly initiated. * * @example * class User extends Item {} * * User.fetch(1).then((user) => { * user.update({name: 'John Doe'}); * }); * * const fred = new User({name: 'Fred'}); * fred.save(); * * const jane = User.fetch(1); * jane.then((jane) => { * jane.alias = 'Joe'; * jane.save(); * }); * * User.query().then((users) => { * users[0].destroy(); * }); */ export declare abstract class Item { [key: string]: any; /** * Get a resource by id. * @param {Number|String} id * @param {ItemFetchOptions} options * @param {boolean} [options.cache=true] - Setting it to `true` will ensure that the item will be fetched from cache if it exists and the HTTP request is cached. */ static fetch(id: number | string, {cache}?: ItemFetchOptions): Promise; /** * Query resources. * @param {QueryParams} [queryParams] - Can be used to manipulate the pagination with {page: number, perPage: number}, * but it can also be used to further filter the results with {sort: any, where: any}. * @param {ItemFetchOptions} options * @param {boolean} [options.paginate=false] - Setting {paginate: true} will result in the return value to be a Pagination object. * @param {boolean} [options.cache=true] - Cache the HTTP request. */ static query(queryParams?: QueryParams | null, {paginate, cache}?: ItemQueryOptions): Promise; /** * Get the first item. * @param {QueryParams} [queryOptions] - Can be used to manipulate the pagination with {page: number, perPage: number}, * but it can also be used to further filter the results with {sort: any, where: any}. */ static first(queryOptions?: QueryParams): Promise; private $uri; private $id; /** * Create an instance of the class that extended the Item. * @param {Object} properties - An object with any properties that will be added and accessible on the resource. */ constructor(properties?: ItemInitArgs); readonly uri: string; readonly id: number | string | null; /** * Compare current resource with another object. * @param {Object} resource */ equals(resource: any): boolean; /** * Get the JSON repr. of this item. */ toJSON(): any; /** * Save the current item. */ save(): Promise; /** * Update the resource. * @param {Object} data - An object with any properties to update. */ update(data?: any): Promise; /** * Destroy the current item. */ destroy(): Promise; }